@v12-engine/engine 0.1.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (951) hide show
  1. package/dist/abilities/amounts.d.ts +28 -0
  2. package/dist/abilities/amounts.js +74 -0
  3. package/dist/abilities/amounts.js.map +1 -0
  4. package/dist/abilities/buffs.d.ts +106 -6
  5. package/dist/abilities/buffs.js +443 -0
  6. package/dist/abilities/buffs.js.map +1 -0
  7. package/dist/abilities/castTold.d.ts +2 -0
  8. package/dist/abilities/castTold.js +66 -0
  9. package/dist/abilities/castTold.js.map +1 -0
  10. package/dist/abilities/chance.d.ts +38 -0
  11. package/dist/abilities/chance.js +77 -0
  12. package/dist/abilities/chance.js.map +1 -0
  13. package/dist/abilities/charges.d.ts +18 -0
  14. package/dist/abilities/charges.js +101 -0
  15. package/dist/abilities/charges.js.map +1 -0
  16. package/dist/abilities/control.d.ts +28 -0
  17. package/dist/abilities/control.js +113 -0
  18. package/dist/abilities/control.js.map +1 -0
  19. package/dist/abilities/dispel.js +51 -0
  20. package/dist/abilities/dispel.js.map +1 -0
  21. package/dist/abilities/effectFields.d.ts +1 -1
  22. package/dist/abilities/effectFields.js +676 -0
  23. package/dist/abilities/effectFields.js.map +1 -0
  24. package/dist/abilities/effectIndex.d.ts +27 -0
  25. package/dist/abilities/effectIndex.js +64 -0
  26. package/dist/abilities/effectIndex.js.map +1 -0
  27. package/dist/abilities/effects/buff.d.ts +9 -3
  28. package/dist/abilities/effects/buff.js +84 -0
  29. package/dist/abilities/effects/buff.js.map +1 -0
  30. package/dist/abilities/effects/conditions.d.ts +2 -0
  31. package/dist/abilities/effects/conditions.js +41 -0
  32. package/dist/abilities/effects/conditions.js.map +1 -0
  33. package/dist/abilities/effects/core.js +54 -0
  34. package/dist/abilities/effects/core.js.map +1 -0
  35. package/dist/abilities/effects/damage.d.ts +1 -1
  36. package/dist/abilities/effects/damage.js +43 -0
  37. package/dist/abilities/effects/damage.js.map +1 -0
  38. package/dist/abilities/effects/heal.d.ts +2 -2
  39. package/dist/abilities/effects/heal.js +51 -0
  40. package/dist/abilities/effects/heal.js.map +1 -0
  41. package/dist/abilities/effects/missile.d.ts +13 -1
  42. package/dist/abilities/effects/missile.js +104 -0
  43. package/dist/abilities/effects/missile.js.map +1 -0
  44. package/dist/abilities/effects/morph.d.ts +5 -0
  45. package/dist/abilities/effects/morph.js +43 -0
  46. package/dist/abilities/effects/morph.js.map +1 -0
  47. package/dist/abilities/effects/moves.d.ts +16 -4
  48. package/dist/abilities/effects/moves.js +212 -0
  49. package/dist/abilities/effects/moves.js.map +1 -0
  50. package/dist/abilities/effects/passives.d.ts +19 -9
  51. package/dist/abilities/effects/passives.js +131 -0
  52. package/dist/abilities/effects/passives.js.map +1 -0
  53. package/dist/abilities/effects/proxy.d.ts +5 -0
  54. package/dist/abilities/effects/proxy.js +60 -0
  55. package/dist/abilities/effects/proxy.js.map +1 -0
  56. package/dist/abilities/effects/sight.d.ts +2 -2
  57. package/dist/abilities/effects/sight.js +39 -0
  58. package/dist/abilities/effects/sight.js.map +1 -0
  59. package/dist/abilities/effects/spawn.d.ts +5 -2
  60. package/dist/abilities/effects/spawn.js +40 -0
  61. package/dist/abilities/effects/spawn.js.map +1 -0
  62. package/dist/abilities/effects/timed.d.ts +2 -2
  63. package/dist/abilities/effects/timed.js +96 -0
  64. package/dist/abilities/effects/timed.js.map +1 -0
  65. package/dist/abilities/effects/trade.d.ts +1 -1
  66. package/dist/abilities/effects/trade.js +25 -0
  67. package/dist/abilities/effects/trade.js.map +1 -0
  68. package/dist/abilities/effects.d.ts +97 -23
  69. package/dist/abilities/effects.js +860 -0
  70. package/dist/abilities/effects.js.map +1 -0
  71. package/dist/abilities/land.d.ts +38 -4
  72. package/dist/abilities/land.js +189 -0
  73. package/dist/abilities/land.js.map +1 -0
  74. package/dist/abilities/recast.d.ts +45 -0
  75. package/dist/abilities/recast.js +118 -0
  76. package/dist/abilities/recast.js.map +1 -0
  77. package/dist/abilities/scaled.js +40 -0
  78. package/dist/abilities/scaled.js.map +1 -0
  79. package/dist/abilities/screen.d.ts +6 -0
  80. package/dist/abilities/screen.js +83 -0
  81. package/dist/abilities/screen.js.map +1 -0
  82. package/dist/abilities/shapes.d.ts +66 -0
  83. package/dist/abilities/shapes.js +122 -0
  84. package/dist/abilities/shapes.js.map +1 -0
  85. package/dist/abilities/text.d.ts +14 -2
  86. package/dist/abilities/text.js +204 -0
  87. package/dist/abilities/text.js.map +1 -0
  88. package/dist/abilities/triggers.d.ts +98 -0
  89. package/dist/abilities/triggers.js +351 -0
  90. package/dist/abilities/triggers.js.map +1 -0
  91. package/dist/abilityChanges.d.ts +131 -0
  92. package/dist/abilityChanges.js +345 -0
  93. package/dist/abilityChanges.js.map +1 -0
  94. package/dist/ai/area.d.ts +4 -1
  95. package/dist/ai/brain.d.ts +4 -1
  96. package/dist/ai/brain.js +844 -0
  97. package/dist/ai/brain.js.map +1 -0
  98. package/dist/ai/budget.js +74 -0
  99. package/dist/ai/budget.js.map +1 -0
  100. package/dist/ai/checks.d.ts +9 -1
  101. package/dist/ai/checks.js +242 -0
  102. package/dist/ai/checks.js.map +1 -0
  103. package/dist/ai/computer.d.ts +11 -4
  104. package/dist/ai/computer.js +251 -0
  105. package/dist/ai/computer.js.map +1 -0
  106. package/dist/ai/defence.d.ts +4 -0
  107. package/dist/ai/defence.js +430 -0
  108. package/dist/ai/defence.js.map +1 -0
  109. package/dist/ai/define.d.ts +3 -2
  110. package/dist/ai/define.js +31 -0
  111. package/dist/ai/define.js.map +1 -0
  112. package/dist/ai/economy.d.ts +10 -7
  113. package/dist/ai/economy.js +780 -0
  114. package/dist/ai/economy.js.map +1 -0
  115. package/dist/ai/geometry.js +38 -0
  116. package/dist/ai/geometry.js.map +1 -0
  117. package/dist/ai/goals.d.ts +1 -0
  118. package/dist/ai/goals.js +560 -0
  119. package/dist/ai/goals.js.map +1 -0
  120. package/dist/ai/knowledge.d.ts +72 -7
  121. package/dist/ai/knowledge.js +804 -0
  122. package/dist/ai/knowledge.js.map +1 -0
  123. package/dist/ai/lanes.d.ts +10 -2
  124. package/dist/ai/lanes.js +715 -0
  125. package/dist/ai/lanes.js.map +1 -0
  126. package/dist/ai/melee/build.js +264 -0
  127. package/dist/ai/melee/build.js.map +1 -0
  128. package/dist/ai/melee/goals.d.ts +7 -0
  129. package/dist/ai/melee/goals.js +720 -0
  130. package/dist/ai/melee/goals.js.map +1 -0
  131. package/dist/ai/melee/heroes.js +68 -0
  132. package/dist/ai/melee/heroes.js.map +1 -0
  133. package/dist/ai/melee/index.d.ts +1 -1
  134. package/dist/ai/melee/index.js +51 -0
  135. package/dist/ai/melee/index.js.map +1 -0
  136. package/dist/ai/melee/production.js +29 -0
  137. package/dist/ai/melee/production.js.map +1 -0
  138. package/dist/ai/melee/surrender.js +64 -0
  139. package/dist/ai/melee/surrender.js.map +1 -0
  140. package/dist/ai/micro.d.ts +9 -0
  141. package/dist/ai/micro.js +1316 -0
  142. package/dist/ai/micro.js.map +1 -0
  143. package/dist/ai/mission.d.ts +9 -2
  144. package/dist/ai/mission.js +538 -0
  145. package/dist/ai/mission.js.map +1 -0
  146. package/dist/ai/missionRules.d.ts +1 -1
  147. package/dist/ai/missionRules.js +26 -0
  148. package/dist/ai/missionRules.js.map +1 -0
  149. package/dist/ai/module.d.ts +6 -2
  150. package/dist/ai/module.js +37 -0
  151. package/dist/ai/module.js.map +1 -0
  152. package/dist/ai/options.d.ts +3 -3
  153. package/dist/ai/plans/build.d.ts +20 -1
  154. package/dist/ai/plans/build.js +608 -0
  155. package/dist/ai/plans/build.js.map +1 -0
  156. package/dist/ai/plans/placement.d.ts +4 -1
  157. package/dist/ai/plans/placement.js +295 -0
  158. package/dist/ai/plans/placement.js.map +1 -0
  159. package/dist/ai/plans/plans.d.ts +9 -0
  160. package/dist/ai/plans/plans.js +110 -0
  161. package/dist/ai/plans/plans.js.map +1 -0
  162. package/dist/ai/plans/production.d.ts +14 -2
  163. package/dist/ai/plans/production.js +434 -0
  164. package/dist/ai/plans/production.js.map +1 -0
  165. package/dist/ai/plans/purse.d.ts +6 -3
  166. package/dist/ai/plans/purse.js +139 -0
  167. package/dist/ai/plans/purse.js.map +1 -0
  168. package/dist/ai/plans/tech.d.ts +6 -0
  169. package/dist/ai/plans/tech.js +122 -0
  170. package/dist/ai/plans/tech.js.map +1 -0
  171. package/dist/ai/profiles.d.ts +4 -4
  172. package/dist/{profiles-B3NS9jwk.js → ai/profiles.js} +3 -98
  173. package/dist/ai/profiles.js.map +1 -0
  174. package/dist/ai/reach.js +54 -0
  175. package/dist/ai/reach.js.map +1 -0
  176. package/dist/ai/report.d.ts +8 -0
  177. package/dist/ai/report.js +87 -0
  178. package/dist/ai/report.js.map +1 -0
  179. package/dist/ai/roles.d.ts +4 -0
  180. package/dist/ai/roles.js +207 -0
  181. package/dist/ai/roles.js.map +1 -0
  182. package/dist/ai/rules.d.ts +8 -2
  183. package/dist/ai/rules.js +416 -0
  184. package/dist/ai/rules.js.map +1 -0
  185. package/dist/ai/scouting.d.ts +6 -0
  186. package/dist/ai/scouting.js +324 -0
  187. package/dist/ai/scouting.js.map +1 -0
  188. package/dist/ai/settings.js +99 -0
  189. package/dist/ai/settings.js.map +1 -0
  190. package/dist/ai/squads.d.ts +21 -2
  191. package/dist/ai/squads.js +916 -0
  192. package/dist/ai/squads.js.map +1 -0
  193. package/dist/ai/strength.js +320 -0
  194. package/dist/ai/strength.js.map +1 -0
  195. package/dist/ai/task.d.ts +3 -1
  196. package/dist/ai/task.js +17 -0
  197. package/dist/ai/task.js.map +1 -0
  198. package/dist/ai/tasks/attack.js +24 -0
  199. package/dist/ai/tasks/attack.js.map +1 -0
  200. package/dist/ai/tasks/capture.d.ts +3 -3
  201. package/dist/ai/tasks/capture.js +37 -0
  202. package/dist/ai/tasks/capture.js.map +1 -0
  203. package/dist/ai/tasks/creep.js +29 -0
  204. package/dist/ai/tasks/creep.js.map +1 -0
  205. package/dist/ai/tasks/defend.js +61 -0
  206. package/dist/ai/tasks/defend.js.map +1 -0
  207. package/dist/ai/tasks/drop.js +81 -0
  208. package/dist/ai/tasks/drop.js.map +1 -0
  209. package/dist/ai/tasks/escort.js +59 -0
  210. package/dist/ai/tasks/escort.js.map +1 -0
  211. package/dist/ai/tasks/gather.js +48 -0
  212. package/dist/ai/tasks/gather.js.map +1 -0
  213. package/dist/ai/tasks/harass.js +39 -0
  214. package/dist/ai/tasks/harass.js.map +1 -0
  215. package/dist/ai/tasks/hold.js +32 -0
  216. package/dist/ai/tasks/hold.js.map +1 -0
  217. package/dist/ai/tasks/index.js +34 -0
  218. package/dist/ai/tasks/index.js.map +1 -0
  219. package/dist/ai/tasks/move.js +26 -0
  220. package/dist/ai/tasks/move.js.map +1 -0
  221. package/dist/ai/tasks/patrol.js +59 -0
  222. package/dist/ai/tasks/patrol.js.map +1 -0
  223. package/dist/ai/tasks/retreat.js +28 -0
  224. package/dist/ai/tasks/retreat.js.map +1 -0
  225. package/dist/ai/tasks/scout.js +73 -0
  226. package/dist/ai/tasks/scout.js.map +1 -0
  227. package/dist/ai/tasks/shared.d.ts +1 -1
  228. package/dist/ai/tasks/shared.js +137 -0
  229. package/dist/ai/tasks/shared.js.map +1 -0
  230. package/dist/ai/team.d.ts +18 -1
  231. package/dist/ai/team.js +492 -0
  232. package/dist/ai/team.js.map +1 -0
  233. package/dist/ai/threat.d.ts +6 -0
  234. package/dist/ai/threat.js +206 -0
  235. package/dist/ai/threat.js.map +1 -0
  236. package/dist/ai/view.d.ts +21 -7
  237. package/dist/ai/view.js +677 -0
  238. package/dist/ai/view.js.map +1 -0
  239. package/dist/ai/waves.d.ts +6 -0
  240. package/dist/ai/waves.js +410 -0
  241. package/dist/ai/waves.js.map +1 -0
  242. package/dist/ai.js +54 -6239
  243. package/dist/aiTesting.d.ts +6 -3
  244. package/dist/aiTesting.js +229 -0
  245. package/dist/aiTesting.js.map +1 -0
  246. package/dist/areas.d.ts +4 -1
  247. package/dist/areas.js +295 -0
  248. package/dist/areas.js.map +1 -0
  249. package/dist/attacks.d.ts +3 -3
  250. package/dist/attacks.js +127 -0
  251. package/dist/attacks.js.map +1 -0
  252. package/dist/burning.d.ts +267 -0
  253. package/dist/burning.js +795 -0
  254. package/dist/burning.js.map +1 -0
  255. package/dist/bytes.js +21 -0
  256. package/dist/bytes.js.map +1 -0
  257. package/dist/callings.d.ts +71 -0
  258. package/dist/callings.js +157 -0
  259. package/dist/callings.js.map +1 -0
  260. package/dist/cameraOrders.d.ts +78 -0
  261. package/dist/cameraOrders.js +114 -0
  262. package/dist/cameraOrders.js.map +1 -0
  263. package/dist/camps.d.ts +70 -4
  264. package/dist/camps.js +501 -0
  265. package/dist/camps.js.map +1 -0
  266. package/dist/capture.d.ts +15 -3
  267. package/dist/capture.js +304 -0
  268. package/dist/capture.js.map +1 -0
  269. package/dist/cellLayers.d.ts +78 -13
  270. package/dist/cellLayers.js +275 -0
  271. package/dist/cellLayers.js.map +1 -0
  272. package/dist/cellPatches.d.ts +24 -0
  273. package/dist/cellPatches.js +73 -0
  274. package/dist/cellPatches.js.map +1 -0
  275. package/dist/cinematics.d.ts +10 -5
  276. package/dist/cinematics.js +161 -0
  277. package/dist/cinematics.js.map +1 -0
  278. package/dist/clock.d.ts +2 -2
  279. package/dist/clock.js +78 -0
  280. package/dist/clock.js.map +1 -0
  281. package/dist/commands.d.ts +36 -4
  282. package/dist/commands.js +636 -0
  283. package/dist/commands.js.map +1 -0
  284. package/dist/components.d.ts +31 -10
  285. package/dist/components.js +74 -0
  286. package/dist/components.js.map +1 -0
  287. package/dist/computers.d.ts +4 -4
  288. package/dist/computers.js +194 -0
  289. package/dist/computers.js.map +1 -0
  290. package/dist/concealment.d.ts +25 -2
  291. package/dist/concealment.js +409 -0
  292. package/dist/concealment.js.map +1 -0
  293. package/dist/coreComponents.js +130 -0
  294. package/dist/coreComponents.js.map +1 -0
  295. package/dist/createGame.d.ts +306 -0
  296. package/dist/createGame.js +405 -0
  297. package/dist/createGame.js.map +1 -0
  298. package/dist/dashing.d.ts +18 -2
  299. package/dist/dashing.js +41 -0
  300. package/dist/dashing.js.map +1 -0
  301. package/dist/debug.d.ts +8 -0
  302. package/dist/debug.js +5 -3
  303. package/dist/debug2.js +76 -0
  304. package/dist/debug2.js.map +1 -0
  305. package/dist/debugCommands.d.ts +6 -6
  306. package/dist/debugCommands.js +537 -0
  307. package/dist/debugCommands.js.map +1 -0
  308. package/dist/debugging.d.ts +1 -0
  309. package/dist/defaultSets.d.ts +183 -0
  310. package/dist/defaultSets.js +216 -0
  311. package/dist/defaultSets.js.map +1 -0
  312. package/dist/definitions.d.ts +6 -0
  313. package/dist/definitions.js +78 -0
  314. package/dist/definitions.js.map +1 -0
  315. package/dist/defs.d.ts +1895 -165
  316. package/dist/defs.js +380 -0
  317. package/dist/defs.js.map +1 -0
  318. package/dist/denying.d.ts +4 -4
  319. package/dist/denying.js +106 -0
  320. package/dist/denying.js.map +1 -0
  321. package/dist/destructibles.d.ts +2 -2
  322. package/dist/destructibles.js +36 -0
  323. package/dist/destructibles.js.map +1 -0
  324. package/dist/determinism.d.ts +4 -4
  325. package/dist/determinism.js +247 -0
  326. package/dist/determinism.js.map +1 -0
  327. package/dist/dialog.d.ts +17 -2
  328. package/dist/dialog.js +108 -0
  329. package/dist/dialog.js.map +1 -0
  330. package/dist/effectRefs.js +28 -0
  331. package/dist/effectRefs.js.map +1 -0
  332. package/dist/effects.d.ts +27 -11
  333. package/dist/effects.js +110 -0
  334. package/dist/effects.js.map +1 -0
  335. package/dist/endings.d.ts +1 -1
  336. package/dist/endings.js +78 -0
  337. package/dist/endings.js.map +1 -0
  338. package/dist/engagement.d.ts +40 -6
  339. package/dist/engagement.js +530 -0
  340. package/dist/engagement.js.map +1 -0
  341. package/dist/engineEvents.d.ts +72 -9
  342. package/dist/engineEvents.js +520 -0
  343. package/dist/engineEvents.js.map +1 -0
  344. package/dist/entity.d.ts +275 -26
  345. package/dist/entity.js +441 -0
  346. package/dist/entity.js.map +1 -0
  347. package/dist/entityIndex.d.ts +10 -3
  348. package/dist/entityIndex.js +149 -0
  349. package/dist/entityIndex.js.map +1 -0
  350. package/dist/errors.d.ts +6 -2
  351. package/dist/errors.js +59 -0
  352. package/dist/errors.js.map +1 -0
  353. package/dist/events.d.ts +11 -5
  354. package/dist/events.js +158 -0
  355. package/dist/events.js.map +1 -0
  356. package/dist/exactMath.js +273 -0
  357. package/dist/exactMath.js.map +1 -0
  358. package/dist/features.d.ts +1 -1
  359. package/dist/features.js +127 -0
  360. package/dist/features.js.map +1 -0
  361. package/dist/fields.d.ts +25 -5
  362. package/dist/fields.js +140 -0
  363. package/dist/fields.js.map +1 -0
  364. package/dist/fixture.d.ts +3 -3
  365. package/dist/fixture.js +512 -0
  366. package/dist/fixture.js.map +1 -0
  367. package/dist/fog.d.ts +26 -3
  368. package/dist/fog.js +333 -0
  369. package/dist/fog.js.map +1 -0
  370. package/dist/foliage.d.ts +476 -0
  371. package/dist/foliage.js +1478 -0
  372. package/dist/foliage.js.map +1 -0
  373. package/dist/foliageDebug.d.ts +57 -0
  374. package/dist/foliageDebug.js +172 -0
  375. package/dist/foliageDebug.js.map +1 -0
  376. package/dist/foliageRegrowth.d.ts +20 -0
  377. package/dist/foliageRegrowth.js +332 -0
  378. package/dist/foliageRegrowth.js.map +1 -0
  379. package/dist/formState.d.ts +67 -0
  380. package/dist/formState.js +65 -0
  381. package/dist/formState.js.map +1 -0
  382. package/dist/formation.d.ts +46 -8
  383. package/dist/formation.js +297 -0
  384. package/dist/formation.js.map +1 -0
  385. package/dist/forms.d.ts +58 -0
  386. package/dist/forms.js +146 -0
  387. package/dist/forms.js.map +1 -0
  388. package/dist/friendlyFire.d.ts +2 -2
  389. package/dist/friendlyFire.js +37 -0
  390. package/dist/friendlyFire.js.map +1 -0
  391. package/dist/game.d.ts +141 -48
  392. package/dist/game.js +834 -0
  393. package/dist/game.js.map +1 -0
  394. package/dist/gameData.d.ts +96 -22
  395. package/dist/gameData.js +1690 -0
  396. package/dist/gameData.js.map +1 -0
  397. package/dist/gameFiles.d.ts +3 -3
  398. package/dist/gameFiles.js +14 -0
  399. package/dist/gameFiles.js.map +1 -0
  400. package/dist/gates.js +92 -0
  401. package/dist/gates.js.map +1 -0
  402. package/dist/generate.d.ts +28 -1
  403. package/dist/generate.js +1062 -0
  404. package/dist/generate.js.map +1 -0
  405. package/dist/generateWorker.d.ts +7 -3
  406. package/dist/generateWorker.js +86 -0
  407. package/dist/generateWorker.js.map +1 -0
  408. package/dist/grid.d.ts +9 -0
  409. package/dist/grid.js +102 -0
  410. package/dist/grid.js.map +1 -0
  411. package/dist/ground.d.ts +17 -1
  412. package/dist/ground.js +375 -0
  413. package/dist/ground.js.map +1 -0
  414. package/dist/groundObjects.d.ts +70 -0
  415. package/dist/groundObjects.js +371 -0
  416. package/dist/groundObjects.js.map +1 -0
  417. package/dist/groundSpeed.d.ts +20 -3
  418. package/dist/groundSpeed.js +117 -0
  419. package/dist/groundSpeed.js.map +1 -0
  420. package/dist/hero.d.ts +126 -10
  421. package/dist/hero.js +432 -0
  422. package/dist/hero.js.map +1 -0
  423. package/dist/holds.d.ts +94 -0
  424. package/dist/holds.js +305 -0
  425. package/dist/holds.js.map +1 -0
  426. package/dist/home.d.ts +1 -1
  427. package/dist/home.js +30 -0
  428. package/dist/home.js.map +1 -0
  429. package/dist/hooks.d.ts +339 -57
  430. package/dist/hooks.js +105 -0
  431. package/dist/hooks.js.map +1 -0
  432. package/dist/hotReload.d.ts +6 -5
  433. package/dist/hotReload.js +145 -0
  434. package/dist/hotReload.js.map +1 -0
  435. package/dist/ids.d.ts +3 -3
  436. package/dist/ids.js +30 -0
  437. package/dist/ids.js.map +1 -0
  438. package/dist/idsFile.d.ts +36 -0
  439. package/dist/idsFile.js +134 -0
  440. package/dist/idsFile.js.map +1 -0
  441. package/dist/index.d.ts +105 -68
  442. package/dist/index.js +194 -4701
  443. package/dist/inspect.d.ts +29 -2
  444. package/dist/{inspect-D9dWHmZ0.js → inspect.js} +21 -12
  445. package/dist/inspect.js.map +1 -0
  446. package/dist/inventory.d.ts +14 -1
  447. package/dist/inventory.js +84 -0
  448. package/dist/inventory.js.map +1 -0
  449. package/dist/items.d.ts +136 -8
  450. package/dist/items.js +585 -0
  451. package/dist/items.js.map +1 -0
  452. package/dist/lanes.d.ts +12 -3
  453. package/dist/lanes.js +496 -0
  454. package/dist/lanes.js.map +1 -0
  455. package/dist/life.d.ts +6 -2
  456. package/dist/life.js +287 -0
  457. package/dist/life.js.map +1 -0
  458. package/dist/log.d.ts +26 -3
  459. package/dist/log.js +192 -0
  460. package/dist/log.js.map +1 -0
  461. package/dist/manaBurn.d.ts +2 -2
  462. package/dist/manaBurn.js +75 -0
  463. package/dist/manaBurn.js.map +1 -0
  464. package/dist/map/file.d.ts +56 -3
  465. package/dist/map/file.js +264 -0
  466. package/dist/map/file.js.map +1 -0
  467. package/dist/map/images.js +61 -0
  468. package/dist/map/images.js.map +1 -0
  469. package/dist/map/look.d.ts +1 -1
  470. package/dist/map/look.js +30 -0
  471. package/dist/map/look.js.map +1 -0
  472. package/dist/map/pathProfile.js +183 -0
  473. package/dist/map/pathProfile.js.map +1 -0
  474. package/dist/map/resize.d.ts +4 -0
  475. package/dist/map/resize.js +136 -0
  476. package/dist/map/resize.js.map +1 -0
  477. package/dist/map/schema.js +257 -0
  478. package/dist/map/schema.js.map +1 -0
  479. package/dist/map/terrain.js +214 -0
  480. package/dist/map/terrain.js.map +1 -0
  481. package/dist/map/types.d.ts +92 -13
  482. package/dist/map/types.js +251 -0
  483. package/dist/map/types.js.map +1 -0
  484. package/dist/mapCheck/cells.js +94 -0
  485. package/dist/mapCheck/cells.js.map +1 -0
  486. package/dist/mapCheck/rules/foliage.d.ts +9 -0
  487. package/dist/mapCheck/rules/foliage.js +83 -0
  488. package/dist/mapCheck/rules/foliage.js.map +1 -0
  489. package/dist/mapCheck/rules/names.js +39 -0
  490. package/dist/mapCheck/rules/names.js.map +1 -0
  491. package/dist/mapCheck/rules/objects.d.ts +1 -1
  492. package/dist/mapCheck/rules/objects.js +56 -0
  493. package/dist/mapCheck/rules/objects.js.map +1 -0
  494. package/dist/mapCheck/rules/paths.js +32 -0
  495. package/dist/mapCheck/rules/paths.js.map +1 -0
  496. package/dist/mapCheck/rules/players.js +20 -0
  497. package/dist/mapCheck/rules/players.js.map +1 -0
  498. package/dist/mapCheck/rules/races.js +56 -0
  499. package/dist/mapCheck/rules/races.js.map +1 -0
  500. package/dist/mapCheck/rules/random.js +47 -0
  501. package/dist/mapCheck/rules/random.js.map +1 -0
  502. package/dist/mapCheck/rules/regions.js +30 -0
  503. package/dist/mapCheck/rules/regions.js.map +1 -0
  504. package/dist/mapCheck/rules/targets.js +31 -0
  505. package/dist/mapCheck/rules/targets.js.map +1 -0
  506. package/dist/mapCheck/rules/walking.js +45 -0
  507. package/dist/mapCheck/rules/walking.js.map +1 -0
  508. package/dist/mapCheck.d.ts +2 -2
  509. package/dist/mapCheck.js +63 -0
  510. package/dist/mapCheck.js.map +1 -0
  511. package/dist/mapFields.d.ts +25 -2
  512. package/dist/mapFields.js +134 -0
  513. package/dist/mapFields.js.map +1 -0
  514. package/dist/mapFile.js +176 -0
  515. package/dist/mapFile.js.map +1 -0
  516. package/dist/mapMeasure.d.ts +8 -0
  517. package/dist/mapMeasure.js +283 -0
  518. package/dist/mapMeasure.js.map +1 -0
  519. package/dist/mapMerge.d.ts +1 -0
  520. package/dist/mapMerge.js +172 -0
  521. package/dist/mapMerge.js.map +1 -0
  522. package/dist/mapObjectives.js +138 -0
  523. package/dist/mapObjectives.js.map +1 -0
  524. package/dist/mapObjects.js +80 -0
  525. package/dist/mapObjects.js.map +1 -0
  526. package/dist/math.d.ts +37 -7
  527. package/dist/math.js +155 -0
  528. package/dist/math.js.map +1 -0
  529. package/dist/messages.d.ts +71 -4
  530. package/dist/messages.js +29 -0
  531. package/dist/messages.js.map +1 -0
  532. package/dist/missionRules.d.ts +10 -2
  533. package/dist/{missionRules-C-bGxm0Q.js → missionRules.js} +30 -150
  534. package/dist/missionRules.js.map +1 -0
  535. package/dist/mods.d.ts +39 -20
  536. package/dist/mods.js +271 -0
  537. package/dist/mods.js.map +1 -0
  538. package/dist/moves.d.ts +87 -0
  539. package/dist/moves.js +539 -0
  540. package/dist/moves.js.map +1 -0
  541. package/dist/names.d.ts +7 -0
  542. package/dist/names.js +122 -0
  543. package/dist/names.js.map +1 -0
  544. package/dist/navigation/agentParams.js +14 -0
  545. package/dist/navigation/agentParams.js.map +1 -0
  546. package/dist/navigation/air.d.ts +7 -3
  547. package/dist/navigation/air.js +401 -0
  548. package/dist/navigation/air.js.map +1 -0
  549. package/dist/navigation/builds.d.ts +34 -2
  550. package/dist/navigation/builds.js +287 -0
  551. package/dist/navigation/builds.js.map +1 -0
  552. package/dist/navigation/groundAreas.d.ts +59 -1
  553. package/dist/navigation/groundAreas.js +407 -0
  554. package/dist/navigation/groundAreas.js.map +1 -0
  555. package/dist/navigation/navigation.d.ts +98 -9
  556. package/dist/navigation/recast.d.ts +194 -18
  557. package/dist/navigation/recast.js +1379 -0
  558. package/dist/navigation/recast.js.map +1 -0
  559. package/dist/navigation/sidePaths.d.ts +8 -3
  560. package/dist/navigation/sidePaths.js +241 -0
  561. package/dist/navigation/sidePaths.js.map +1 -0
  562. package/dist/navigation/sized.js +243 -0
  563. package/dist/navigation/sized.js.map +1 -0
  564. package/dist/nearest.js +32 -0
  565. package/dist/nearest.js.map +1 -0
  566. package/dist/noise.js +59 -0
  567. package/dist/noise.js.map +1 -0
  568. package/dist/objectives.d.ts +12 -3
  569. package/dist/objectives.js +144 -0
  570. package/dist/objectives.js.map +1 -0
  571. package/dist/orders/basic.d.ts +5 -5
  572. package/dist/orders/basic.js +417 -0
  573. package/dist/orders/basic.js.map +1 -0
  574. package/dist/orders/build.js +278 -0
  575. package/dist/orders/build.js.map +1 -0
  576. package/dist/orders/cast.d.ts +13 -3
  577. package/dist/orders/cast.js +558 -0
  578. package/dist/orders/cast.js.map +1 -0
  579. package/dist/orders/facts.js +16 -0
  580. package/dist/orders/facts.js.map +1 -0
  581. package/dist/orders/harvest.d.ts +21 -5
  582. package/dist/orders/harvest.js +540 -0
  583. package/dist/orders/harvest.js.map +1 -0
  584. package/dist/orders/idle.d.ts +3 -1
  585. package/dist/orders/idle.js +234 -0
  586. package/dist/orders/idle.js.map +1 -0
  587. package/dist/orders/items.js +92 -0
  588. package/dist/orders/items.js.map +1 -0
  589. package/dist/orders/queue.js +108 -0
  590. package/dist/orders/queue.js.map +1 -0
  591. package/dist/orders/waiting.d.ts +39 -0
  592. package/dist/orders/waiting.js +149 -0
  593. package/dist/orders/waiting.js.map +1 -0
  594. package/dist/pack.schema.js +13 -0
  595. package/dist/pack.schema.js.map +1 -0
  596. package/dist/pack.schema.json +7622 -841
  597. package/dist/packs/director/index.d.ts +13 -5
  598. package/dist/packs/director/index.js +204 -0
  599. package/dist/packs/director/index.js.map +1 -0
  600. package/dist/packs/heroes/campaign.d.ts +3 -2
  601. package/dist/packs/heroes/campaign.js +241 -0
  602. package/dist/packs/heroes/campaign.js.map +1 -0
  603. package/dist/packs/heroes/carry.d.ts +6 -0
  604. package/dist/packs/heroes/carry.js +112 -0
  605. package/dist/packs/heroes/carry.js.map +1 -0
  606. package/dist/packs/heroes/commands.js +115 -0
  607. package/dist/packs/heroes/commands.js.map +1 -0
  608. package/dist/packs/heroes/fallen.d.ts +43 -0
  609. package/dist/packs/heroes/fallen.js +61 -0
  610. package/dist/packs/heroes/fallen.js.map +1 -0
  611. package/dist/packs/heroes/hire.js +60 -0
  612. package/dist/packs/heroes/hire.js.map +1 -0
  613. package/dist/packs/heroes/index.d.ts +7 -6
  614. package/dist/packs/heroes/index.js +130 -0
  615. package/dist/packs/heroes/index.js.map +1 -0
  616. package/dist/packs/heroes/loop.d.ts +95 -0
  617. package/dist/packs/heroes/loop.js +250 -0
  618. package/dist/packs/heroes/loop.js.map +1 -0
  619. package/dist/packs/heroes/making.d.ts +6 -3
  620. package/dist/packs/heroes/making.js +55 -0
  621. package/dist/packs/heroes/making.js.map +1 -0
  622. package/dist/packs/heroes/respawn.d.ts +3 -3
  623. package/dist/packs/heroes/respawn.js +87 -0
  624. package/dist/packs/heroes/respawn.js.map +1 -0
  625. package/dist/packs/heroes/sets.d.ts +32 -0
  626. package/dist/packs/heroes/sets.js +51 -0
  627. package/dist/packs/heroes/sets.js.map +1 -0
  628. package/dist/packs/heroes/spells.d.ts +16 -0
  629. package/dist/packs/heroes/spells.js +269 -0
  630. package/dist/packs/heroes/spells.js.map +1 -0
  631. package/dist/packs/items/defaults.d.ts +43 -0
  632. package/dist/packs/items/defaults.js +1504 -0
  633. package/dist/packs/items/defaults.js.map +1 -0
  634. package/dist/packs/items/index.d.ts +27 -0
  635. package/dist/packs/items/index.js +214 -0
  636. package/dist/packs/items/index.js.map +1 -0
  637. package/dist/packs/moba/index.d.ts +3 -3
  638. package/dist/packs/moba/index.js +174 -0
  639. package/dist/packs/moba/index.js.map +1 -0
  640. package/dist/packs/pack.d.ts +15 -15
  641. package/dist/packs/pack.js +14 -0
  642. package/dist/packs/pack.js.map +1 -0
  643. package/dist/packs.d.ts +15 -7
  644. package/dist/packs.js +222 -0
  645. package/dist/packs.js.map +1 -0
  646. package/dist/paths.d.ts +2 -0
  647. package/dist/paths.js +109 -0
  648. package/dist/paths.js.map +1 -0
  649. package/dist/plain.js +57 -0
  650. package/dist/plain.js.map +1 -0
  651. package/dist/player.d.ts +33 -10
  652. package/dist/player.js +159 -0
  653. package/dist/player.js.map +1 -0
  654. package/dist/portals.d.ts +1 -1
  655. package/dist/portals.js +194 -0
  656. package/dist/portals.js.map +1 -0
  657. package/dist/prefabs.d.ts +25 -2
  658. package/dist/prefabs.js +239 -0
  659. package/dist/prefabs.js.map +1 -0
  660. package/dist/presetBuildings.js +58 -0
  661. package/dist/presetBuildings.js.map +1 -0
  662. package/dist/presetFoliage.d.ts +27 -0
  663. package/dist/presetFoliage.js +98 -0
  664. package/dist/presetFoliage.js.map +1 -0
  665. package/dist/presetGround.js +65 -0
  666. package/dist/presetGround.js.map +1 -0
  667. package/dist/proxies.d.ts +12 -0
  668. package/dist/proxies.js +79 -0
  669. package/dist/proxies.js.map +1 -0
  670. package/dist/query.d.ts +56 -0
  671. package/dist/query.js +88 -0
  672. package/dist/query.js.map +1 -0
  673. package/dist/races.d.ts +15 -14
  674. package/dist/races.js +172 -0
  675. package/dist/races.js.map +1 -0
  676. package/dist/randomGroups.js +91 -0
  677. package/dist/randomGroups.js.map +1 -0
  678. package/dist/registry.d.ts +117 -53
  679. package/dist/registry.js +323 -0
  680. package/dist/registry.js.map +1 -0
  681. package/dist/remains.d.ts +11 -9
  682. package/dist/remains.js +188 -0
  683. package/dist/remains.js.map +1 -0
  684. package/dist/replication.d.ts +12 -7
  685. package/dist/replication.js +100 -0
  686. package/dist/replication.js.map +1 -0
  687. package/dist/rng.d.ts +2 -0
  688. package/dist/rng.js +40 -0
  689. package/dist/rng.js.map +1 -0
  690. package/dist/rules.d.ts +186 -99
  691. package/dist/rules.js +179 -0
  692. package/dist/rules.js.map +1 -0
  693. package/dist/rulesCheck.d.ts +5 -4
  694. package/dist/rulesCheck.js +693 -0
  695. package/dist/rulesCheck.js.map +1 -0
  696. package/dist/runes.d.ts +2 -2
  697. package/dist/runes.js +80 -0
  698. package/dist/runes.js.map +1 -0
  699. package/dist/save.d.ts +37 -12
  700. package/dist/save.js +532 -0
  701. package/dist/save.js.map +1 -0
  702. package/dist/scenario.d.ts +2 -2
  703. package/dist/scenario.js +99 -0
  704. package/dist/scenario.js.map +1 -0
  705. package/dist/scheduler.d.ts +3 -0
  706. package/dist/scheduler.js +156 -0
  707. package/dist/scheduler.js.map +1 -0
  708. package/dist/score.d.ts +19 -19
  709. package/dist/score.js +709 -0
  710. package/dist/score.js.map +1 -0
  711. package/dist/sequences.d.ts +10 -6
  712. package/dist/sequences.js +206 -0
  713. package/dist/sequences.js.map +1 -0
  714. package/dist/server/doorman.js +154 -0
  715. package/dist/server/doorman.js.map +1 -0
  716. package/dist/server/gameServer.d.ts +16 -1
  717. package/dist/server/gameServer.js +643 -0
  718. package/dist/server/gameServer.js.map +1 -0
  719. package/dist/server/index.d.ts +1 -1
  720. package/dist/server/lobby.js +199 -0
  721. package/dist/server/lobby.js.map +1 -0
  722. package/dist/server/log.js +18 -0
  723. package/dist/server/log.js.map +1 -0
  724. package/dist/server/match.js +267 -0
  725. package/dist/server/match.js.map +1 -0
  726. package/dist/server/mode.d.ts +18 -9
  727. package/dist/server/mode.js +220 -0
  728. package/dist/server/mode.js.map +1 -0
  729. package/dist/{navigation-worker.js → server/navigation-worker.js} +1 -1
  730. package/dist/server/navigation-worker.js.map +1 -0
  731. package/dist/server/navigation.js +39 -0
  732. package/dist/server/navigation.js.map +1 -0
  733. package/dist/server/ops.d.ts +4 -0
  734. package/dist/server/ops.js +137 -0
  735. package/dist/server/ops.js.map +1 -0
  736. package/dist/server/packs.d.ts +3 -3
  737. package/dist/server/packs.js +32 -0
  738. package/dist/server/packs.js.map +1 -0
  739. package/dist/server/ratings.d.ts +5 -0
  740. package/dist/server/ratings.js +104 -0
  741. package/dist/server/ratings.js.map +1 -0
  742. package/dist/server/relay.d.ts +12 -2
  743. package/dist/server/relay.js +144 -0
  744. package/dist/server/relay.js.map +1 -0
  745. package/dist/server/rooms.d.ts +9 -2
  746. package/dist/server/rooms.js +442 -0
  747. package/dist/server/rooms.js.map +1 -0
  748. package/dist/server/seat.js +116 -0
  749. package/dist/server/seat.js.map +1 -0
  750. package/dist/server/seatSettings.d.ts +3 -3
  751. package/dist/server/seatSettings.js +63 -0
  752. package/dist/server/seatSettings.js.map +1 -0
  753. package/dist/server/secret.js +13 -0
  754. package/dist/server/secret.js.map +1 -0
  755. package/dist/server/start.d.ts +13 -6
  756. package/dist/server/start.js +76 -0
  757. package/dist/server/start.js.map +1 -0
  758. package/dist/server/websocket.d.ts +9 -1
  759. package/dist/server/websocket.js +306 -0
  760. package/dist/server/websocket.js.map +1 -0
  761. package/dist/server.js +15 -2861
  762. package/dist/session/can.js +26 -0
  763. package/dist/session/can.js.map +1 -0
  764. package/dist/session/commandReplay.d.ts +8 -2
  765. package/dist/session/commandReplay.js +293 -0
  766. package/dist/session/commandReplay.js.map +1 -0
  767. package/dist/session/debug.js +151 -0
  768. package/dist/session/debug.js.map +1 -0
  769. package/dist/session/delay.js +62 -0
  770. package/dist/session/delay.js.map +1 -0
  771. package/dist/session/delta.d.ts +14 -1
  772. package/dist/session/delta.js +407 -0
  773. package/dist/session/delta.js.map +1 -0
  774. package/dist/session/entityState.js +415 -0
  775. package/dist/session/entityState.js.map +1 -0
  776. package/dist/session/local.d.ts +47 -5
  777. package/dist/session/local.js +670 -0
  778. package/dist/session/local.js.map +1 -0
  779. package/dist/session/memory.d.ts +20 -2
  780. package/dist/session/memory.js +131 -0
  781. package/dist/session/memory.js.map +1 -0
  782. package/dist/session/protocol.d.ts +325 -31
  783. package/dist/session/protocol.js +55 -0
  784. package/dist/session/protocol.js.map +1 -0
  785. package/dist/session/remote.d.ts +74 -12
  786. package/dist/session/remote.js +1394 -0
  787. package/dist/session/remote.js.map +1 -0
  788. package/dist/session/replay.d.ts +11 -2
  789. package/dist/session/replay.js +160 -0
  790. package/dist/session/replay.js.map +1 -0
  791. package/dist/session/seed.js +12 -0
  792. package/dist/session/seed.js.map +1 -0
  793. package/dist/session/share.d.ts +5 -1
  794. package/dist/session/share.js +94 -0
  795. package/dist/session/share.js.map +1 -0
  796. package/dist/session/socket.d.ts +1 -1
  797. package/dist/session/socket.js +29 -0
  798. package/dist/session/socket.js.map +1 -0
  799. package/dist/session/wire.d.ts +5 -0
  800. package/dist/session/wire.js +84 -0
  801. package/dist/session/wire.js.map +1 -0
  802. package/dist/session/worker.d.ts +77 -12
  803. package/dist/session/worker.js +499 -0
  804. package/dist/session/worker.js.map +1 -0
  805. package/dist/shared.d.ts +31 -5
  806. package/dist/shared.js +166 -0
  807. package/dist/shared.js.map +1 -0
  808. package/dist/sides.d.ts +9 -3
  809. package/dist/sides.js +149 -0
  810. package/dist/sides.js.map +1 -0
  811. package/dist/sight.js +85 -0
  812. package/dist/sight.js.map +1 -0
  813. package/dist/simulate-worker.js +1 -1
  814. package/dist/simulate.d.ts +12 -8
  815. package/dist/{simulate-oXBiw1Ff.js → simulate.js} +10 -11
  816. package/dist/simulate.js.map +1 -0
  817. package/dist/smart.js +77 -0
  818. package/dist/smart.js.map +1 -0
  819. package/dist/spatial.d.ts +32 -16
  820. package/dist/spatial.js +234 -0
  821. package/dist/spatial.js.map +1 -0
  822. package/dist/spawning.d.ts +1 -0
  823. package/dist/spawning.js +224 -0
  824. package/dist/spawning.js.map +1 -0
  825. package/dist/stances.d.ts +6 -3
  826. package/dist/stances.js +169 -0
  827. package/dist/stances.js.map +1 -0
  828. package/dist/start.d.ts +10 -10
  829. package/dist/start.js +75 -0
  830. package/dist/start.js.map +1 -0
  831. package/dist/stats.d.ts +42 -16
  832. package/dist/stats.js +290 -0
  833. package/dist/stats.js.map +1 -0
  834. package/dist/summoned.d.ts +52 -0
  835. package/dist/summoned.js +38 -0
  836. package/dist/summoned.js.map +1 -0
  837. package/dist/summons.d.ts +10 -13
  838. package/dist/summons.js +271 -0
  839. package/dist/summons.js.map +1 -0
  840. package/dist/systems/abilities.js +224 -0
  841. package/dist/systems/abilities.js.map +1 -0
  842. package/dist/systems/combat.d.ts +35 -1
  843. package/dist/systems/combat.js +677 -0
  844. package/dist/systems/combat.js.map +1 -0
  845. package/dist/systems/combatTold.d.ts +3 -1
  846. package/dist/systems/combatTold.js +85 -0
  847. package/dist/systems/combatTold.js.map +1 -0
  848. package/dist/systems/construction.js +80 -0
  849. package/dist/systems/construction.js.map +1 -0
  850. package/dist/systems/economy.d.ts +0 -6
  851. package/dist/systems/economy.js +128 -0
  852. package/dist/systems/economy.js.map +1 -0
  853. package/dist/systems/fog.d.ts +1 -1
  854. package/dist/systems/fog.js +120 -0
  855. package/dist/systems/fog.js.map +1 -0
  856. package/dist/systems/life.js +32 -0
  857. package/dist/systems/life.js.map +1 -0
  858. package/dist/systems/movement.d.ts +24 -12
  859. package/dist/systems/movement.js +1247 -0
  860. package/dist/systems/movement.js.map +1 -0
  861. package/dist/systems/orders.js +64 -0
  862. package/dist/systems/orders.js.map +1 -0
  863. package/dist/systems/production.js +322 -0
  864. package/dist/systems/production.js.map +1 -0
  865. package/dist/systems/productionQueue.js +120 -0
  866. package/dist/systems/productionQueue.js.map +1 -0
  867. package/dist/systems/victory.d.ts +1 -1
  868. package/dist/systems/victory.js +56 -0
  869. package/dist/systems/victory.js.map +1 -0
  870. package/dist/talk.d.ts +6 -6
  871. package/dist/talk.js +153 -0
  872. package/dist/talk.js.map +1 -0
  873. package/dist/targeting.d.ts +142 -0
  874. package/dist/targeting.js +49 -0
  875. package/dist/targeting.js.map +1 -0
  876. package/dist/tech.d.ts +20 -3
  877. package/dist/tech.js +239 -0
  878. package/dist/tech.js.map +1 -0
  879. package/dist/techTree.d.ts +7 -0
  880. package/dist/techTree.js +90 -0
  881. package/dist/techTree.js.map +1 -0
  882. package/dist/terrain.d.ts +59 -7
  883. package/dist/terrain.js +389 -0
  884. package/dist/terrain.js.map +1 -0
  885. package/dist/terrainSave.d.ts +6 -0
  886. package/dist/terrainSave.js +74 -0
  887. package/dist/terrainSave.js.map +1 -0
  888. package/dist/testing.d.ts +8 -7
  889. package/dist/testing.js +13 -739
  890. package/dist/testing.js.map +1 -1
  891. package/dist/tiles.d.ts +1 -1
  892. package/dist/tiles.js +43 -0
  893. package/dist/tiles.js.map +1 -0
  894. package/dist/timers.d.ts +29 -4
  895. package/dist/timers.js +242 -0
  896. package/dist/timers.js.map +1 -0
  897. package/dist/tomes.d.ts +4 -4
  898. package/dist/tomes.js +94 -0
  899. package/dist/tomes.js.map +1 -0
  900. package/dist/trade.js +103 -0
  901. package/dist/trade.js.map +1 -0
  902. package/dist/transport.d.ts +6 -1
  903. package/dist/transport.js +281 -0
  904. package/dist/transport.js.map +1 -0
  905. package/dist/tunables.d.ts +10 -3
  906. package/dist/tunables.js +56 -0
  907. package/dist/tunables.js.map +1 -0
  908. package/dist/unitResources.d.ts +67 -0
  909. package/dist/unitResources.js +266 -0
  910. package/dist/unitResources.js.map +1 -0
  911. package/dist/upkeep.d.ts +6 -1
  912. package/dist/upkeep.js +26 -0
  913. package/dist/upkeep.js.map +1 -0
  914. package/dist/veterancy.d.ts +8 -3
  915. package/dist/veterancy.js +131 -0
  916. package/dist/veterancy.js.map +1 -0
  917. package/dist/vision.d.ts +36 -0
  918. package/dist/vision.js +133 -0
  919. package/dist/vision.js.map +1 -0
  920. package/dist/walls.d.ts +1 -1
  921. package/dist/walls.js +278 -0
  922. package/dist/walls.js.map +1 -0
  923. package/dist/world.d.ts +606 -88
  924. package/dist/world.js +1263 -0
  925. package/dist/world.js.map +1 -0
  926. package/package.json +2 -2
  927. package/dist/ai.js.map +0 -1
  928. package/dist/attributes.d.ts +0 -66
  929. package/dist/brain-BvVdUhX8.js +0 -7659
  930. package/dist/brain-BvVdUhX8.js.map +0 -1
  931. package/dist/builds-C6LfgvEU.js +0 -460
  932. package/dist/builds-C6LfgvEU.js.map +0 -1
  933. package/dist/coreComponents-syuh2fPG.js +0 -5149
  934. package/dist/coreComponents-syuh2fPG.js.map +0 -1
  935. package/dist/debugCommands-CzjrSm66.js +0 -14739
  936. package/dist/debugCommands-CzjrSm66.js.map +0 -1
  937. package/dist/determinism-BCymQwiE.js +0 -518
  938. package/dist/determinism-BCymQwiE.js.map +0 -1
  939. package/dist/game-DiJEN-Ks.js +0 -5800
  940. package/dist/game-DiJEN-Ks.js.map +0 -1
  941. package/dist/index.js.map +0 -1
  942. package/dist/inspect-D9dWHmZ0.js.map +0 -1
  943. package/dist/local-Dkovq42k.js +0 -1379
  944. package/dist/local-Dkovq42k.js.map +0 -1
  945. package/dist/missionRules-C-bGxm0Q.js.map +0 -1
  946. package/dist/navigation-worker.js.map +0 -1
  947. package/dist/packs-g5thvmGn.js +0 -3199
  948. package/dist/packs-g5thvmGn.js.map +0 -1
  949. package/dist/profiles-B3NS9jwk.js.map +0 -1
  950. package/dist/server.js.map +0 -1
  951. package/dist/simulate-oXBiw1Ff.js.map +0 -1
@@ -1 +0,0 @@
1
- {"version":3,"file":"local-Dkovq42k.js","names":["checkpointEvent"],"sources":["../src/session/protocol.ts","../src/session/can.ts","../src/session/delta.ts","../src/session/debug.ts","../src/session/entityState.ts","../src/session/local.ts"],"sourcesContent":["import type { SystemTiming } from '#engine/scheduler'\nimport type { DataKind, DataValues } from '#engine/gameData'\nimport type { Logger } from '#engine/log'\nimport type { Command, ModCommand } from '#engine/commands'\nimport type { ChatAudience, PingKind } from '#engine/talk'\nimport type { Cost, DamageType, ResourceKind, Stats } from '#engine/defs'\nimport type { PlayerId } from '#engine/entity'\nimport type { Vec2 } from '#engine/math'\nimport type { SaidLine } from '#engine/dialog'\nimport type { Message } from '#engine/messages'\nimport type { ObjectiveState, ObjectiveStatus } from '#engine/objectives'\nimport type { ShownTimer } from '#engine/timers'\nimport type { WorldSave } from '#engine/save'\nimport type { Registry } from '#engine/registry'\nimport type { Inspection, InspectTarget, LoggedEvent, WorldListing } from '#engine/inspect'\nimport type { Lane } from '#engine/lanes'\nimport type { MapCamera, MapDoodad, MapEnvironment, MapPath, MapRegion } from '#engine/map'\nimport type { Terrain } from '#engine/terrain'\nimport type { TerrainPatch } from '#engine/ground'\nimport type { MessageKind } from '#engine/world'\nimport type { ScoreLineState, ScoreState } from '#engine/score'\n\n/**\n * What travels between the simulation and a player's screen.\n *\n * A client never touches the world. It gets snapshots of what its player is allowed\n * to know and sends commands back. Today both ends live in the same page, later the\n * simulation runs on a server, and nothing on the client has to change for that.\n * Everything in here is plain data for that reason: it has to survive being sent.\n */\n\n/** @beta */\nexport interface QueueItemState {\n\tkind: 'unit' | 'upgrade' | 'revive' | 'morph'\n\tid: string\n\t/** 0..1 */\n\tprogress: number\n}\n\n/** @beta */\nexport interface AbilityInfo {\n\tid: string\n\tlevel: number\n\t/** Seconds until it can be used again */\n\tcooldown: number\n\t/** Uses left, of an ability with charges, while it holds fewer than it can (all of them when left out: `chargesLeft`) */\n\tcharges?: number\n\t/** Seconds until the next use is back, while it holds fewer than it can */\n\trefill?: number\n\tautocast: boolean\n\t/**\n\t * What the game's `canCast` hook decided, where it is not what the declared costs say: a reason it cannot be used\n\t * now, or null for one it can be used for all that (\"free while Clearcasting\"). Left out when there is nothing to add\n\t */\n\tdecided?: Message | null\n}\n\n/**\n * An ability of a unit as everyone who sees it may be told (`GameRules.hud.shareAbilities`): what it is and its\n * level, and how much of its cooldown is left where the rules share that too\n *\n * @beta\n */\nexport interface SharedAbility {\n\t/** The ability's id */\n\tid: string\n\t/** Its level: 1 and up, those not learned are not told */\n\tlevel: number\n\t/**\n\t * Seconds until it can be used again: with `shareAbilities: 'cooldowns'` alone. Whole seconds, rounded up, from a\n\t * host (`quantize`): the plate counts down between\n\t */\n\tcooldown?: number\n}\n\n/**\n * Something a unit carries\n *\n * @beta\n */\nexport interface CarriedItem {\n\t/** Which one of the unit's items, for commands */\n\tid: number\n\titem: string\n\tcharges: number\n\t/** Seconds until it can be used again */\n\tcooldown: number\n\t/**\n\t * Uses left of the ability it casts, where that has charges (`AbilityDef.charges`) and holds fewer than it can: all\n\t * of them when left out. None, and it cannot be used until one comes back\n\t */\n\tuses?: number\n}\n\n/**\n * What everyone who sees a unit is told of its items (`inventorySlots`' snapshot): what it carries; its owner and their\n * allies the slots too, for commands\n *\n * @beta\n */\nexport interface InventoryInfo {\n\t/** The items it carries, by id: anyone who sees the unit sees that */\n\titems: string[]\n\t/** One entry per slot, null for the empty ones: for its owner and their allies */\n\tslots?: (CarriedItem | null)[]\n}\n\n/**\n * What a worker's owner and their allies are told of what it carries (`gathering`'s snapshot)\n *\n * @beta\n */\nexport interface GatheringInfo {\n\t/** How much of it */\n\tcarrying: number\n\t/** What it is that it carries, or last gathered. Null for a worker that has not gathered anything yet */\n\tkind: ResourceKind | null\n}\n\n/**\n * What a building's owner and their allies are told of what it makes (`productionQueue`'s snapshot): its queue and where\n * what comes out goes; and everyone who sees it, how far it is in turning into another type\n *\n * @beta\n */\nexport interface ProductionInfo {\n\t/** What it makes, the first being made: for its owner and their allies */\n\tqueue?: QueueItemState[]\n\t/** Where what it makes goes once out: for its owner and their allies */\n\trally?: Vec2\n\t/** 0..1 while it turns into another type (`upgradeTo`, `UnitTypeDef.upgradesTo`): what every player who sees it sees */\n\tupgrade?: number\n\t/** The type it turns into, while it does */\n\tupgradeTo?: string\n}\n\n/**\n * An item lying on the ground\n *\n * @beta\n */\nexport interface GroundItemState {\n\tid: number\n\titem: string\n\tx: number\n\tz: number\n}\n\n/** @beta */\nexport interface StockInfo {\n\titem: string\n\t/** How many are left. Left out for what a shop never runs out of */\n\tcount?: number\n\t/** 0..1 towards the next one, when the shop is not full */\n\trestock: number\n}\n\n/**\n * An ability a hero can put points into\n *\n * @beta\n */\nexport interface LearnableInfo {\n\tid: string\n\tlevel: number\n\tmaxLevel: number\n\t/** Hero level needed for the next level of the ability */\n\tneeds: number\n\t/** Whether a point can go into it right now */\n\tavailable: boolean\n}\n\n/**\n * A hero's experience: what it has, at what the level it is at started and at what the next one does (`HeroSent.xp`)\n *\n * @beta\n */\nexport interface XpInfo {\n\t/** Experience in total, whole */\n\txp: number\n\t/** What the level it is at took */\n\tlevelXp: number\n\t/** What the next level takes */\n\tnextXp: number\n}\n\n/**\n * A hero of the player, for the row of portraits. Fallen ones are in here too\n *\n * @beta\n */\nexport interface HeroSummary {\n\tid: number\n\ttype: string\n\tlevel: number\n\talive: boolean\n\t/** 0..1 */\n\thp: number\n\tmana: number\n\tpoints: number\n\t/** 0..1 while being brought back: at an altar, or coming back by itself (`withRespawn`) */\n\treviving?: number\n\t/** Seconds until it comes back by itself, while it waits to (`withRespawn`) */\n\trespawnIn?: number\n\t/** What bringing it back would cost */\n\treviveCost?: Cost\n}\n\n/**\n * The part of an entity only its owner and their allies get to know\n *\n * @beta\n */\nexport interface OwnEntityState {\n\t/** Another player's, which this one may command: its owner shares control with them (`world.shareControl`) */\n\tshared?: boolean\n\t/** Inside something, like a worker in a mine */\n\thidden: boolean\n\t/** Type of the order being carried out */\n\torder: string | null\n\t/** What it is about to build, for a build order */\n\tbuild?: string\n\t/** Orders in the queue, the current one included */\n\torders: number\n\tpassive: boolean\n\tfighting: boolean\n\t/** Where it is walking to right now */\n\tgoal?: Vec2\n\t/** Destinations of the orders waiting in the queue: none while nothing waits */\n\twaypoints?: Vec2[]\n\tabilities?: AbilityInfo[]\n}\n\n/** @beta */\nexport interface EntityState {\n\tid: number\n\ttype: string\n\towner: PlayerId\n\tx: number\n\tz: number\n\tfacing: number\n\thp: number\n\t/** The stats that are not what its type starts with. Whoever sees a unit can tell what it is capable of */\n\tstats?: Partial<Stats>\n\t/** What its shields still hold */\n\tshield?: number\n\t/** On its way through the air: from where to where, and how high it rises in between */\n\tleap?: { from: Vec2; to: Vec2; height: number }\n\t/** False for a structure that is out of sight and shown the way it was last seen */\n\tvisible: boolean\n\t/** Left out when it is what the unit type says */\n\tmaxHp?: number\n\tmana?: number\n\tmaxMana?: number\n\t/** Ids of the buffs on it */\n\tbuffs?: string[]\n\t/** How many of each of its buffs that stack it carries, for the ones it carries any of */\n\tstacks?: Record<string, number>\n\t/**\n\t * Seconds left of each of its `buffs`, in their order (whole seconds, rounded up, from a host: the plate counts\n\t * down between); -1 for one kept up by an aura or a passive (`BuffInstance.kept`) or that lasts until it is\n\t * taken off. Where the rules share them (`GameRules.hud.shareBuffTimes`)\n\t *\n\t * @beta\n\t */\n\tbuffTimes?: number[]\n\t/**\n\t * The abilities it has learned, for whoever sees it, its side's or not, where the rules share them\n\t * (`GameRules.hud.shareAbilities`). Its side has them in `own.abilities` all the same\n\t *\n\t * @beta\n\t */\n\tabilities?: SharedAbility[]\n\t/** What is left in a resource */\n\tresource?: number\n\t/** The resource it stands on (`UnitTypeDef.builtOn`, a cursed mine on a gold mine), by id */\n\ton?: number\n\t/** Doing nothing until woken, like a creep sleeping through the night */\n\tasleep?: boolean\n\t/** How big it is drawn, when that is not 1 */\n\tscale?: number\n\t/** Which of the models of its type it is drawn with, when the map says */\n\tlook?: string\n\t/** Seconds left and seconds in all, for what is gone by itself after a while, like a ward */\n\tlifetime?: { left: number; total: number }\n\t/** Invisible to enemies right now. Whoever gets this sees it all the same: it is theirs, or they found it */\n\tunseen?: boolean\n\t/** Components of game modules and mods that are sent to this player (see `Component.replicate`), by id */\n\tcomponents?: Record<string, unknown>\n\t/** The name the map or the rules gave it (`world.named`), for whoever knows of it: \"the gate\", \"the hero\" */\n\tname?: string\n\town?: OwnEntityState\n}\n\n/** @beta */\nexport interface PlayerState {\n\tid: PlayerId\n\tname: string\n\tteam: number\n\tcolor: [number, number, number]\n\tneutral: boolean\n\t/** Whether they are the creeps: hostile to everyone, but no one's rival */\n\tcreeps?: boolean\n\t/** The race they play (`raceOf`): left out in a game without races */\n\trace?: string\n\tdefeated: boolean\n\t/** What they are to the player the snapshot is for: by their teams, or as the rules set it (`setRelation`) */\n\trelation: 'self' | 'ally' | 'enemy' | 'neutral'\n\t/**\n\t * What the player the snapshot is for shares with this ally (`shareWith`): their units' control, and their team's\n\t * sight (always, for an ally of their team). Left out for who is not an ally\n\t */\n\tshared?: { control: boolean; vision: boolean }\n\t/** Only filled in for the player the snapshot is for */\n\town?: {\n\t\t/** What the player has of each resource, by resource id */\n\t\tresources: Record<ResourceKind, number>\n\t\tsupplyUsed: number\n\t\tsupplyCap: number\n\t\t/** The game's other pools of supply, by name (`GameRules.supply.pools`): left out in a game with none */\n\t\tsupplies?: Record<string, { used: number; cap: number }>\n\t\t/** What the size of the army costs in income */\n\t\tupkeep: { tier: number; name: string; income: number }\n\t\tupgrades: Record<string, number>\n\t\tresearching: string[]\n\t\t/** Types of the finished buildings the player has, with what those count as */\n\t\ttech: string[]\n\t\theroes: HeroSummary[]\n\t\t/** What the player is set to do, in a mission. Empty in a game without objectives */\n\t\tobjectives: ObjectiveState[]\n\t\t/** The timers the rules show the player (`world.timers.show`): their words and the tick each goes off at */\n\t\ttimers?: ShownTimer[]\n\t\t/**\n\t\t * What the game's `requirement` hook decided, where it differs from what the requirements say (see\n\t\t * `PlayerFacts.unlocks`): by unit or structure type, and `upgrade:<id>` for the next level. Left out without one\n\t\t */\n\t\tunlocks?: Record<string, Message | null>\n\t\t/**\n\t\t * What the game's `available` hook decided, where it differs from what their race says (see\n\t\t * `PlayerFacts.availability`): by unit or structure type, and `upgrade:<id>`. Left out without one\n\t\t */\n\t\tavailability?: Record<string, boolean>\n\t}\n}\n\n/** @beta */\nexport interface ProjectileState {\n\tid: number\n\tx: number\n\tz: number\n\t/** The type of what shot it, known even when the shooter is out of sight: what it looks like */\n\tkind: string\n\towner: PlayerId\n\tcrit: boolean\n\tdamageType: DamageType\n\t/** A look the rules gave it (see `Projectile.look`) */\n\tlook?: string\n\t/** Entity it was fired by, when that one is known to the player */\n\tsource?: number\n\t/** Entity it is after, when that one is known to the player */\n\ttarget?: number\n\t/** Where it was fired from and where it comes down, for shots that are lobbed at a spot */\n\tfrom?: Vec2\n\tto?: Vec2\n}\n\n/**\n * What an ability sent on its way, like a tornado\n *\n * @beta\n */\nexport interface MissileState {\n\tid: number\n\tability: string\n\tlevel: number\n\t/** Entity that sent it, when that one is known to the player */\n\tsource?: number\n\tx: number\n\tz: number\n\tradius: number\n\t/** The way it is heading, in radians */\n\theading: number\n\t/** How far it is with taking shape, 0..1, while it has not set off yet */\n\tforming?: number\n\t/** How much of its way it has come, 0..1, for the ones that go a known way */\n\tprogress?: number\n\t/** How high above the ground its arc carries it now, for what is thrown in one (`EffectFields.arc`) */\n\tarc?: number\n}\n\n/**\n * What the players are told happened during a tick, which cannot be read from the state afterwards: each kind by its\n * `type` (design review E7). The engine's are told by its replications (`replicateEvent(key, type, tell)`, typed by\n * this entry); a pack's or a game's own added by declaration merging, as `OrderStates` is. A screen's handlers are\n * keyed by the same names (`SessionEventOf`)\n *\n * @beta\n */\nexport interface SessionEvents {\n\t/**\n\t * Something died. What killed it (`killer`, `killerType`, `from`, where it stood) when the player sees it; how:\n\t * an attack of the killer's, the blow's damage type, the ability, how much too much, a critical strike, and what\n\t * the rules made of it (`how`, set in the `death` hook: `'exploded'`). For the screen to show it its way\n\t */\n\tdeath: {\n\t\ttype: 'death'\n\t\tid: number\n\t\tfrom?: Vec2\n\t\tkiller?: number\n\t\tkillerType?: string\n\t\tattack: boolean\n\t\tdamageType?: DamageType\n\t\tability?: string\n\t\toverkill?: number\n\t\tcrit?: boolean\n\t\thow?: string\n\t\t/** Why, when it was not of damage (`DeathReason`): `cancelled`, `expired`, a game's own word */\n\t\treason?: string\n\t\t/** The blow's words of the game's own (`DamageOptions.tags`) */\n\t\ttags?: string[]\n\t}\n\t/**\n\t * Cells of one of the game's layers (`Terrain.cells`) were set to `value` (`world.setCells`): the session's ground has\n\t * it already, for the screen to draw again. Told where the player's team sees the cells, and as they come into its sight\n\t * where it does not (`TeamMemory.cells`): an observer is told of all\n\t */\n\tcells: { type: 'cells'; layer: string; at: number[]; value: number }\n\t/**\n\t * A part of the ground was reshaped (`world.reshapeGround`, the editor's Play here): the session's ground has it\n\t * already, for the screen to draw again. Told to everyone\n\t */\n\tground: { type: 'ground'; patch: TerrainPatch }\n\t/**\n\t * Something the player does not see moved in a layer of cells where the player sees the ground (`ConcealmentOptions.rustle`):\n\t * where, and whether it stepped in. Not who: for the screen to shake the bushes there\n\t *\n\t * @beta\n\t */\n\trustle: { type: 'rustle'; layer: string; x: number; z: number; entered?: boolean }\n\t/** What the map looks like beyond its ground, as it is now (`world.setEnvironment`), and the seconds to ease into it over */\n\tenvironment: { type: 'environment'; environment: MapEnvironment; over?: number }\n\t/**\n\t * A definition changed while the game runs (`world.redefine`), a copy made with `copyOf`: a screen with a registry of\n\t * its own puts it in. Told to everyone\n\t */\n\tredefined: { type: 'redefined'; kind: DataKind; definition: string; values: DataValues }\n\t/** An attack started, at `target` when the player sees it */\n\t/** `weapon`: which of its attacks swings, by place (`UnitTypeDef.attacks`); the first when left out */\n\tattack: { type: 'attack'; id: number; target?: number; weapon?: number }\n\t/** Damage dealt to an entity the player sees: by whom when the player sees that too, with what, how much */\n\tdamage: {\n\t\ttype: 'damage'\n\t\tid: number\n\t\tamount: number\n\t\tdamageType: DamageType\n\t\tsource?: number\n\t\tsourceType?: string\n\t\tattack: boolean\n\t\tcrit: boolean\n\t\t/** The ability that dealt it, where the player sees the source (`source`) */\n\t\tability?: string\n\t\ttags?: string[]\n\t}\n\t/** Health given back to an entity the player sees */\n\theal: { type: 'heal'; id: number; amount: number; source?: number }\n\t/**\n\t * A buff put on an entity the player sees (`on`), put on again at another level (`renewed`), or taken off or run\n\t * out. Once as it begins and once as it ends: a renewal at the same level is not told\n\t */\n\tbuff: { type: 'buff'; id: number; buff: string; on: boolean; level?: number; renewed?: boolean; source?: number }\n\t/** A unit came out of `building`, where the player sees that too */\n\ttrained: { type: 'trained'; id: number; building?: number }\n\t/** A structure was put down to be built, to go up over `buildTime` seconds as builders work (`EntityState.construction`) */\n\tconstructionStarted: { type: 'constructionStarted'; id: number; buildTime: number }\n\t/** A structure was finished (or put down whole, `UnitTypeDef.construction: 'instant'`) */\n\tbuilt: { type: 'built'; id: number }\n\t/** A construction was called off by its owner: it dies next, its death's reason `cancelled` */\n\tconstructionCancelled: { type: 'constructionCancelled'; id: number }\n\t/** A building started to turn into another type (`to`) over `time` seconds (`EntityState.upgrade`) */\n\tupgradeStarted: { type: 'upgradeStarted'; id: number; to: string; time: number }\n\t/** That was called off */\n\tupgradeCancelled: { type: 'upgradeCancelled'; id: number; to: string }\n\t/** An entity became another type (`from`: what it was): an upgrade done, a morph */\n\tmorphed: { type: 'morphed'; id: number; from: string }\n\t/** A hero was brought back */\n\trevived: { type: 'revived'; id: number }\n\t/** An entity picked an item up */\n\tpicked: { type: 'picked'; id: number; item: string }\n\t/** Research of the player or an ally finished */\n\tresearched: { type: 'researched'; upgrade: string; level: number; building: number }\n\t/** A shot arrived: at its target when it had one, missing (`miss`), or struck critically */\n\tshot: { type: 'shot'; id: number; x: number; z: number; target?: number; miss: boolean; crit: boolean }\n\t/** A channelled ability started to be kept up (`on`, for `duration` seconds), or ended: done, or `interrupted` */\n\tchannel: { type: 'channel'; id: number; ability: string; on: boolean; duration?: number; interrupted?: boolean }\n\t/** What an ability sent on its way struck an entity */\n\tmissileHit: { type: 'missileHit'; missile: number; target: number }\n\t/** A critical strike landed on the entity */\n\tcrit: { type: 'crit'; id: number; amount: number }\n\t/** An attack up a cliff went wide, at this spot */\n\tmiss: { type: 'miss'; x: number; z: number }\n\t/** A shot that hits an area came down */\n\timpact: { type: 'impact'; x: number; z: number; radius: number }\n\t/** A worker struck what it is mending */\n\twork: { type: 'work'; id: number }\n\t/** A worker struck what it is gathering from */\n\tchop: { type: 'chop'; id: number; target: number }\n\t/** An ability went off. `radius` is there for the ones that hit an area */\n\tlevelUp: { type: 'levelUp'; id: number; level: number }\n\t/** Experience a hero of the player's or an ally's earned, and the level it is at after it */\n\txp: { type: 'xp'; id: number; amount: number; level: number }\n\t/**\n\t * Mana of a unit of the player's or an ally's spent on a cast (`amount` below 0, `ability` the one cast) or given by\n\t * an effect (above 0). Not regeneration\n\t */\n\tmana: { type: 'mana'; id: number; amount: number; ability?: string }\n\t/** A pool of the game's own on a unit of the player's or an ally's changed (`resourceChanged`) */\n\tresource: { type: 'resource'; id: number; kind: string; amount: number; reason?: string }\n\t/** Gold for a kill */\n\tbounty: { type: 'bounty'; x: number; z: number; amount: number }\n\t/** Someone started to cast. `duration` is how long until it goes off */\n\twindup: { type: 'windup'; id: number; ability: string; level: number; x: number; z: number; duration: number }\n\t/** `id`: the caster, where the player sees it (not where only the spot is seen). `charged`: it went off charged, see `charge` on the ability */\n\tcast: { type: 'cast'; id?: number; ability: string; level: number; x: number; z: number; target?: number; radius?: number; charged?: boolean }\n\t/** What an ability set off arrived somewhere: a missile hit, a rush ended, the time was up. `id`: the caster, where the player sees it */\n\tstrike: { type: 'strike'; id?: number; ability: string; level: number; x: number; z: number; target?: number; radius?: number; impact?: string }\n\t/** Something to tell the player. The client finds the words for it, see `Message` */\n\tmessage: { type: 'message'; message: Message; kind: MessageKind; seconds?: number }\n\t/** A command the player sent (`seq`, what `send` gave) was carried out: refused, with why, or not */\n\tcommand: { type: 'command'; seq: number; refusal?: Message }\n\t/** An objective of the player was given (`was` undefined), got further along, or was done or failed */\n\tobjective: { type: 'objective'; objective: ObjectiveState; was?: ObjectiveStatus }\n\t/** Someone says a line to the player: who, what, and for how long (see `world.dialog`) */\n\tline: { type: 'line'; line: SaidLine }\n\t/** The line was skipped: it ends now */\n\tlineEnded: { type: 'lineEnded'; id: number }\n\t/** One of the view's cinematics plays (see `playCinematic`) */\n\tcinematic: { type: 'cinematic'; cinematic: string; hold: boolean; skippable: boolean; params?: Record<string, unknown> }\n\t/** The rules cue the cinematic playing (see `cueCinematic`) */\n\tcinematicCue: { type: 'cinematicCue'; cue: string; params?: Record<string, unknown> }\n\t/**\n\t * One of the view's effects plays, as the rules said (`world.effect`): `id` is the rules' handle on it, `fx` its name,\n\t * at a place (`x`, `y`, `z`) or on an entity (`on`, at a `point`), its knobs, the seed of its random parts\n\t */\n\tfx: {\n\t\ttype: 'fx'\n\t\tid: number\n\t\tfx: string\n\t\tx?: number\n\t\ty?: number\n\t\tz?: number\n\t\ton?: number\n\t\tpoint?: string\n\t\tparams?: Record<string, unknown>\n\t\tseed: number\n\t\toverFog?: boolean\n\t}\n\t/** An effect the rules played stops (`world.stopEffect`) */\n\tfxStop: { type: 'fxStop'; id: number; fade?: number }\n\t/** A player of the side marked a spot of the map, or any player for everyone (`to`, see `ping`) */\n\t/** `by`: the name of who watches, for one of theirs (`to: 'observers'`) */\n\tping: { type: 'ping'; player: PlayerId; x: number; z: number; kind: PingKind; to: ChatAudience; by?: string }\n\t/** A line of chat for the player: of their side, or to everyone (see `chat`) */\n\t/** `by`: the name of who watches, for a line of theirs (`to: 'observers'`) */\n\tchat: { type: 'chat'; player: PlayerId; text: string; to: ChatAudience; by?: string }\n\t/** An event of the game's own that goes to the screen (see `defineEvent`): its id, and what it says */\n\tgame: { type: 'game'; event: string; payload: unknown }\n}\n\n/**\n * Things that happened during a tick and cannot be read from the state afterwards: one of `SessionEvents`\n *\n * @beta\n */\nexport type SessionEvent = SessionEvents[keyof SessionEvents]\n\n/**\n * How the game stands for the player\n *\n * @beta\n */\nexport type Outcome = 'playing' | 'victory' | 'defeat'\n\n/**\n * Everything one player knows about the game at the end of a tick\n *\n * @beta\n */\nexport interface Snapshot {\n\ttick: number\n\t/**\n\t * The switches of the debug tools as they stand, for a player who may use them (`world.debugPlayers`): `explored`,\n\t * the whole map explored (`debug.explore`)\n\t */\n\tdebug?: { noCooldowns: boolean; noManaCosts: boolean; invulnerable: boolean; speed: number; explored?: boolean }\n\t/** Hour of the day, 0..24, in a game with days and nights */\n\thour?: number\n\toutcome: Outcome\n\tentities: EntityState[]\n\tplayers: PlayerState[]\n\tprojectiles: ProjectileState[]\n\tmissiles: MissileState[]\n\t/** Items on the ground, where the player can see the ground */\n\titems: GroundItemState[]\n\t/** Spots someone sees for a while. Everyone can tell, not only whoever it is */\n\treveals: RevealState[]\n\t/** Corpses where the player can see the ground, by the id of who died there (see `raiseDead`). None when left out */\n\tcorpses?: CorpseState[]\n\tevents: SessionEvent[]\n\t/** What the game tells the player about itself, see `GameModule.report` */\n\treport?: Record<string, unknown>\n\t/**\n\t * The score of the players the player is told of (`GameRules.score`: `live`, then `end`), told again at most once\n\t * in `refresh` seconds. None in a game that counts nothing\n\t *\n\t * @beta\n\t */\n\tscore?: ScoreState\n\t/**\n\t * The score's timeline, of the same players: told again at each point of it (`ScoreRules.every`)\n\t *\n\t * @beta\n\t */\n\tscoreLine?: ScoreLineState\n}\n\n/**\n * A corpse as the player sees it: the id the unit had, of what type, where\n *\n * @beta\n */\nexport interface CorpseState {\n\tid: number\n\ttype: string\n\tx: number\n\tz: number\n}\n\n/** @beta */\nexport interface RevealState {\n\tid: number\n\tx: number\n\tz: number\n\tradius: number\n\t/** Seconds it goes on */\n\tleft: number\n\t/** The player's team is the one that sees it */\n\tours: boolean\n}\n\n/** A creep camp. Where they are is part of the map, which everyone knows */\n/**\n * A deposit of the game's money, as the map shows it (`GameSession.mines`)\n *\n * @beta\n */\nexport interface MineInfo {\n\tid: number\n\tx: number\n\tz: number\n}\n\n/** @beta */\nexport interface CampInfo {\n\tid: number\n\tx: number\n\tz: number\n\t/** Levels of its creeps added up */\n\tlevel: number\n\t/** Whether the player has seen that the camp is empty */\n\tcleared: boolean\n}\n\n/**\n * What the player's team sees of the map. The arrays are per cell, row by row\n *\n * @beta\n */\nexport interface FogState {\n\twidth: number\n\tdepth: number\n\t/** Changes whenever the arrays did */\n\tversion: number\n\t/** The whole map is lit, a debug switch */\n\trevealed: boolean\n\tvisible: Uint8Array\n\texplored: Uint8Array\n}\n\ntype WithoutPlayer<T> = T extends unknown ? Omit<T, 'player'> : never\n\n/**\n * A command as the client writes it. Who it comes from is decided by the session, never by the sender\n *\n * @beta\n */\nexport type PlayerCommand = WithoutPlayer<Command> | ModCommand\n\n/**\n * Whether a command is one of the engine's of a kind, narrowed to its shape (`isCommand(sent, 'order')`: its units and\n * its order): what reads a command it did not write, a game's own (`ModCommand`) passed over\n *\n * @beta\n */\nexport function isCommand<K extends Command['type']>(command: PlayerCommand, type: K): command is Extract<WithoutPlayer<Command>, { type: K }> {\n\treturn command.type === type\n}\n\n/**\n * What the debug tools of a client see of the simulation: an entity as the rules have it, and the events and hooks of\n * the last seconds. Plain data, as the snapshots are, so that it works the same with a simulation somewhere else: the\n * client says what it wants to follow, and reads what came back last\n *\n * @beta\n */\nexport interface SessionDebug {\n\t/** Follows an entity, a player or the world, or nothing. Its inspection comes back from then on */\n\tinspect(target: InspectTarget | null): void\n\t/** What is followed, as it stood when last heard of. Null when nothing is followed, or it is gone */\n\treadonly inspection: Inspection | null\n\t/** Changes a number, or a switch (a boolean), of what is followed, where its inspection shows it (`InspectedSection.path` and the key) */\n\tset(path: (string | number)[], value: number | boolean): void\n\t/** Whether the list of everything in the world comes back. Off until asked for: the world can be big */\n\tlisting: boolean\n\t/** Every player and entity of the world, out of sight, hidden and scenery too, as when last heard of. Null while not listing */\n\treadonly world: WorldListing | null\n\t/** Whether the events and hooks are logged. Off until asked for: logging costs a little */\n\tlogging: boolean\n\t/** The events and hooks of the last seconds, oldest first */\n\tlog(): readonly LoggedEvent[]\n\t/** Forgets what was logged so far */\n\tclearLog(): void\n}\n\n/**\n * What a session can do besides being a seat, each where it can (`GameSession.can`): a game played in this page holds\n * its pace and saves, a game in a worker of it says its timing too, a seat a computer plays from serves its brain. Asked\n * for as `session.can.pace?.advance()`: there or not\n *\n * @beta\n */\nexport interface SessionCan {\n\t/** The pace, where it is this player's to set: a game played in this page, in its thread or in a worker of it */\n\treadonly pace?: SessionPace\n\t/** Saves of the world as it stands, and the last checkpoint: a game played in this page */\n\treadonly saves?: SessionSaves\n\t/** The debug tools' view of the simulation, where the session allows it */\n\treadonly inspect?: SessionDebug\n\t/** Where the time of a simulation run elsewhere in this page went of late: a worker (S54) */\n\treadonly timing?: SessionTiming\n\t/** What a computer player's brain reads besides the snapshot: a seat in the simulation's own thread */\n\treadonly computer?: SessionComputer\n}\n\n/**\n * The pace a session holds the game at (`SessionCan.pace`)\n *\n * @beta\n */\nexport interface SessionPace {\n\t/** 1 as it goes, 0 held (a pause menu, a cinematic that has the game wait) */\n\tspeed: number\n\t/** Moves a held game on by `ticks` (one when left out): a step */\n\tadvance(ticks?: number): void\n}\n\n/**\n * Saves of the world a session plays (`SessionCan.saves`)\n *\n * @beta\n */\nexport interface SessionSaves {\n\t/** A save of the world as it stands: at once in this thread, a message there and back in a worker */\n\tsave(): Promise<WorldSave>\n\t/**\n\t * The last moment the rules marked to start again from (`world.checkpoint`), with what it is called, and a save of\n\t * the world as it stood: a scene can load it for \"Retry from wave 6\"\n\t */\n\treadonly checkpoint?: { label: Message; save: WorldSave }\n}\n\n/**\n * Where the time of a simulation run elsewhere went of late (`SessionCan.timing`)\n *\n * @beta\n */\nexport interface SessionTiming {\n\t/**\n\t * Milliseconds a tick took, evened out, the longest, what sending the page what changed took, what the page took to\n\t * take it in, and each system's share (`world.scheduler.timing()`) while they are measured (`profile`)\n\t */\n\ttiming(): { tick: number; tickMax: number; send: number; receive?: number; systems?: SystemTiming[] } | undefined\n\t/** Measures the simulation's systems, or stops (it costs a little): what the stats window asks while it is open */\n\tprofile?(on: boolean): void\n}\n\n/**\n * What a computer player's seat gives its brain besides the snapshot (`SessionCan.computer`)\n *\n * @beta\n */\nexport interface SessionComputer {\n\t/**\n\t * Where the game's money is mined (a resource of `Registry.currency`: gold mines), as a player knows from the map,\n\t * under the fog too: what a computer player looks to for another hall\n\t */\n\tmines(): readonly MineInfo[]\n\t/** The lanes of the map (`lanesOf`), as everyone knows them from the map: what a computer player of lanes walks with its waves */\n\tlanes(): readonly Lane[]\n\t/**\n\t * What happened since the last snapshot, not yet given in one: a copy. The brain's save keeps what it heard since it\n\t * last thought (`restoreEvents`), so that a game loaded from the save hears it too\n\t */\n\tpendingEvents(): SessionEvent[]\n\t/** Takes back what `pendingEvents` gave, ahead of what has happened since: in a game loaded from a save */\n\trestoreEvents(events: readonly SessionEvent[]): void\n}\n\n/**\n * A seat in a game: the only thing a client needs to play\n *\n * @beta\n */\nexport interface GameSession {\n\treadonly playerId: PlayerId\n\treadonly team: number\n\t/** The map and the game data are the same for everyone and known up front */\n\treadonly terrain: Terrain\n\t/**\n\t * What the map looks like beyond its ground, for the screen: its water, sky, weather. Nothing when it does not say.\n\t * As it was when the session began: what the rules change after comes as `environment` events\n\t */\n\treadonly environment?: MapEnvironment\n\t/** The scenery of the map, for the screen: none when it has none (see `MapDoodad`) */\n\treadonly doodads: readonly MapDoodad[]\n\t/** The regions of the map, for the screen: what mist in places lies over by name (see `MapRegion`, `AreaRef`) */\n\treadonly regions: readonly MapRegion[]\n\t/** The views of the map saved under names, for cinematics and a player's first view (see `MapCamera`) */\n\treadonly cameras: readonly MapCamera[]\n\t/** The paths of the map (a road), for the screen: a cinematic's camera on a rail along one (see `MapPath`) */\n\treadonly paths: readonly MapPath[]\n\treadonly registry: Registry\n\treadonly tickRate: number\n\t/**\n\t * What the game says about what it does (`World.log`), where the session has it: a game played in the page. A\n\t * server's game says it on the server, and a player is not given it\n\t */\n\treadonly log?: Logger\n\t/**\n\t * Why the game ended on an error in its rules, once it has (`World.failure`): what the player is told. A game that\n\t * failed does not go on; a client says so, and offers what there is to offer\n\t */\n\treadonly failure?: { message: string } | null\n\t/** How far the current frame is between the last two snapshots, 0..1 */\n\treadonly alpha: number\n\n\t/** State to start from */\n\tsnapshot(): Snapshot\n\t/** Lets time pass. Returns the snapshots that came in since the last call, oldest first */\n\tupdate(dt: number): Snapshot[]\n\t/** Sends a command, to be carried out at the next tick. What it gives is told back with how it went (a `command` event) */\n\tsend(command: PlayerCommand): number\n\tfog(): FogState\n\tcamps(): readonly CampInfo[]\n\n\t/** Whether the player could build this here, as far as they can tell */\n\tcanPlace(unitType: string, point: Vec2): boolean\n\t/**\n\t * Which cells of the ground a building would cover there are in the way, as far as the player can tell, row by row\n\t * from its corner (`placementCells`): what a preview draws cell by cell. None for one built on a resource, or where\n\t * the session does not say @beta\n\t */\n\tplaceCells?(unitType: string, point: Vec2): readonly boolean[] | undefined\n\t/** Route a unit would take, over the ground the player knows */\n\tfindPath(from: Vec2, to: Vec2, flying?: boolean): Vec2[] | null\n\n\t/**\n\t * What this kind of session can do besides being a seat (`SessionCan`): hold the pace, save, show the debug tools,\n\t * tell its timing, serve a computer player. A seat over a wire can none of it; a game in this page most of it\n\t */\n\treadonly can: SessionCan\n\n\t/** Whether the player only watches, and sees everything (every player's resources among it): see `LocalSession.observer` */\n\treadonly observer?: boolean\n\t/** Milliseconds a message takes to the simulation and back, where it runs elsewhere. Nothing in the page */\n\treadonly ping?: number\n\n\tdispose(): void\n}\n\n/**\n * The version of what goes over the wire between a host and its players: the messages here and in `session/remote.ts`,\n * and how deltas are made (`session/delta.ts`). The host says it in its welcome and a player says it when joining a\n * server; a player of another version is refused with a reason, not left to fail somewhere strange. Raised by one on\n * any change of their shape, which a game's own data (`Registry.dataHash`) does not show\n *\n * @beta\n */\nexport const PROTOCOL_VERSION = 13\n\n/**\n * What a player is told when the host's version of the wire is not its own (`PROTOCOL_VERSION`)\n *\n * @internal\n */\nexport function protocolMismatch(host: unknown, player: number = PROTOCOL_VERSION): string {\n\treturn `The host runs another version of the engine (protocol ${typeof host === 'number' ? host : 'unknown'}, this player's is ${player}): update the game`\n}\n\n/**\n * Reads a message that came over a wire: an object with a `type` that is a string, or nothing. What is not JSON, or is\n * JSON of another shape (`null`, a number, a list), is nothing, so that a peer that sends anything at all makes whoever\n * reads it drop the message, not fall over. The other fields are still the sender's word: check each before it is used\n *\n * @internal\n */\nexport function readMessage(text: string): ({ type: string } & Record<string, unknown>) | undefined {\n\tlet message: unknown\n\ttry {\n\t\tmessage = JSON.parse(text)\n\t} catch {\n\t\treturn undefined\n\t}\n\tif (typeof message !== 'object' || message === null || Array.isArray(message)) return undefined\n\tconst { type } = message as { type?: unknown }\n\treturn typeof type === 'string' ? (message as { type: string } & Record<string, unknown>) : undefined\n}\n\n/**\n * A number that is a number: not `NaN`, not infinite, not a string of digits\n *\n * @internal\n */\nexport const isFiniteNumber = (value: unknown): value is number => typeof value === 'number' && Number.isFinite(value)\n\n/**\n * A game of a server, as its list says it (`GET /games`): its room (what to connect to, `ws://host:port/<room>`; none for\n * a server of one game), the game and mode, where it is at, its seats taken and free, who watches, and its settings\n * (the map, among them, where the mode offers one)\n *\n * @beta\n */\nexport interface GameListing {\n\troom: string\n\tgame: string\n\tmode: string\n\tphase: 'lobby' | 'game' | 'ended'\n\t/** Seats players hold, seats nobody holds a player could, seats the computer plays */\n\tplayers: number\n\tfree: number\n\tcomputer: number\n\twatchers: number\n\tsettings: Record<string, string>\n\t/** Whether it takes no new games: stopping */\n\tdraining: boolean\n\t/** How its players are rated, on average, where the server keeps ratings (`Ratings`) */\n\trating?: number\n}\n\n/**\n * A kind of game a server lets players make a room of, as its list says it (`GET /games`'s `kinds`): what to ask\n * `POST /games` for (`{ kind: id, settings }`), what it is called, and the settings it offers (a map, among them)\n *\n * @beta\n */\nexport interface GameKindListing {\n\tid: string\n\tname: string\n\t/** Where to wait to be matched with others for it (`ws://host:port/<queue>`), and how many wait now, of how many it takes. None without matchmaking */\n\tqueue?: string\n\twaiting?: number\n\tneeded?: number\n\tsettings: Record<string, { label: string; options: string[]; default: string }>\n}\n","/**\n * What a session can do besides being a seat (`SessionCan`), made of its own members: what a game played in this page\n * gives, in its thread (`LocalSession`) or in a worker (`WorkerSession`)\n */\nimport type { WorldSave } from '#engine/save'\nimport type { Message } from '#engine/messages'\nimport type { SessionPace, SessionSaves } from './protocol'\n\n/** A session's pace, as `SessionCan.pace`: its own `speed` and `advance` */\nexport function paceOf(session: { speed: number; advance(ticks?: number): void }): SessionPace {\n\treturn {\n\t\tget speed() {\n\t\t\treturn session.speed\n\t\t},\n\t\tset speed(speed: number) {\n\t\t\tsession.speed = speed\n\t\t},\n\t\tadvance: (ticks) => session.advance(ticks)\n\t}\n}\n\n/** A session's saves, as `SessionCan.saves`: its own `save` and `checkpoint` */\nexport function savesOf(session: { save(): Promise<WorldSave>; readonly checkpoint?: { label: Message; save: WorldSave } }): SessionSaves {\n\treturn {\n\t\tsave: () => session.save(),\n\t\tget checkpoint() {\n\t\t\treturn session.checkpoint\n\t\t}\n\t}\n}\n","import type { Registry } from '#engine/registry'\nimport type { CampInfo, EntityState, OwnEntityState, SessionEvent, Snapshot } from './protocol'\n\n/*\n * Snapshots as changes. The host keeps what it sent a player at each tick, and sends the next one as what changed since\n * the last one the player has said it got (`base`): entities that came, the fields of those that changed, entities\n * that went, and the other parts when they differ. The player rebuilds the whole snapshot from the one at `base`,\n * keeping the very objects of what did not change: the screen tells what changed by them, and goes no further for\n * the rest. Numbers are rounded first (`quantize`), so that what moves by nothing worth drawing is not a change\n */\n\n/**\n * The fog of a team, as runs of the same value: 0s first, then 1s, then 0s... Few runs for a map of open fields\n *\n * @beta\n */\nexport interface FogMessage {\n\trevealed: boolean\n\tvisible: number[]\n\texplored: number[]\n}\n\n/**\n * What a player knows at a tick: the snapshot (without its events, which go their own way), the fog, the camps, the team\n *\n * @beta\n */\nexport interface Frame {\n\tsnapshot: Snapshot\n\tfog: FogMessage\n\tcamps: CampInfo[]\n\tteam: number\n}\n\n/** The parts of a frame besides its entities, sent when they differ from the base's */\ntype Rest = Omit<Snapshot, 'tick' | 'entities' | 'events'> & { fog: FogMessage; camps: CampInfo[]; team: number }\n\n/**\n * A list or an object sent as the parts of it that changed (`$patch`): by index for a list as long as the one before,\n * by key for an object, each part whole or a patch of its own, and the keys of an object that are gone (`$unset`).\n * What a cooldown of one ability of four, or the gold of one player, sends in place of all of them\n *\n * @beta\n */\nexport interface WirePatch {\n\t/** The parts that changed, by index or key: each the part whole, or a patch of its own */\n\t$patch: Record<string, unknown>\n\t/** The keys of an object that are gone */\n\t$unset?: string[]\n}\n\n/**\n * An entity that changed, as a list rather than an object (what goes over the wire for each one adds up): its id, the\n * fields that are new, those that are gone, and of what only its owner is told (`own`), the same, and its fields that\n * changed in part, as what changed in them (`WirePatch`: one ability's cooldown). Trailing parts that say nothing are\n * left off, the others `0`\n *\n * @beta\n */\nexport type EntityChange = [\n\tid: number,\n\tset: Partial<EntityState>,\n\tunset?: (keyof EntityState)[] | 0,\n\townSet?: Partial<OwnEntityState> | 0,\n\townUnset?: (keyof OwnEntityState)[] | 0,\n\townPatch?: Partial<Record<keyof OwnEntityState, WirePatch>>\n]\n\n/**\n * A frame as what changed since another (`base`, a tick the player has), or all of it (`base: null`)\n *\n * @beta\n */\nexport interface Delta {\n\ttick: number\n\tbase: number | null\n\tadded: EntityState[]\n\tchanged: EntityChange[]\n\tremoved: number[]\n\trest: Partial<Rest>\n\t/** The other parts that changed in part, as what changed in them (`WirePatch`: the gold of one player of four) */\n\trestPatch?: Partial<Record<keyof Rest, WirePatch>>\n\t/**\n\t * The batches of events the player has not said it got, each by its own number (`n`) and the tick it went out with:\n\t * sent again until it does, applied once. Talk between two ticks is a batch of its own (RV14)\n\t */\n\tevents: { tick: number; n: number; events: SessionEvent[] }[]\n}\n\n/** Rounded to `step` */\nconst round = (value: number, step: number) => Math.round(value / step) * step\n\n/**\n * Seconds rounded up to whole ones, a hair over one (what floating point leaves over) not counted: what a plate\n * sweeps changes once a second on the wire, not every round (the plate counts down between)\n */\nconst secondsUp = (value: number) => Math.ceil(value - 1e-6)\n\n/** Positions on the wire, in 256ths of a unit, and the facing in 256ths of a turn: whole numbers, short to write */\nconst POSITION = 256\nconst TURN = 256 / (Math.PI * 2)\n\n/** An entity's numbers as they go over the wire: whole numbers where they can be. `decode` takes them back */\nfunction encode<T extends Partial<EntityState>>(state: T): T {\n\tconst out = { ...state }\n\tif (out.x !== undefined) out.x = Math.round(out.x * POSITION)\n\tif (out.z !== undefined) out.z = Math.round(out.z * POSITION)\n\tif (out.facing !== undefined) out.facing = ((Math.round(out.facing * TURN) % 256) + 256) % 256\n\treturn out\n}\n\nfunction decode<T extends Partial<EntityState>>(state: T): T {\n\tconst out = { ...state }\n\tif (out.x !== undefined) out.x /= POSITION\n\tif (out.z !== undefined) out.z /= POSITION\n\tif (out.facing !== undefined) out.facing /= TURN\n\treturn out\n}\n\n/**\n * An entity's state with its numbers rounded for the wire: positions to 1/256 of a unit (16 bits over a map of 256),\n * the facing to a 256th of a turn, health and shield up to whole points (what is alive keeps at least one), mana down\n * (an ability is never shown ready that the simulation would refuse), what is under way to hundredths, the seconds\n * left of buffs and of shared cooldowns up to whole seconds\n *\n * @beta\n */\nexport function quantize(state: EntityState): EntityState {\n\t// what the wire's whole numbers come back as (`encode`, then `decode`), in one copy: the host diffs what the player\n\t// will have, for every entity in sight of every seat each round\n\tconst out: EntityState = { ...state }\n\tout.x = Math.round(state.x * POSITION) / POSITION\n\tout.z = Math.round(state.z * POSITION) / POSITION\n\tout.facing = (((Math.round(state.facing * TURN) % 256) + 256) % 256) / TURN\n\tout.hp = Math.ceil(state.hp)\n\tif (state.shield !== undefined) out.shield = Math.ceil(state.shield)\n\tif (state.mana !== undefined) out.mana = Math.floor(state.mana)\n\t// what the rules share for the plates (indicators-plan U3): whole seconds, rounded up (what is about to end is not\n\t// shown ended). To a tenth, a buff on each of 1,000 footmen doubled what each seat is sent (395 KB/s to 846)\n\tif (state.buffTimes) out.buffTimes = state.buffTimes.map((left) => (left < 0 ? left : secondsUp(left)))\n\tif (state.abilities?.some((ability) => ability.cooldown))\n\t\tout.abilities = state.abilities.map((ability) => (ability.cooldown ? { ...ability, cooldown: secondsUp(ability.cooldown) } : ability))\n\tif (state.lifetime) out.lifetime = { left: round(state.lifetime.left, 0.1), total: state.lifetime.total }\n\treturn out\n}\n\n/**\n * Whether two values of a field are the same: the very same, or equal as data. Two flat objects (an entity's `stats`, a\n * `lifetime`, a `leap`'s points) are compared field by field; what nests deeper as text\n */\nfunction same(a: unknown, b: unknown): boolean {\n\tif (a === b) return true\n\tif (typeof a !== 'object' || typeof b !== 'object' || a === null || b === null) return false\n\tif (Array.isArray(a) || Array.isArray(b)) {\n\t\tif (!Array.isArray(a) || !Array.isArray(b) || a.length !== b.length) return false\n\t\tfor (let i = 0; i < a.length; i++) if (!same(a[i], b[i])) return false\n\t\treturn true\n\t}\n\tconst left = a as Record<string, unknown>\n\tconst right = b as Record<string, unknown>\n\tfor (const key in left) {\n\t\tif (!(key in right)) return false\n\t\tconst x = left[key]\n\t\tconst y = right[key]\n\t\tif (x === y) continue\n\t\tif (typeof x !== 'object' || typeof y !== 'object' || x === null || y === null) return false\n\t\tif (!same(x, y)) return false\n\t}\n\tfor (const key in right) if (!(key in left)) return false\n\treturn true\n}\n\n/** How deep a patch goes into lists and objects: past it, what changed is sent whole */\nconst PATCH_DEPTH = 4\n\nconst isObject = (value: unknown): value is object => typeof value === 'object' && value !== null\n\n/**\n * What to send of a value that changed (`same` said so) to whoever has `before`: the parts of a list or an object\n * that changed (`WirePatch`), or `after` whole where every part did, or where it is not the same kind of thing\n */\nfunction patchOf(before: unknown, after: unknown, depth = PATCH_DEPTH): unknown {\n\tif (depth === 0 || !isObject(before) || !isObject(after) || Array.isArray(before) !== Array.isArray(after)) return after\n\tconst parts: Record<string, unknown> = {}\n\tlet changed = 0\n\tif (Array.isArray(before)) {\n\t\tconst list = after as unknown[]\n\t\tif (list.length !== before.length) return after\n\t\tfor (let i = 0; i < list.length; i++) {\n\t\t\tif (same(before[i], list[i])) continue\n\t\t\tparts[i] = patchOf(before[i], list[i], depth - 1)\n\t\t\tchanged++\n\t\t}\n\t\treturn changed === list.length ? after : { $patch: parts }\n\t}\n\tconst left = before as Record<string, unknown>\n\tconst right = after as Record<string, unknown>\n\tlet fields = 0\n\tlet unset: string[] | undefined\n\tfor (const key in right) {\n\t\tif (right[key] === undefined) continue\n\t\tfields++\n\t\tif (same(left[key], right[key])) continue\n\t\tparts[key] = patchOf(left[key], right[key], depth - 1)\n\t\tchanged++\n\t}\n\tfor (const key in left) if (left[key] !== undefined && right[key] === undefined) (unset ??= []).push(key)\n\tif (changed === fields && !unset) return after\n\treturn unset ? { $patch: parts, $unset: unset } : { $patch: parts }\n}\n\nconst isPatch = (value: unknown): value is WirePatch => isObject(value) && !Array.isArray(value) && '$patch' in value\n\n/** A value a patch was made against, with the patch put in: new lists and objects where it says, the very parts it does not */\nfunction patched(base: unknown, patch: WirePatch): unknown {\n\tconst made = (Array.isArray(base) ? [...base] : { ...(base as Record<string, unknown>) }) as Record<string, unknown>\n\tfor (const [key, part] of Object.entries(patch.$patch)) made[key] = isPatch(part) ? patched((base as Record<string, unknown>)[key], part) : part\n\tfor (const key of patch.$unset ?? []) delete made[key]\n\treturn made\n}\n\n/** Whether two entities' components say the same: each as it knows how (`Component.same`), or as text */\nfunction sameComponents(registry: Registry | undefined, a: Record<string, unknown> | undefined, b: Record<string, unknown> | undefined): boolean {\n\tif (a === b) return true\n\tif (!a || !b) return false\n\tfor (const id in a) if (!(id in b)) return false\n\tfor (const id in b) {\n\t\tif (!(id in a)) return false\n\t\tconst compare = registry?.component(id)?.same\n\t\tif (compare ? !compare(a[id], b[id]) : !same(a[id], b[id])) return false\n\t}\n\treturn true\n}\n\n/**\n * The fields of an object that changed, and those that are gone, or nothing when none did. A field named in `skip` is\n * left to the caller (an entity's `own` part goes field by field on its own)\n */\nfunction fieldsOf<T extends object>(\n\tregistry: Registry | undefined,\n\tbefore: T,\n\tafter: T,\n\tskip?: keyof T\n): { set: Partial<T>; unset?: (keyof T)[] } | undefined {\n\tlet set: Partial<T> | undefined\n\tlet unset: (keyof T)[] | undefined\n\tfor (const key in after) {\n\t\tif (key === skip || after[key] === undefined) continue\n\t\tconst changed =\n\t\t\t(key as string) === 'components'\n\t\t\t\t? !sameComponents(registry, before[key] as Record<string, unknown> | undefined, after[key] as Record<string, unknown> | undefined)\n\t\t\t\t: !same(before[key], after[key])\n\t\tif (changed) (set ??= {} as Partial<T>)[key] = after[key]\n\t}\n\tfor (const key in before) if (key !== skip && before[key] !== undefined && after[key] === undefined) (unset ??= []).push(key)\n\treturn set || unset ? { set: set ?? {}, ...(unset ? { unset } : {}) } : undefined\n}\n\n/** What changed of an entity, or nothing when nothing did. What only its owner is told goes field by field too */\nfunction changeOf(registry: Registry | undefined, before: EntityState, after: EntityState): EntityChange | undefined {\n\tconst ownBefore = before.own\n\tconst ownAfter = after.own\n\tconst fields = fieldsOf<EntityState>(registry, before, after, 'own')\n\tlet own: { set: Partial<OwnEntityState>; unset?: (keyof OwnEntityState)[] } | undefined\n\tlet ownPatch: Partial<Record<keyof OwnEntityState, WirePatch>> | undefined\n\tlet unsetOwn = false\n\tif (ownBefore && ownAfter) {\n\t\town = fieldsOf(registry, ownBefore, ownAfter)\n\t\t// a list or an object that changed in part (one ability's cooldown of four) goes as what changed in it\n\t\tif (own)\n\t\t\tfor (const key in own.set) {\n\t\t\t\tconst field = key as keyof OwnEntityState\n\t\t\t\tif (!isObject(ownBefore[field])) continue\n\t\t\t\tconst patch = patchOf(ownBefore[field], own.set[field])\n\t\t\t\tif (!isPatch(patch)) continue\n\t\t\t\t;(ownPatch ??= {})[field] = patch\n\t\t\t\tdelete own.set[field]\n\t\t\t}\n\t} else if (ownAfter) own = { set: ownAfter }\n\telse if (ownBefore) unsetOwn = true\n\tif (!fields && !own && !unsetOwn) return undefined\n\tconst unset = [...((fields?.unset ?? []) as (keyof EntityState)[]), ...(unsetOwn ? (['own'] as const) : [])]\n\t// (the set is this call's own object: its numbers are made the wire's in place)\n\tconst set = fields?.set ?? {}\n\tif (set.x !== undefined) set.x = Math.round(set.x * POSITION)\n\tif (set.z !== undefined) set.z = Math.round(set.z * POSITION)\n\tif (set.facing !== undefined) set.facing = ((Math.round(set.facing * TURN) % 256) + 256) % 256\n\tconst change: EntityChange = [after.id, set]\n\tif (unset.length || own) change.push(unset.length ? unset : 0)\n\tif (own) {\n\t\tchange.push(Object.keys(own.set).length || !ownPatch ? own.set : 0)\n\t\tif (own.unset || ownPatch) change.push(own.unset ?? 0)\n\t\tif (ownPatch) change.push(ownPatch)\n\t}\n\treturn change\n}\n\n/**\n * Every part of a frame besides its tick, its entities and its events: the snapshot's parts, the engine's and a pack's\n * (`SnapshotPart`), and the fog, the camps and the team\n */\nconst restOf = (frame: Frame): Rest => {\n\tconst { snapshot, fog, camps, team } = frame\n\tconst { tick: _tick, entities: _entities, events: _events, ...parts } = snapshot\n\treturn { ...parts, fog, camps, team }\n}\n\n/** A frame's entities by id, worked out once: a base is diffed against round after round while the player's answer is on its way */\nconst BY_ID = new WeakMap<Frame, Map<number, EntityState>>()\nfunction entitiesById(frame: Frame): Map<number, EntityState> {\n\tlet byId = BY_ID.get(frame)\n\tif (!byId) {\n\t\tbyId = new Map()\n\t\tfor (const entity of frame.snapshot.entities) byId.set(entity.id, entity)\n\t\tBY_ID.set(frame, byId)\n\t}\n\treturn byId\n}\n\n/** What changed of the entities between two lists, worked out once for the two (the seats of a side share their lists) */\ntype EntitiesDiff = Pick<Delta, 'added' | 'changed' | 'removed'>\nconst entityDiffs = new WeakMap<EntityState[], WeakMap<EntityState[], EntitiesDiff>>()\nconst wholeDiffs = new WeakMap<EntityState[], EntitiesDiff>()\n\nfunction entitiesDiff(then: EntityState[] | undefined, now: EntityState[], base: Frame | undefined, registry: Registry | undefined): EntitiesDiff {\n\tlet byBase = then && entityDiffs.get(then)\n\tconst known = then ? byBase?.get(now) : wholeDiffs.get(now)\n\tif (known) return known\n\tconst made: EntitiesDiff = { added: [], changed: [], removed: [] }\n\tconst before = base ? entitiesById(base) : undefined\n\tconst seen = before && before.size ? new Set<number>() : undefined\n\tfor (const entity of now) {\n\t\tconst old = before?.get(entity.id)\n\t\tif (old) seen!.add(entity.id)\n\t\t// another type under the same id (a building upgraded) is sent whole\n\t\tif (!old || old.type !== entity.type) {\n\t\t\tif (old) made.removed.push(old.id)\n\t\t\tmade.added.push(encode(entity))\n\t\t\tcontinue\n\t\t}\n\t\tconst change = changeOf(registry, old, entity)\n\t\tif (change) made.changed.push(change)\n\t}\n\tif (before) for (const id of before.keys()) if (!seen!.has(id)) made.removed.push(id)\n\tif (then) {\n\t\tif (!byBase) entityDiffs.set(then, (byBase = new WeakMap()))\n\t\tbyBase.set(now, made)\n\t} else wholeDiffs.set(now, made)\n\treturn made\n}\n\n/**\n * A frame as what changed since `base`, or all of it without one. Events are the caller's to add. `registry`: the game's, whose\n * components say how a change of theirs is found (`Component.same`); without it, as text\n *\n * @internal\n */\nexport function diff(base: Frame | undefined, next: Frame, registry?: Registry): Omit<Delta, 'events'> {\n\tconst delta: Omit<Delta, 'events'> = {\n\t\ttick: next.snapshot.tick,\n\t\tbase: base ? base.snapshot.tick : null,\n\t\tadded: [],\n\t\tchanged: [],\n\t\tremoved: [],\n\t\trest: {}\n\t}\n\tconst { added, changed, removed } = entitiesDiff(base?.snapshot.entities, next.snapshot.entities, base, registry)\n\tdelta.added = added\n\tdelta.changed = changed\n\tdelta.removed = removed\n\tconst now = restOf(next)\n\tconst then = base && restOf(base)\n\tconst keys = then ? new Set([...Object.keys(now), ...Object.keys(then)]) : Object.keys(now)\n\tfor (const key of keys) {\n\t\tconst before = then?.[key as keyof Rest]\n\t\tconst after = now[key as keyof Rest]\n\t\tif (then && same(before, after)) continue\n\t\t// a part that changed in part (the gold of one player) goes as what changed in it; the fog whole, as the player\n\t\t// takes it whole (`RemoteSession`)\n\t\tconst patch = then && key !== 'fog' ? patchOf(before, after) : after\n\t\tif (isPatch(patch)) (delta.restPatch ??= {})[key as keyof Rest] = patch\n\t\telse (delta.rest as Record<string, unknown>)[key] = after\n\t}\n\treturn delta\n}\n\n/**\n * The frame a delta makes of the one at its base (none, for a whole one). Entities that did not change are the very\n * objects they were, so that whoever compares them by identity knows they did not. That is the frame before\n * (`latest`) whose object is the same as what is made, which is not always the base: the base is the last frame the\n * host heard was got, a frame or two behind, and the frames in between have objects of their own\n *\n * @internal\n */\nexport function apply(base: Frame | undefined, delta: Delta, latest?: Frame): Frame {\n\tconst removed = new Set(delta.removed)\n\tconst changed = new Map<number, EntityChange>()\n\tfor (const change of delta.changed) changed.set(change[0], change)\n\tconst before = new Map<number, EntityState>()\n\tif (latest && latest !== base) for (const entity of latest.snapshot.entities) before.set(entity.id, entity)\n\t/** The frame before's object for what is made, where it is the same as it; else what is made */\n\tconst kept = (made: EntityState) => {\n\t\tconst was = before.get(made.id)\n\t\treturn was && (was === made || sameEntity(was, made)) ? was : made\n\t}\n\tconst entities: EntityState[] = []\n\tfor (const entity of base?.snapshot.entities ?? []) {\n\t\tif (removed.has(entity.id)) continue\n\t\tconst change = changed.get(entity.id)\n\t\tif (!change) {\n\t\t\tentities.push(kept(entity))\n\t\t\tcontinue\n\t\t}\n\t\tconst [, set, unset, ownSet, ownUnset, ownPatch] = change\n\t\tconst next = { ...entity, ...decode(set) }\n\t\tfor (const field of unset || []) delete next[field]\n\t\tif (ownSet || ownUnset || ownPatch) {\n\t\t\tconst own = { ...entity.own, ...(ownSet || {}) } as OwnEntityState\n\t\t\tfor (const field of ownUnset || []) delete own[field]\n\t\t\tfor (const [field, patch] of Object.entries(ownPatch ?? {}))\n\t\t\t\t(own as unknown as Record<string, unknown>)[field] = patched(entity.own?.[field as keyof OwnEntityState], patch)\n\t\t\tnext.own = own\n\t\t}\n\t\tentities.push(kept(next))\n\t}\n\tfor (const added of delta.added) entities.push(kept(decode(added)))\n\tconst rest = { ...(base ? restOf(base) : {}), ...delta.rest } as Rest\n\tfor (const [key, patch] of Object.entries(delta.restPatch ?? {}))\n\t\t(rest as unknown as Record<string, unknown>)[key] = patched(base && restOf(base)[key as keyof Rest], patch)\n\tconst { fog, camps, team, ...parts } = rest\n\treturn { snapshot: { tick: delta.tick, ...parts, entities, events: [] }, fog, camps, team }\n}\n\n/**\n * Whether two states of an entity say the same, field by field\n *\n * @internal\n */\nexport function sameEntity(a: EntityState, b: EntityState): boolean {\n\tif (a.type !== b.type) return false\n\treturn fieldsOf(undefined, a, b) === undefined\n}\n\n/**\n * Characters of a delta's text by what they carry, added to `into`: each field of an entity, of those added and those\n * changed together (`entity.hp`; of what only its owner is told, `entity.own.abilities`), the other parts (`rest.fog`),\n * `events`, `removed`, and what is left (ids, brackets, the tick) as `other`, so that they add up to `text`'s length.\n * A field is its key, its value and the comma between, as `JSON.stringify` writes them\n */\nexport function bytesByKey(delta: Delta, text: string, into: Record<string, number>): void {\n\tlet counted = 0\n\tconst add = (key: string, characters: number) => {\n\t\tinto[key] = (into[key] ?? 0) + characters\n\t\tcounted += characters\n\t}\n\tconst fields = (prefix: string, values: object) => {\n\t\tfor (const [key, value] of Object.entries(values)) {\n\t\t\tif (value === undefined) continue\n\t\t\tif (key === 'own' && prefix === 'entity.' && value && typeof value === 'object') {\n\t\t\t\tadd('entity.own', key.length + 5)\n\t\t\t\tfields('entity.own.', value)\n\t\t\t} else add(prefix + key, key.length + 4 + JSON.stringify(value).length)\n\t\t}\n\t}\n\tfor (const entity of delta.added) fields('entity.', entity)\n\tfor (const [, set, unset, ownSet, ownUnset, ownPatch] of delta.changed) {\n\t\tfields('entity.', set)\n\t\tif (unset) add('entity.unset', JSON.stringify(unset).length + 1)\n\t\tif (ownSet) fields('entity.own.', ownSet)\n\t\tif (ownUnset) add('entity.own.unset', JSON.stringify(ownUnset).length + 1)\n\t\t// a field sent as what changed in it counts as the field\n\t\tif (ownPatch) fields('entity.own.', ownPatch)\n\t}\n\tfor (const part of [delta.rest, delta.restPatch ?? {}])\n\t\tfor (const [key, value] of Object.entries(part)) if (value !== undefined) add(`rest.${key}`, key.length + 4 + JSON.stringify(value).length)\n\tif (delta.events.length) add('events', JSON.stringify(delta.events).length)\n\tif (delta.removed.length) add('removed', JSON.stringify(delta.removed).length)\n\tadd('other', text.length - counted)\n}\n","import { EventLog, inspect, type Inspection, type InspectTarget, listWorld, type LoggedEvent, setInspected, type WorldListing } from '#engine/inspect'\nimport type { World } from '#engine/world'\nimport { isFiniteNumber, type SessionDebug } from './protocol'\nimport type { DebugAsk } from './wire'\n\n/** Milliseconds between two words of the debug tools' view of a world elsewhere: a server's, a worker's */\nexport const DEBUG_EVERY = 100\n\n/** Ticks between two lists of everything in the world: thousands of trees need not be listed every tick */\nconst LIST_EVERY = 10\n\n/**\n * The debug tools' view of a world running in the same page. What it hands out is worked out again whenever a\n * snapshot is, and at once when the client asks for something else: a remote one would wait for the answer instead\n */\nexport class LocalDebug implements SessionDebug {\n\tinspection: Inspection | null = null\n\tworld: WorldListing | null = null\n\tprivate target: InspectTarget | null = null\n\tprivate listedAt = -Infinity\n\tprivate readonly events = new EventLog()\n\n\tconstructor(private readonly simulation: World) {}\n\n\tinspect(target: InspectTarget | null): void {\n\t\tthis.target = target\n\t\tthis.refresh()\n\t}\n\n\tset(path: (string | number)[], value: number | boolean): void {\n\t\tif (!this.target) return\n\t\tsetInspected(this.simulation, this.target, path, value)\n\t\tthis.refresh()\n\t}\n\n\tget listing(): boolean {\n\t\treturn this.world !== null\n\t}\n\n\tset listing(on: boolean) {\n\t\tthis.listedAt = -Infinity\n\t\tthis.world = on ? listWorld(this.simulation) : null\n\t}\n\n\tget logging(): boolean {\n\t\treturn this.events.attached\n\t}\n\n\tset logging(on: boolean) {\n\t\tif (on === this.logging) return\n\t\tif (on) this.events.attach(this.simulation)\n\t\telse this.events.detach()\n\t}\n\n\tlog(): readonly LoggedEvent[] {\n\t\treturn this.events.entries\n\t}\n\n\tclearLog(): void {\n\t\tthis.events.clear()\n\t}\n\n\t/** Works what is handed out again. The session does when a tick went by */\n\trefresh(): void {\n\t\tconst world = this.simulation\n\t\tthis.inspection = this.target && inspect(world, this.target)\n\t\tif (this.world && world.tick - this.listedAt >= LIST_EVERY) {\n\t\t\tthis.world = listWorld(world)\n\t\t\tthis.listedAt = world.tick\n\t\t}\n\t}\n\n\tdispose(): void {\n\t\tthis.events.detach()\n\t}\n}\n\n/** What is followed, as the wire says it: an entity, a player or the world, or nothing; anything else is not */\nfunction targetOf(value: unknown): InspectTarget | null | undefined {\n\tif (value === null) return null\n\tif (typeof value !== 'object') return undefined\n\tconst target = value as Record<string, unknown>\n\tif (isFiniteNumber(target.entity)) return { entity: target.entity }\n\tif (isFiniteNumber(target.player)) return { player: target.player }\n\tif (target.world === true) return { world: true }\n\treturn undefined\n}\n\n/**\n * Does what the debug tools of a screen asked of a world here (`DebugAsk`), each field checked first: it comes from\n * anyone who can send anything\n */\nexport function askDebug(view: SessionDebug, ask: Record<string, unknown>): void {\n\tconst target = targetOf(ask.inspect)\n\tif (target !== undefined) view.inspect(target)\n\tconst set = ask.set as { path?: unknown; value?: unknown } | undefined\n\tif (\n\t\tset &&\n\t\tArray.isArray(set.path) &&\n\t\tset.path.every((key) => typeof key === 'string' || isFiniteNumber(key)) &&\n\t\t(isFiniteNumber(set.value) || typeof set.value === 'boolean')\n\t)\n\t\tview.set(set.path as (string | number)[], set.value)\n\tif (typeof ask.listing === 'boolean') view.listing = ask.listing\n\tif (typeof ask.logging === 'boolean') view.logging = ask.logging\n\tif (ask.clearLog === true) view.clearLog()\n}\n\n/**\n * The debug tools' view of a world elsewhere, a server's or a worker's: what it asked to follow, said over the wire\n * (`DebugAsk`), and what came back last (`take`)\n */\nexport class RemoteDebug implements SessionDebug {\n\tinspection: Inspection | null = null\n\tworld: WorldListing | null = null\n\tprivate listed = false\n\tprivate logged = false\n\tprivate target: InspectTarget | null = null\n\tprivate events: readonly LoggedEvent[] = []\n\n\tconstructor(private readonly ask: (ask: DebugAsk) => void) {}\n\n\tinspect(target: InspectTarget | null): void {\n\t\tthis.target = target\n\t\tif (!target) this.inspection = null\n\t\tthis.ask({ inspect: target })\n\t}\n\n\t/** Asks again for all it follows: of a world it is served from anew (a session resumed, a replay gone back) */\n\taskAgain(): void {\n\t\tif (this.target || this.listed || this.logged) this.ask({ inspect: this.target, listing: this.listed, logging: this.logged })\n\t}\n\n\tset(path: (string | number)[], value: number | boolean): void {\n\t\tthis.ask({ set: { path, value } })\n\t}\n\n\tget listing(): boolean {\n\t\treturn this.listed\n\t}\n\n\tset listing(on: boolean) {\n\t\tthis.listed = on\n\t\tif (!on) this.world = null\n\t\tthis.ask({ listing: on })\n\t}\n\n\tget logging(): boolean {\n\t\treturn this.logged\n\t}\n\n\tset logging(on: boolean) {\n\t\tthis.logged = on\n\t\tthis.ask({ logging: on })\n\t}\n\n\tlog(): readonly LoggedEvent[] {\n\t\treturn this.events\n\t}\n\n\tclearLog(): void {\n\t\tthis.events = []\n\t\tthis.ask({ clearLog: true })\n\t}\n\n\t/** What the world's side said of what is followed */\n\ttake(said: { inspection: Inspection | null; world: WorldListing | null; log: readonly LoggedEvent[] }): void {\n\t\tthis.inspection = said.inspection\n\t\tthis.world = this.listed ? said.world : null\n\t\tif (this.logged) this.events = said.log\n\t}\n}\n","/**\n * What a player is told of an entity (design review E7): what everyone in sight of it is, worked out once a tick for\n * every seat of a host (`commonEntityState`), and on it what is one player's own (`playerEntityState`). A seat\n * (`LocalSession`) puts them in its snapshots; nothing here keeps anything between ticks\n */\nimport { orderSays } from '#engine/orders/facts'\nimport { dashing } from '#engine/dashing'\nimport { illusion } from '#engine/summons'\nimport type { SnapshotView } from '#engine/components'\nimport type { Entity } from '#engine/entity'\nimport type { Vec2 } from '#engine/math'\nimport { declaredRefusal, notReady } from '#engine/orders/cast'\nimport { shieldOf } from '#engine/abilities/buffs'\nimport { baseStats } from '#engine/defs'\nimport { changedStats } from '#engine/stats'\nimport type { World } from '#engine/world'\nimport type { HudShareRule } from '#engine/rules'\nimport type { SessionView } from '#engine/replication'\nimport { deposit, fighting, moving } from '#engine/entity'\nimport type { AbilityInfo, EntityState, OwnEntityState, SharedAbility } from './protocol'\n\n/** A rule of `GameRules.hud` for one unit: its value, or what its function decides */\nconst ruleOf = <T>(world: World, entity: Entity, rule: HudShareRule<T>): T =>\n\ttypeof rule === 'function' ? (rule as (world: World, entity: Entity) => T)(world, entity) : rule\n\n/** The seconds left of a unit's buffs, in their order: -1 for one with no end, or kept up by an aura or a passive */\nfunction buffTimesOf(entity: Entity): number[] {\n\tconst times = new Array<number>(entity.buffs.length)\n\tfor (let i = 0; i < entity.buffs.length; i++) {\n\t\tconst buff = entity.buffs[i]\n\t\t// an aura's, a passive's: there while its source keeps it up, not for a time\n\t\ttimes[i] = Number.isFinite(buff.remaining) && !buff.kept ? Math.max(buff.remaining, 0) : -1\n\t}\n\treturn times\n}\n\n/**\n * What everyone in sight of an entity is told of it this tick, the same for every seat (`EntityState`): where it is,\n * its health and mana, its stats where they changed, its buffs, what the rules share for the plates over it. `name`\n * is what the map calls it, where it has a name\n *\n * @internal\n */\nexport function commonEntityState(world: World, entity: Entity, name: string | undefined): EntityState {\n\tconst state: EntityState = {\n\t\tid: entity.id,\n\t\ttype: entity.def.id,\n\t\towner: entity.owner,\n\t\tx: entity.pos.x,\n\t\tz: entity.pos.z,\n\t\tfacing: entity.facing,\n\t\thp: entity.hp,\n\t\tstats: changedStats(world, entity),\n\t\tvisible: true\n\t}\n\tconst base = baseStats(entity.def, world.registry)\n\tif (entity.maxHp !== base.health) state.maxHp = entity.maxHp\n\tif (entity.buffs.length) state.shield = shieldOf(entity) || undefined\n\tconst dash = entity.get(dashing)\n\tif (dash?.height) state.leap = { from: dash.from, to: { x: dash.x, z: dash.z }, height: dash.height }\n\tif (entity.maxMana > 0) {\n\t\tstate.mana = entity.mana\n\t\tif (entity.maxMana !== base.mana) state.maxMana = entity.maxMana\n\t}\n\tif (entity.buffs.length) state.buffs = entity.buffs.map((buff) => buff.id)\n\tfor (const buff of entity.buffs) if (buff.stacks) (state.stacks ??= {})[buff.id] = buff.stacks\n\t// what the game's rules share besides, for the plates over it (indicators-plan U3)\n\tconst { hud } = world.rules\n\tif (hud.shareBuffTimes !== undefined && entity.buffs.length && ruleOf(world, entity, hud.shareBuffTimes) === true)\n\t\tstate.buffTimes = buffTimesOf(entity)\n\tif (hud.shareAbilities !== undefined && entity.abilities.length) {\n\t\tconst share = ruleOf(world, entity, hud.shareAbilities)\n\t\tif (share === 'icons' || share === 'cooldowns') {\n\t\t\tconst abilities: SharedAbility[] = []\n\t\t\tfor (const { id, level, cooldown } of entity.abilities) {\n\t\t\t\tif (level >= 1) abilities.push(share === 'cooldowns' ? { id, level, cooldown } : { id, level })\n\t\t\t}\n\t\t\tif (abilities.length) state.abilities = abilities\n\t\t}\n\t}\n\tif (entity.get(deposit)) state.resource = entity.get(deposit)!.amount\n\tif (entity.on !== undefined) state.on = entity.on\n\tif (entity.asleep) state.asleep = true\n\tif (entity.scale !== 1) state.scale = entity.scale\n\tif (entity.look) state.look = entity.look\n\tif (world.sight.isInvisible(entity)) state.unseen = true\n\tif (name !== undefined) state.name = name\n\t// how long an illusion lasts would give it away: its side alone is told (`describe`)\n\tif (entity.expires !== null && !entity.has(illusion)) state.lifetime = { left: entity.expires, total: entity.lifetime }\n\treturn state\n}\n\n/**\n * Whether an entity has a component replicated to its owner, or shaping itself for each player (`Component.snapshot`)\n *\n * @internal\n */\nexport function hasOnePlayersPart(world: World, entity: Entity): boolean {\n\tfor (const held of entity.heldComponents()) {\n\t\tconst component = world.registry.component(held.id)\n\t\tif (component?.replicate === 'owner' || (component?.replicate && component.snapshot)) return true\n\t}\n\treturn false\n}\n\n/**\n * What one player is told of an entity, on what everyone is (`shared`, `commonEntityState`): an illusion's lifetime on\n * its own side, the components replicated to the player and what they make of themselves for them, and its own part\n * (`own`: its orders, where it goes, its abilities) for one of the player's side. `shared` itself where there is\n * nothing more\n *\n * @internal\n */\nexport function playerEntityState(view: SessionView, entity: Entity, shared: EntityState): EntityState {\n\tconst { world, player, observer } = view\n\tlet state = shared\n\t/** This player's copy of the shared state, made once something of this player's is added */\n\tconst mine = () => (state === shared ? (state = { ...shared }) : state)\n\tif (entity.expires !== null && entity.has(illusion) && view.isAlly(entity.owner)) mine().lifetime = { left: entity.expires, total: entity.lifetime }\n\tlet seen: SnapshotView | undefined\n\tfor (const held of entity.heldComponents()) {\n\t\tconst { id } = held\n\t\tconst component = world.registry.component(id)\n\t\tconst audience = component?.replicate\n\t\tif (!audience) continue\n\t\tconst ally = view.isAlly(entity.owner)\n\t\tif (!(audience === 'everyone' || (audience === 'allies' ? ally : entity.owner === player))) continue\n\t\t// what the component makes of it for this player, or a copy: what is sent must not change with the world, nor change it\n\t\tconst value = entity.get(held)\n\t\tconst sent = component!.snapshot\n\t\t\t? component!.snapshot(\n\t\t\t\t\tvalue,\n\t\t\t\t\tentity,\n\t\t\t\t\t(seen ??= {\n\t\t\t\t\t\tworld,\n\t\t\t\t\t\tplayer: observer ? undefined : player,\n\t\t\t\t\t\town: entity.owner === player,\n\t\t\t\t\t\tally,\n\t\t\t\t\t\tobserver: observer,\n\t\t\t\t\t\tknows: view.knows,\n\t\t\t\t\t\tisAlly: view.isAlly,\n\t\t\t\t\t\tsees: view.sees\n\t\t\t\t\t})\n\t\t\t\t)\n\t\t\t: structuredClone(value)\n\t\tif (sent !== undefined) (mine().components ??= {})[id] = sent\n\t}\n\tif (!view.isAlly(entity.owner)) return state\n\tconst shareBuffTimes = world.rules.hud.shareBuffTimes\n\tif (shareBuffTimes !== undefined && entity.buffs.length && !shared.buffTimes && ruleOf(world, entity, shareBuffTimes) === 'allies')\n\t\tmine().buffTimes = buffTimesOf(entity)\n\n\tconst m = entity.get(moving)\n\t// the places of the orders queued after the first: none made for a unit with nothing queued, most of them (RV87)\n\tlet waypoints: Vec2[] | undefined\n\tfor (let i = 1; i < entity.orders.length; i++) {\n\t\tconst order = entity.orders[i]\n\t\tconst target = world.get(order.init.target)\n\t\tconst point = target && view.knows(target) ? target.pos : order.init.point\n\t\tif (point) (waypoints ??= []).push({ x: point.x, z: point.z })\n\t}\n\tconst own: OwnEntityState = (mine().own = {\n\t\t// another's that this player may command: its owner shares control with them\n\t\t...(entity.owner !== player && !observer && world.mayCommand(player, entity) && { shared: true }),\n\t\thidden: entity.hidden,\n\t\torder: entity.orders[0]?.type ?? null,\n\t\t// on its way to build it: once the site is down, what it builds is there to be counted itself\n\t\tbuild: entity.orders[0]?.type === 'build' && !orderSays(world, entity, 'building') ? entity.orders[0].init.unitType : undefined,\n\t\torders: entity.orders.length,\n\t\tpassive: entity.get(fighting)?.passive ?? false,\n\t\tfighting: !!entity.get(fighting)?.autoTarget,\n\t\tgoal: m?.status === 'moving' ? { x: m.navGoal.x, z: m.navGoal.z } : undefined,\n\t\t...(waypoints && { waypoints })\n\t})\n\tif (entity.abilities.length) {\n\t\tconst hooked = world.hooks.has('canCast')\n\t\town.abilities = entity.abilities.map(({ id, level, cooldown, charges, refill, autocast }) => {\n\t\t\tconst info: AbilityInfo = { id, level, cooldown, autocast }\n\t\t\tif (charges !== undefined) Object.assign(info, { charges, refill })\n\t\t\tif (!hooked || level < 1) return info\n\t\t\t// what the game's hook decides, where the screen could not work it out from what is declared\n\t\t\tconst ability = world.registry.ability(id)\n\t\t\tconst declared = declaredRefusal(world, entity, ability)\n\t\t\tconst decided = notReady(world, entity, ability)\n\t\t\tif (declared?.key !== decided?.key) info.decided = decided ?? null\n\t\t\treturn info\n\t\t})\n\t}\n\treturn state\n}\n","import { checkpoint as checkpointEvent } from '#engine/engineEvents'\nimport { minesFor } from '#engine/systems/economy'\nimport { paceOf, savesOf } from './can'\nimport { sameEntity } from './delta'\nimport type { Logger } from '#engine/log'\nimport type { MapCamera, MapDoodad, MapEnvironment, MapPath, MapRegion } from '#engine/map'\nimport { names } from '#engine/names'\nimport { campsFor } from '#engine/camps'\nimport { type Lane, lanesOf } from '#engine/lanes'\nimport { assertPlainData } from '#engine/debug'\nimport type { Entity, EntityId, PlayerId } from '#engine/entity'\nimport { heroSummaries } from '#engine/hero'\nimport type { Vec2 } from '#engine/math'\nimport { canPlaceStructure, placementCells } from '#engine/orders/build'\nimport type { Registry } from '#engine/registry'\nimport { decidedAvailability, decidedUnlocks, techOf } from '#engine/tech'\nimport type { Terrain } from '#engine/terrain'\nimport type { World } from '#engine/world'\nimport type {\n\tCampInfo,\n\tEntityState,\n\tFogState,\n\tGameSession,\n\tMineInfo,\n\tPlayerCommand,\n\tPlayerState,\n\tSessionEvent,\n\tSnapshot,\n\tSessionCan,\n\tSessionDebug\n} from './protocol'\nimport type { Message } from '#engine/messages'\nimport { saveWorld, type WorldSave } from '#engine/save'\nimport type { TeamMemory } from './memory'\nimport { LocalDebug } from './debug'\nimport { deposit } from '../entity'\nimport { SessionView, type SnapshotPart } from '#engine/replication'\nimport { commonEntityState, hasOnePlayersPart, playerEntityState } from './entityState'\nimport { shownEffects } from '#engine/effects'\n\n/**\n * A seat at a world running in the same page. It does the job a server will do later:\n * run the simulation, and hand the player only what their team is allowed to know.\n */\n/** The effects of the rules a player was shown that are kept, for a stop to be told to them: the latest so many */\nconst MOST_EFFECTS = 1024\n\n/**\n * The events a computer player's seat hears (`forComputer`): the facts a brain reads and a save keeps for it (deaths,\n * damage, healing, pings, chat, the game's own events) and the answers to its commands. The rest is for a screen (an\n * attack's swing, a shot, a buff, a hammer blow, a line said), and a computer's seat is spared hearing it\n *\n * @beta\n */\nexport const COMPUTER_EVENTS: ReadonlySet<SessionEvent['type']> = new Set(['death', 'damage', 'heal', 'ping', 'chat', 'game', 'command'])\n\n/**\n * What is told of each entity this round, for every session of a world, while a host sends to its seats\n * (`shareCaptures`), none otherwise: what everyone is told (`common`, by entity), and what the seats of one side are\n * (`sides`: by the side's key, `LocalSession.sideKey`, then by entity) where nothing of it is one player's\n */\ninterface Round {\n\treadonly common: Map<EntityId, EntityState>\n\treadonly sides: Map<string, Side>\n}\n\n/**\n * What the seats of a side are told this round, by entity: what nothing of is one player's (`all`), and of what is, the\n * first seat's (`alike`), which a seat told the very same takes as it is, so that the side's frames share their objects\n */\ninterface Side {\n\treadonly all: Map<EntityId, EntityState>\n\treadonly alike: Map<EntityId, EntityState>\n\t/** What its first seat saw (`LocalSession.capture`): the others of the side see the same, but what may be theirs alone */\n\tseen?: SideSeen\n}\n\n/**\n * What the first seat of a side saw this round: its entities, those of them in sight, and where in the list are those\n * whose description may be one player's (`LocalSession.isOnePlayers`), to be described again for each seat\n */\ninterface SideSeen {\n\treadonly entities: readonly EntityState[]\n\treadonly inSight: ReadonlySet<EntityId>\n\treadonly mine: readonly number[]\n}\nconst SHARED = new WeakMap<World, Round>()\n\n/**\n * From here until `endSharedCaptures`, the sessions of the world describe each entity once between them (what\n * everyone is told; what is one player's goes on a copy): for a host's round of sending, where every seat is captured\n * from the same world. Not while the world changes: what was described is said again\n *\n * @internal\n */\nexport function shareCaptures(world: World): void {\n\tSHARED.set(world, { common: new Map(), sides: new Map() })\n}\n\n/** @internal */\nexport function endSharedCaptures(world: World): void {\n\tSHARED.delete(world)\n}\n\n/** @beta */\nexport class LocalSession implements GameSession {\n\treadonly terrain: Terrain\n\treadonly environment?: MapEnvironment\n\treadonly doodads: readonly MapDoodad[]\n\treadonly regions: readonly MapRegion[]\n\treadonly cameras: readonly MapCamera[]\n\treadonly paths: readonly MapPath[]\n\treadonly registry: Registry\n\treadonly tickRate: number\n\talpha = 1\n\t/** What the world says (`World.log`): a session in the page has it, and the client shows it with its own */\n\tget log(): Logger {\n\t\treturn this.world.log\n\t}\n\t/** Why the game ended on an error, once it has (`World.failure`) */\n\tget failure(): { message: string } | null {\n\t\treturn this.world.failure\n\t}\n\t/** Simulation speed multiplier, 0 pauses. A debug control, a real server sets the pace itself */\n\tspeed = 1\n\n\tprivate accumulator = 0\n\t/** Whether the team saw the whole map at the last snapshot (the debug switch): what it saw then only is forgotten after */\n\tprivate wasRevealed = false\n\t/** What the player's team remembers, or an observer's own (`SessionView.memory`) */\n\tprivate get memory(): TeamMemory {\n\t\treturn this.view.memory\n\t}\n\t/** Ids of what made it into the snapshot being put together as in sight. Kept to be cleared, not made anew */\n\tprivate readonly inSight = new Set<EntityId>()\n\t/** The names the map or the rules gave entities, by id, as of the snapshot being put together (`world.named`) */\n\tprivate readonly namesNow = new Map<EntityId, string>()\n\tprivate readonly disposers: (() => void)[] = []\n\tprivate pendingCheckpoint?: Message\n\tcheckpoint?: { label: Message; save: WorldSave }\n\treadonly debug: LocalDebug\n\t/** Its pace, saves of its world, the debug tools' view, and what a computer player's brain reads (`SessionCan`) */\n\treadonly can: SessionCan = {\n\t\tpace: paceOf(this),\n\t\tsaves: savesOf(this),\n\t\tinspect: undefined,\n\t\tcomputer: {\n\t\t\tmines: () => this.mines(),\n\t\t\tlanes: () => this.lanes(),\n\t\t\tpendingEvents: () => this.pendingEvents(),\n\t\t\trestoreEvents: (events) => this.restoreEvents(events)\n\t\t}\n\t}\n\t/**\n\t * Who only watches, and sees everything: every entity, the whole map, every player's resources and heroes. From\n\t * `playerId`'s side all the same (who is an ally, an enemy). For a server's watchers, whose commands go nowhere\n\t */\n\treadonly observer: boolean\n\t/**\n\t * Whose seat is a computer player's (`forComputer`): its snapshots leave out projectiles, missiles, corpses, reveals\n\t * and the events a brain never reads, and it listens for none of those, so twelve computers cost the world less\n\t */\n\treadonly forComputer: boolean\n\t/** The seat's side of the world: whose it is, what they may know, what was told to them since the last snapshot */\n\treadonly view: SessionView\n\n\tconstructor(\n\t\t/** For tools and tests. Clients have no business here, they go through the session */\n\t\treadonly world: World,\n\t\treadonly playerId: PlayerId,\n\t\t/**\n\t\t * `debug`: the player may use the debug commands (see `world.debugPlayers`). `ownsWorld`: the world is the\n\t\t * session's, and goes with it (`dispose`): for a game played in the page, where the session is all the screen\n\t\t * holds of it. Not for a world others play too, or one that goes on after this session (a host's seats, the computer's).\n\t\t * `forComputer`: the seat is a computer player's, and its snapshots carry what a brain reads and none of what a\n\t\t * screen needs (`COMPUTER_EVENTS`): cheaper to take, and fewer of the world's events to hear.\n\t\t * `mostEffects` (`@beta`): how many of the effects the rules play are kept for their stop, 1024 when left out\n\t\t */\n\t\toptions: { observer?: boolean; debug?: boolean; ownsWorld?: boolean; forComputer?: boolean; mostEffects?: number } = {}\n\t) {\n\t\tthis.observer = options.observer ?? false\n\t\tthis.ownsWorld = options.ownsWorld ?? false\n\t\tthis.forComputer = options.forComputer ?? false\n\t\tthis.view = new SessionView(world, playerId, {\n\t\t\tobserver: this.observer,\n\t\t\tforComputer: this.forComputer,\n\t\t\tmostEffects: options.mostEffects ?? MOST_EFFECTS\n\t\t})\n\t\tif (options.debug) world.debugPlayers.add(playerId)\n\t\tthis.terrain = world.terrain\n\t\tthis.environment = world.map.environment\n\t\tthis.doodads = world.map.doodads\n\t\tthis.regions = world.map.regions\n\t\tthis.cameras = world.map.cameras\n\t\tthis.paths = world.map.paths\n\t\tthis.registry = world.registry\n\t\tthis.tickRate = world.tickRate\n\t\tthis.debug = new LocalDebug(world)\n\t\t;(this.can as { inspect?: SessionDebug }).inspect = this.debug\n\n\t\tconst { events } = world\n\t\tconst { view } = this\n\t\t// what the seat hears of the world, each told as what emits it says (`replicateEvent`): a computer's seat only what\n\t\t// a brain reads (`COMPUTER_EVENTS`), so that it is told of nothing it throws away, and the world's events have fewer\n\t\t// listeners for each computer seated\n\t\tfor (const replication of world.registry.replications) {\n\t\t\tif (!this.hears(replication.as)) continue\n\t\t\tthis.disposers.push(\n\t\t\t\tevents.on(replication.event as never, (payload: unknown) => {\n\t\t\t\t\tconst said = replication.tell(payload, view)\n\t\t\t\t\tif (said) view.events.push(said)\n\t\t\t\t})\n\t\t\t)\n\t\t}\n\t\t// saved once the tick is over, with everything in it settled\n\t\tthis.disposers.push(events.on(checkpointEvent, ({ label }) => (this.pendingCheckpoint = label)))\n\t\t// the game's own, to whom it says: those of this world's game (`GameModule.events`), whichever they turn out to be\n\t\tif (this.hears('game'))\n\t\t\tthis.disposers.push(\n\t\t\t\tevents.watch((type, payload) => {\n\t\t\t\t\tif (typeof type !== 'string') return\n\t\t\t\t\tconst audience = world.registry.event(type)?.replicate\n\t\t\t\t\tif (!audience) return\n\t\t\t\t\tif (audience !== 'everyone' && !audience(payload, view)) return\n\t\t\t\t\tif (this.world.checks.events) assertPlainData(payload, `Event \"${type}\"`)\n\t\t\t\t\tview.events.push({ type: 'game', event: type, payload })\n\t\t\t\t})\n\t\t\t)\n\t}\n\n\t/** Whether the seat is told of events of a kind: a player's seat of all of them, a computer's of what a brain reads */\n\tprivate hears(kind: SessionEvent['type']): boolean {\n\t\treturn !this.forComputer || COMPUTER_EVENTS.has(kind)\n\t}\n\n\t/** The player's team: theirs now, as the rules may move them to another (`setTeam`) */\n\tget team(): number {\n\t\treturn this.view.team\n\t}\n\n\tprivate isAlly(owner: PlayerId): boolean {\n\t\treturn this.view.isAlly(owner)\n\t}\n\n\t/** Whether the player's team sees a spot of the map right now: an observer sees all of it */\n\tprivate sees(x: number, z: number): boolean {\n\t\treturn this.view.sees(x, z)\n\t}\n\n\t/**\n\t * How many effects of the rules are kept for their stop to be told (`mostEffects`), for a test of the bound\n\t *\n\t * @internal\n\t */\n\tget keptEffects(): number {\n\t\treturn shownEffects(this.view).size\n\t}\n\n\t/** Whether the player's team can see the entity right now */\n\tprivate knows(entity: Entity): boolean {\n\t\treturn this.view.knows(entity)\n\t}\n\n\t/**\n\t * What everyone in sight of an entity is told of it this tick, the same for every seat: worked out once for all\n\t * the sessions of a world while a host's round of sending is on (`shareCaptures`), else for this session alone\n\t */\n\tprivate common(entity: Entity): EntityState {\n\t\tconst shared = SHARED.get(this.world)?.common\n\t\tconst known = shared?.get(entity.id)\n\t\tif (known) return known\n\t\tconst state = commonEntityState(this.world, entity, this.namesNow.get(entity.id))\n\t\tshared?.set(entity.id, state)\n\t\treturn state\n\t}\n\n\t/**\n\t * What this player is told of an entity: what everyone is (`common`, shared between the seats of a host), and on a\n\t * copy of it what is this player's to know: an illusion's lifetime on its own side, the components replicated to it\n\t * and what they make of themselves for it, and its own part (`own`) for an ally's\n\t */\n\tprivate describe(entity: Entity): EntityState {\n\t\tconst side = this.sideNow\n\t\tif (!side) return playerEntityState(this.view, entity, this.common(entity))\n\t\tif (this.isOnePlayers(entity)) {\n\t\t\tconst state = playerEntityState(this.view, entity, this.common(entity))\n\t\t\tconst first = side.alike.get(entity.id)\n\t\t\tif (!first) side.alike.set(entity.id, state)\n\t\t\telse if (first !== state && sameEntity(first, state)) return first\n\t\t\treturn state\n\t\t}\n\t\tconst known = side.all.get(entity.id)\n\t\tif (known) return known\n\t\tconst state = playerEntityState(this.view, entity, this.common(entity))\n\t\tside.all.set(entity.id, state)\n\t\treturn state\n\t}\n\n\t/**\n\t * What the seats of this one's side are told alike this round (`Round.sides`), by entity: none outside a host's round.\n\t * Set as the capture starts (`capture`)\n\t */\n\tprivate sideNow: Side | undefined\n\n\t/**\n\t * Which seats are told the same of an entity where nothing of it is one player's: an observer's, or a team's with the\n\t * same allies among the players (relations are a pair of players', not a team's)\n\t */\n\tprivate sideKey(): string {\n\t\tif (this.observer) return 'observer'\n\t\tlet key = `team ${this.team}:`\n\t\tfor (const player of this.world.players.keys()) key += this.isAlly(player) ? '1' : '0'\n\t\treturn key\n\t}\n\n\t/**\n\t * Whether what this player is told of an entity is theirs alone, not their side's: a component replicated to its owner\n\t * or shaping itself for each player (`Component.snapshot`), or control of another's unit shared with this player\n\t */\n\tprivate isOnePlayers(entity: Entity): boolean {\n\t\tif (hasOnePlayersPart(this.world, entity)) return true\n\t\treturn entity.owner !== this.playerId && !this.observer && this.isAlly(entity.owner) && this.world.mayCommand(this.playerId, entity)\n\t}\n\n\t/** Where in the list being captured are those that may be one player's (`SideSeen.mine`): while the first seat of a side captures */\n\tprivate mineNow: number[] | undefined\n\n\t/**\n\t * What the team remembers of a structure is every teammate's to be told, not this seat's: without the parts of the\n\t * description shaped for one player (components replicated to the owner, or made by their `snapshot` for whoever is\n\t * told), which the seat that happened to see it first would otherwise give to the whole team\n\t */\n\tprivate forTeam(entity: Entity, state: EntityState): EntityState {\n\t\tif (!state.components || !hasOnePlayersPart(this.world, entity)) return state\n\t\tconst components: Record<string, unknown> = {}\n\t\tfor (const [id, part] of Object.entries(state.components)) {\n\t\t\tconst component = this.world.registry.component(id)\n\t\t\tif (component?.replicate === 'owner' || (component?.replicate && component.snapshot)) continue\n\t\t\tcomponents[id] = part\n\t\t}\n\t\treturn { ...state, components }\n\t}\n\n\t/** Adds what the player sees of an entity in sight to the snapshot, and remembers structures for when they are out of sight */\n\tprivate see(entity: Entity, out: EntityState[], remembered: Record<EntityId, EntityState>): void {\n\t\tconst before = remembered[entity.id]\n\t\t// trees and mines rarely change: what was said about them last time is said again, as it is\n\t\tconst kept = entity.isResource && before?.visible && before.resource === entity.get(deposit)?.amount\n\t\tconst state = kept ? before : this.describe(entity)\n\t\tif (!kept && this.mineNow && (this.isAlly(entity.owner) || hasOnePlayersPart(this.world, entity))) this.mineNow.push(out.length)\n\t\tout.push(state)\n\t\tthis.inSight.add(entity.id)\n\t\tif (entity.isStructure && !this.isAlly(entity.owner)) {\n\t\t\tif (state !== before) remembered[entity.id] = this.forTeam(entity, state)\n\t\t} else if (before) delete remembered[entity.id]\n\t}\n\n\t/** Throws when what was taken to be in sight is not what testing every entity gives. See `debugChecks` */\n\tprivate checkSight(): void {\n\t\tfor (const entity of this.world.entities.values()) {\n\t\t\tif (!entity.alive || this.knows(entity) === this.inSight.has(entity.id)) continue\n\t\t\tconst said = this.inSight.has(entity.id) ? 'in sight' : 'out of sight'\n\t\t\tthrow new Error(`Snapshot for player ${this.playerId} has ${entity.def.id}#${entity.id} ${said}, it is not`)\n\t\t}\n\t}\n\n\t/** The scenery the player's team sees right now */\n\tprivate *sceneryInSight(): Iterable<Entity> {\n\t\tconst { world } = this\n\t\t// a team that sees the whole map sees all of it. Only for players who are out and a debug switch\n\t\tif (this.observer || world.fog.isRevealed(this.team)) {\n\t\t\tfor (const entity of world.entities.values()) if (entity.scenery) yield entity\n\t\t} else yield* world.sceneryInSight.get(this.team) ?? []\n\t}\n\n\t/**\n\t * On a map explored from the start, what stands on it and belongs to no player (trees, mines, rocks, neutral\n\t * buildings, the creeps' own) known to the team from the first snapshot, as it stands, out of sight: the genre's melee\n\t * maps. Once for a team (`TeamMemory.startKnown`); units, and players' buildings, only once seen\n\t */\n\tprivate knowStart(remembered: Record<EntityId, EntityState>): void {\n\t\tconst { world } = this\n\t\tif (this.observer || !world.fog.exploredFromStart) return\n\t\tconst memory = this.memory\n\t\tif (memory.startKnown) return\n\t\tmemory.startKnown = true\n\t\tfor (const entity of world.entities.values()) {\n\t\t\tif (!entity.alive || !entity.isStructure || this.inSight.has(entity.id) || remembered[entity.id]) continue\n\t\t\tconst owner = world.players.get(entity.owner)\n\t\t\tif (!owner?.neutral && !owner?.creeps) continue\n\t\t\tremembered[entity.id] = { ...this.forTeam(entity, this.describe(entity)), visible: false }\n\t\t}\n\t}\n\n\tprivate capture(): Snapshot {\n\t\tconst { world } = this\n\t\tconst round = SHARED.get(world)\n\t\tif (round) {\n\t\t\tconst key = this.sideKey()\n\t\t\tlet side = round.sides.get(key)\n\t\t\tif (!side) round.sides.set(key, (side = { all: new Map(), alike: new Map() }))\n\t\t\tthis.sideNow = side\n\t\t} else this.sideNow = undefined\n\t\tconst remembered = this.memory.structures\n\t\t// what is named, by id, for `describe`: the names are few, and looked up for every entity in sight\n\t\tthis.namesNow.clear()\n\t\tif (world.states.has(names)) for (const [name, id] of Object.entries(world.state(names))) this.namesNow.set(id, name)\n\t\tconst seen = this.sideNow?.seen\n\t\tconst entities = seen ? this.seeAsSide(seen) : this.seeAll(remembered)\n\t\tif (this.world.checks.sight) this.checkSight()\n\t\tif (seen) return this.finish(entities)\n\t\tthis.knowStart(remembered)\n\t\t// the fog back after it was lifted: what was seen only while it was (ground never explored) is not known after all\n\t\tconst revealed = this.observer || world.fog.isRevealed(this.team)\n\t\tif (this.wasRevealed && !revealed) {\n\t\t\tfor (const [key, state] of Object.entries(remembered)) {\n\t\t\t\tif (!this.inSight.has(Number(key)) && !world.fog.isExplored(this.team, state.x, state.z)) delete remembered[Number(key)]\n\t\t\t}\n\t\t}\n\t\tthis.wasRevealed = revealed\n\t\t// Structures that are not in sight are shown the way they were last seen. That goes for the ones that were\n\t\t// destroyed out of sight too: they stay on the map until someone looks at the spot again. Where the rules keep\n\t\t// nothing of what was seen (`FogRules.explored: 'nothing'`), out of sight is forgotten\n\t\tconst forget = world.rules.fog?.explored === 'nothing' && !revealed\n\t\tfor (const [key, state] of Object.entries(remembered)) {\n\t\t\tconst id = Number(key)\n\t\t\tif (this.inSight.has(id)) continue\n\t\t\tif (forget) {\n\t\t\t\tdelete remembered[id]\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif (!world.get(id) && this.sees(state.x, state.z)) {\n\t\t\t\tdelete remembered[id]\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\t// made once, when it leaves the view\n\t\t\tconst memory = state.visible ? { ...state, visible: false } : state\n\t\t\tif (memory !== state) remembered[id] = memory\n\t\t\tentities.push(memory)\n\t\t}\n\t\tif (this.sideNow) this.sideNow.seen = { entities: [...entities], inSight: new Set(this.inSight), mine: this.mineNow ?? [] }\n\t\tthis.mineNow = undefined\n\t\treturn this.finish(entities)\n\t}\n\n\t/** The entities in sight, and what the side remembers out of it, as the first seat of a side (or a seat on its own) sees them */\n\tprivate seeAll(remembered: Record<EntityId, EntityState>): EntityState[] {\n\t\tconst { world } = this\n\t\tconst entities: EntityState[] = []\n\t\tthis.inSight.clear()\n\t\tthis.mineNow = this.sideNow ? [] : undefined\n\t\t// what acts or changes by itself is looked at one by one\n\t\tfor (const entity of world.actors.values()) {\n\t\t\tif (entity.alive && this.knows(entity)) this.see(entity, entities, remembered)\n\t\t}\n\t\t// Scenery (a map can have thousands of trees) never moves, so it only comes into sight or goes out of it when\n\t\t// the fog is worked out again. The fog system keeps what each team sees of it, instead of every tree being tested here\n\t\tfor (const entity of this.sceneryInSight()) {\n\t\t\tif (entity.alive && entity.scenery) this.see(entity, entities, remembered)\n\t\t}\n\t\treturn entities\n\t}\n\n\t/**\n\t * What another seat of the side saw this round, as this one sees it: the same, but what may be this player's alone\n\t * described again for them. The side's memory is the first seat's to keep\n\t */\n\tprivate seeAsSide(seen: SideSeen): EntityState[] {\n\t\tconst entities = [...seen.entities]\n\t\tthis.inSight.clear()\n\t\tfor (const id of seen.inSight) this.inSight.add(id)\n\t\tfor (const at of seen.mine) entities[at] = this.describe(this.world.get(entities[at].id)!)\n\t\t// as the first seat did, what was seen only while the fog was lifted is no longer known\n\t\tthis.wasRevealed = this.observer || this.world.fog.isRevealed(this.team)\n\t\treturn entities\n\t}\n\n\t/** The rest of a snapshot, round its entities: the players, and every feature's part (`SnapshotPart`) */\n\tprivate finish(entities: EntityState[]): Snapshot {\n\t\tconst { world } = this\n\t\tconst players: PlayerState[] = []\n\t\tfor (const player of world.players.values()) {\n\t\t\tconst state: PlayerState = {\n\t\t\t\tid: player.id,\n\t\t\t\tname: player.name,\n\t\t\t\tteam: player.team,\n\t\t\t\tcolor: player.color,\n\t\t\t\tneutral: player.neutral,\n\t\t\t\tcreeps: player.creeps || undefined,\n\t\t\t\t...(player.race !== undefined && { race: player.race }),\n\t\t\t\tdefeated: player.defeated,\n\t\t\t\trelation:\n\t\t\t\t\tplayer.id === this.playerId\n\t\t\t\t\t\t? 'self'\n\t\t\t\t\t\t: world.areAllies(this.playerId, player.id)\n\t\t\t\t\t\t\t? 'ally'\n\t\t\t\t\t\t\t: world.areEnemies(this.playerId, player.id)\n\t\t\t\t\t\t\t\t? 'enemy'\n\t\t\t\t\t\t\t\t: 'neutral'\n\t\t\t}\n\t\t\tif (state.relation === 'ally' && !player.neutral && !this.observer) {\n\t\t\t\tconst me = world.player(this.playerId)\n\t\t\t\tstate.shared = {\n\t\t\t\t\tcontrol: world.sides.controlOf(this.playerId).includes(player.id),\n\t\t\t\t\tvision: me.team === player.team || world.sides.visionOf(me.team).includes(player.team)\n\t\t\t\t}\n\t\t\t}\n\t\t\t// an observer is told every player's\n\t\t\tif (player.id === this.playerId || (this.observer && !player.neutral)) {\n\t\t\t\tstate.own = {\n\t\t\t\t\tresources: { ...player.resources },\n\t\t\t\t\tsupplyUsed: player.supplyUsed,\n\t\t\t\t\tsupplyCap: player.supplyCap,\n\t\t\t\t\t...(Object.keys(player.supplies).length > 0 && { supplies: structuredClone(player.supplies) }),\n\t\t\t\t\tupkeep: world.rules.economy.upkeep(world, player.id),\n\t\t\t\t\tupgrades: Object.fromEntries(player.upgrades),\n\t\t\t\t\tresearching: [...player.researching],\n\t\t\t\t\ttech: [...techOf(world, player.id)],\n\t\t\t\t\theroes: heroSummaries(world, player.id),\n\t\t\t\t\t// copies: the snapshot is the player's to keep, and the objectives go on changing\n\t\t\t\t\tobjectives: world.objectives.of(player.id).map((objective) => structuredClone(objective)),\n\t\t\t\t\t...(world.timers.shownTo(player.id).length && { timers: world.timers.shownTo(player.id) })\n\t\t\t\t}\n\t\t\t\tif (world.hooks.has('requirement') && player.id === this.playerId) state.own.unlocks = decidedUnlocks(world, player.id)\n\t\t\t\tif (world.hooks.has('available') && player.id === this.playerId) {\n\t\t\t\t\tconst availability = decidedAvailability(world, player.id)\n\t\t\t\t\tif (availability) state.own.availability = availability\n\t\t\t\t}\n\t\t\t}\n\t\t\tplayers.push(state)\n\t\t}\n\n\t\t// the rest is each feature's to say (`SnapshotPart`): before the entities where it says, the rest after the players\n\t\tconst { view } = this\n\t\tconst snapshot = { tick: world.tick } as Snapshot\n\t\tconst parts = world.registry.snapshotParts\n\t\tconst take = (part: SnapshotPart) => {\n\t\t\tconst value = part.capture(view)\n\t\t\tif (value !== undefined) (snapshot as unknown as Record<string, unknown>)[part.key] = value\n\t\t}\n\t\tfor (const part of parts) if (part.head) take(part)\n\t\tsnapshot.entities = entities\n\t\tsnapshot.players = players\n\t\tfor (const part of parts) if (!part.head) take(part)\n\t\treturn snapshot\n\t}\n\n\tsnapshot(): Snapshot {\n\t\treturn this.capture()\n\t}\n\n\t/**\n\t * Moves the game on by `ticks` at the next update, however fast it goes: a step of a paused game (`speed` 0), as\n\t * an editor's Step does. Ticks asked for while it runs are taken on top of its pace\n\t */\n\tadvance(ticks = 1): void {\n\t\tthis.accumulator += this.world.dt * Math.max(0, Math.floor(ticks))\n\t}\n\n\t/** A save of the world as it stands (`saveWorld`): at once, as a promise for what a session elsewhere answers later */\n\tsave(): Promise<WorldSave> {\n\t\ttry {\n\t\t\treturn Promise.resolve(saveWorld(this.world))\n\t\t} catch (error) {\n\t\t\treturn Promise.reject(error)\n\t\t}\n\t}\n\n\t/**\n\t * Runs the game on by itself, a tick at a time, as fast as the page can, until `until` holds of the world, `most`\n\t * ticks have run, the game is over, or `deadline` (`performance.now()`'s) is past: what an editor's \"Play to\" does a\n\t * slice a frame, its pace and `advance` aside. The ticks are the same ticks the game runs at its own pace, so the\n\t * same game comes to the same moment. What happened in them is in the next snapshot (`update`), as after a slow frame.\n\t * `until` is asked before the first tick too: what holds already runs none\n\t */\n\trunUntil(until: (world: World) => boolean, options: { most?: number; deadline?: number } = {}): { ticks: number; reached: boolean; over: boolean } {\n\t\tconst { world } = this\n\t\tconst most = options.most ?? Infinity\n\t\tconst deadline = options.deadline ?? Infinity\n\t\tlet ticks = 0\n\t\tconst over = () => world.failure !== null || world.winner !== null\n\t\twhile (!until(world)) {\n\t\t\tif (ticks >= most || over()) return this.ran(ticks, false, over())\n\t\t\t// the clock looked at every few ticks: a tick is a fraction of a millisecond, a look is not free\n\t\t\tif (ticks % 8 === 7 && performance.now() > deadline) return this.ran(ticks, false, false)\n\t\t\tthis.tickOnce()\n\t\t\tticks++\n\t\t}\n\t\treturn this.ran(ticks, true, over())\n\t}\n\n\t/** What `runUntil` gives back, the debug tools' view brought up to date where it ran */\n\tprivate ran(ticks: number, reached: boolean, over: boolean): { ticks: number; reached: boolean; over: boolean } {\n\t\tif (ticks) {\n\t\t\tthis.debug.refresh()\n\t\t\tthis.ranOn = true\n\t\t}\n\t\treturn { ticks, reached, over }\n\t}\n\n\t/** Whether `runUntil` ran ticks since the last update: its next snapshot describes them, paused or not */\n\tprivate ranOn = false\n\n\t/** A tick of the world, and the checkpoint it marked saved as the world stood at its end, not at the end of the frame */\n\tprivate tickOnce(): void {\n\t\tthis.world.step()\n\t\tif (this.pendingCheckpoint) {\n\t\t\tthis.checkpoint = { label: this.pendingCheckpoint, save: saveWorld(this.world) }\n\t\t\tthis.pendingCheckpoint = undefined\n\t\t}\n\t}\n\n\tupdate(dt: number): Snapshot[] {\n\t\tconst { world } = this\n\t\tlet stepped = this.ranOn\n\t\tthis.ranOn = false\n\t\t// slowed down or paused here (tests, tools), and by the game's speed (`debug.speed`)\n\t\tthis.accumulator += dt * this.speed * world.cheats.speed\n\t\twhile (this.accumulator >= world.dt) {\n\t\t\tthis.tickOnce()\n\t\t\tthis.accumulator -= world.dt\n\t\t\tstepped = true\n\t\t}\n\t\tthis.alpha = this.speed * world.cheats.speed > 0 ? this.accumulator / world.dt : 1\n\t\t// When a slow frame had several ticks to catch up on, only how things stand after the last one is described:\n\t\t// the client would throw the ones in between away. What happened in them is in the events, which pile up until then.\n\t\t// With no tick, what was said between ticks (talk, carried out at once: RV14) goes in a snapshot of the same tick\n\t\tif (!stepped) return this.view.events.length ? [this.capture()] : []\n\t\tthis.debug.refresh()\n\t\treturn [this.capture()]\n\t}\n\n\t/** Sends a command. `seq` is the sender's own number for it, for a host passing on what a remote player numbered */\n\tsend(command: PlayerCommand, seq = ++this.lastSeq): number {\n\t\t// the seat decides who is speaking, whatever the message claims\n\t\tthis.world.issue({ ...command, player: this.playerId, seq } as Parameters<World['issue']>[0])\n\t\treturn seq\n\t}\n\n\t/**\n\t * The number of the last command sent: a computer's seat keeps it through a save, so the commands it sends after a\n\t * load are numbered as they would have been\n\t *\n\t * @beta\n\t */\n\tlastSeq = 0\n\n\tfog(): FogState {\n\t\tconst { fog } = this.world\n\t\tconst cells = fog.cells(this.team)\n\t\treturn {\n\t\t\twidth: fog.width,\n\t\t\tdepth: fog.depth,\n\t\t\tversion: fog.version,\n\t\t\trevealed: this.observer || fog.isRevealed(this.team) || !cells,\n\t\t\tvisible: cells?.visible ?? new Uint8Array(0),\n\t\t\texplored: cells?.explored ?? new Uint8Array(0)\n\t\t}\n\t}\n\n\t/** Where the game's money is mined, as the map shows it, seen or not (`GameSession.mines`, `minesFor`) */\n\tmines(): readonly MineInfo[] {\n\t\treturn minesFor(this.view)\n\t}\n\n\t/** The lanes of the map, as the map shows them (`GameSession.lanes`) */\n\tlanes(): readonly Lane[] {\n\t\treturn lanesOf(this.world)\n\t}\n\n\t/** The camps as the player knows them (`GameSession.camps`, `campsFor`): worked out once a tick */\n\tcamps(): readonly CampInfo[] {\n\t\treturn campsFor(this.view)\n\t}\n\n\tcanPlace(unitType: string, point: Vec2): boolean {\n\t\treturn this.registry.units.has(unitType) && canPlaceStructure(this.world, this.registry.unit(unitType), point, this.playerId, true)\n\t}\n\n\t/** Which cells of a building's ground are in the way for the player: taken, or not explored by their team (`placementCells`) */\n\tplaceCells(unitType: string, point: Vec2): readonly boolean[] | undefined {\n\t\tif (!this.registry.units.has(unitType)) return undefined\n\t\tconst { world } = this\n\t\tconst { team } = world.player(this.playerId)\n\t\treturn placementCells(\n\t\t\tthis.registry.unit(unitType),\n\t\t\tpoint,\n\t\t\t(x, z) => world.grid.canPlace(x, z, 1, 1),\n\t\t\t(x, z) => world.fog.isExplored(team, x + 0.5, z + 0.5)\n\t\t)\n\t}\n\n\tfindPath(from: Vec2, to: Vec2, flying = false): Vec2[] | null {\n\t\treturn (flying ? this.world.air : this.world.nav).findPath(from, to)\n\t}\n\n\t/** What happened since the last snapshot, not yet given in one: a copy, for a computer's save */\n\tpendingEvents(): SessionEvent[] {\n\t\treturn structuredClone(this.view.events)\n\t}\n\n\t/** Takes back what `pendingEvents` gave, ahead of what has happened since: in a game loaded from a save */\n\trestoreEvents(events: readonly SessionEvent[]): void {\n\t\tthis.view.events = [...structuredClone(events), ...this.view.events]\n\t}\n\n\t/** Whether the world goes with the session */\n\tprivate readonly ownsWorld: boolean\n\n\tdispose(): void {\n\t\tfor (const dispose of this.disposers.splice(0)) dispose()\n\t\tthis.debug.dispose()\n\t\tif (this.ownsWorld) this.world.dispose()\n\t}\n}\n"],"mappings":";;;;;;;;;;AA+rBA,SAAgB,UAAqC,SAAwB,MAAkE;CAC9I,OAAO,QAAQ,SAAS;AACzB;;;;;;;;;AAgMA,IAAa,mBAAmB;;;;;;AAOhC,SAAgB,iBAAiB,MAAe,SAAA,IAA2C;CAC1F,OAAO,yDAAyD,OAAO,SAAS,WAAW,OAAO,UAAU,qBAAqB,OAAO;AACzI;;;;;;;;AASA,SAAgB,YAAY,MAAwE;CACnG,IAAI;CACJ,IAAI;EACH,UAAU,KAAK,MAAM,IAAI;CAC1B,QAAQ;EACP;CACD;CACA,IAAI,OAAO,YAAY,YAAY,YAAY,QAAQ,MAAM,QAAQ,OAAO,GAAG,OAAO,KAAA;CACtF,MAAM,EAAE,SAAS;CACjB,OAAO,OAAO,SAAS,WAAY,UAAyD,KAAA;AAC7F;;;;;;AAOA,IAAa,kBAAkB,UAAoC,OAAO,UAAU,YAAY,OAAO,SAAS,KAAK;;;;AC35BrH,SAAgB,OAAO,SAAwE;CAC9F,OAAO;EACN,IAAI,QAAQ;GACX,OAAO,QAAQ;EAChB;EACA,IAAI,MAAM,OAAe;GACxB,QAAQ,QAAQ;EACjB;EACA,UAAU,UAAU,QAAQ,QAAQ,KAAK;CAC1C;AACD;;AAGA,SAAgB,QAAQ,SAAkH;CACzI,OAAO;EACN,YAAY,QAAQ,KAAK;EACzB,IAAI,aAAa;GAChB,OAAO,QAAQ;EAChB;CACD;AACD;;;;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;EAChD,OAAO,KAAK,SAAS,MAAM,IAAI,QAAQ,KAAK,kBAAkB,KAAK,OAAO,KAAK,SAAS,KAAK,QAAQ,GAAG,OAAO,KAAK,UAAU,IAAI;CACnI;;CAGA,WAAW,UAAkB,OAA6C;EACzE,IAAI,CAAC,KAAK,SAAS,MAAM,IAAI,QAAQ,GAAG,OAAO,KAAA;EAC/C,MAAM,EAAE,UAAU;EAClB,MAAM,EAAE,SAAS,MAAM,OAAO,KAAK,QAAQ;EAC3C,OAAO,eACN,KAAK,SAAS,KAAK,QAAQ,GAC3B,QACC,GAAG,MAAM,MAAM,KAAK,SAAS,GAAG,GAAG,GAAG,CAAC,IACvC,GAAG,MAAM,MAAM,IAAI,WAAW,MAAM,IAAI,IAAK,IAAI,EAAG,CACtD;CACD;CAEA,SAAS,MAAY,IAAU,SAAS,OAAsB;EAC7D,QAAQ,SAAS,KAAK,MAAM,MAAM,KAAK,MAAM,IAAA,CAAK,SAAS,MAAM,EAAE;CACpE;;CAGA,gBAAgC;EAC/B,OAAO,gBAAgB,KAAK,KAAK,MAAM;CACxC;;CAGA,cAAc,QAAuC;EACpD,KAAK,KAAK,SAAS,CAAC,GAAG,gBAAgB,MAAM,GAAG,GAAG,KAAK,KAAK,MAAM;CACpE;;CAGA;CAEA,UAAgB;EACf,KAAK,MAAM,WAAW,KAAK,UAAU,OAAO,CAAC,GAAG,QAAQ;EACxD,KAAK,MAAM,QAAQ;EACnB,IAAI,KAAK,WAAW,KAAK,MAAM,QAAQ;CACxC;AACD"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"missionRules-C-bGxm0Q.js","names":[],"sources":["../src/mapObjectives.ts","../src/missionRules.ts"],"sourcesContent":["import type { PlayerId } from './entity'\nimport { defineHook } from './hooks'\nimport type { GameMap } from './map'\nimport type { MapProblem } from './mapFields'\nimport type { Message } from './messages'\nimport type { ObjectiveDef, ObjectiveState } from './objectives'\nimport type { GamePack } from './packs/pack'\nimport type { World } from './world'\n\n/*\n * Objectives as data on the map (campaign plan EQ3): a list kept in the map's data (`GameMap.data.objectives`), which\n * the editor's Objectives panel writes, and which the map objectives pack reads (`mapObjectives`): those given at the\n * start are each player's as the world is made from the map, the rest are given by the rules by id\n * (`giveMapObjective`). What becomes of them, done or failed, is the rules' as for any objective (`world.objectives`)\n */\n\n/**\n * The map objectives pack's id\n *\n * @beta\n */\nexport const MAP_OBJECTIVES = 'core.mapObjectives'\n\n/**\n * The key of the map's data its objectives are kept under (`GameMap.data.objectives`)\n *\n * @beta\n */\nexport const MAP_OBJECTIVES_KEY = 'objectives'\n\n/**\n * An objective a map gives, as it keeps it: an objective (`ObjectiveDef`: its id, its words, whether the mission needs\n * it, more about it) and when it is given\n *\n * @beta\n */\nexport interface MapObjective extends ObjectiveDef {\n\t/**\n\t * When it is given: as the game starts (`start`), to every player a person plays (`mapObjectivePlayers`), or when\n\t * the rules say (`rule`: `giveMapObjective(world, id)`). Anything but `rule` is the start\n\t */\n\tat: 'start' | 'rule'\n}\n\n/** The words of an objective as a file may hold them: a key, or a key with params */\nconst isWords = (text: unknown): boolean =>\n\ttypeof text === 'string'\n\t\t? text.trim() !== ''\n\t\t: typeof text === 'object' && text !== null && typeof (text as Message).key === 'string' && (text as Message).key !== ''\n\n/**\n * The objectives a map gives (`GameMap.data.objectives`), in the order it gives them: none for a map with none. What is\n * kept there and is no objective (no id, no words) is left out, so that a file changed by hand breaks no rule that reads\n * it; the map's checks say so (`mapObjectives`)\n *\n * @beta\n */\nexport function mapObjectivesOf(map: { readonly data: Readonly<Record<string, unknown>> }): MapObjective[] {\n\tconst kept = map.data[MAP_OBJECTIVES_KEY]\n\tif (!Array.isArray(kept)) return []\n\treturn kept\n\t\t.filter(\n\t\t\t(each): each is MapObjective => typeof each === 'object' && each !== null && typeof each.id === 'string' && each.id !== '' && isWords(each.text)\n\t\t)\n\t\t.map((each) => ({\n\t\t\tid: each.id,\n\t\t\ttext: each.text,\n\t\t\t...(each.detail !== undefined && isWords(each.detail) && { detail: each.detail }),\n\t\t\t...(each.required !== undefined && { required: each.required !== false }),\n\t\t\tat: each.at === 'rule' ? 'rule' : 'start'\n\t\t}))\n}\n\n/**\n * Who is given a map's objective when the rules do not say (`giveMapObjective`): the map's players a person plays, not\n * those it says the computer plays or nobody does (`MapPlayer.controller`), in the order of their ids\n *\n * @beta\n */\nexport function mapObjectivePlayers(world: World): PlayerId[] {\n\treturn [...world.players.values()]\n\t\t.filter((player) => !player.neutral && !player.creeps)\n\t\t.filter((player) => {\n\t\t\tconst controller = world.map.player(player.id)?.controller\n\t\t\treturn controller !== 'computer' && controller !== 'nobody'\n\t\t})\n\t\t.map((player) => player.id)\n\t\t.sort((a, b) => a - b)\n}\n\n/**\n * Gives players an objective of the map's, by its id (`MapObjective`): those given by a rule (`at: 'rule'`), when the\n * rules say. To every player a person plays when `players` is left out (`mapObjectivePlayers`); a player who has it\n * already keeps theirs. Its words' params and its progress go with it, as `world.objectives.add`. Throws for an id the\n * map does not have: an id in the code that is not on the map is a mistake\n *\n * @beta\n */\nexport function giveMapObjective(\n\tworld: World,\n\tid: string,\n\toptions: { players?: readonly PlayerId[]; params?: Message['params']; progress?: { value: number; max: number } } = {}\n): ObjectiveState[] {\n\tconst def = mapObjectivesOf(world.map).find((objective) => objective.id === id)\n\tif (!def) throw new Error(`The map${world.map.name ? ` \"${world.map.name}\"` : ''} has no objective \"${id}\"`)\n\tconst { at: _at, ...objective } = def\n\tconst given: ObjectiveState[] = []\n\tfor (const player of options.players ?? mapObjectivePlayers(world)) {\n\t\tif (world.objectives.has(player, id)) continue\n\t\tgiven.push(world.objectives.add(player, objective, { params: options.params, progress: options.progress }))\n\t}\n\treturn given\n}\n\n/**\n * What is wrong with a map's objectives (`GameMap.data.objectives`): one with no id or with another's, one with no\n * words, a list that is not one. Each a click away in the Objectives panel\n *\n * @beta\n */\nexport function checkMapObjectives(map: GameMap): MapProblem[] {\n\tconst kept = map.data[MAP_OBJECTIVES_KEY]\n\tif (kept === undefined) return []\n\tif (!Array.isArray(kept)) return [{ message: 'The map’s objectives are not a list', error: true, rule: 'objectives' }]\n\tconst problems: MapProblem[] = []\n\tconst seen = new Set<string>()\n\tkept.forEach((each: Partial<MapObjective> | null, index) => {\n\t\tconst id = typeof each?.id === 'string' ? each.id : ''\n\t\tconst reveal = { panel: 'objectives', entry: id || String(index) }\n\t\tif (!id) problems.push({ message: `Objective ${index + 1} has no id`, error: true, rule: 'objective-id', reveal })\n\t\telse if (seen.has(id)) problems.push({ message: `Two objectives have the id \"${id}\"`, error: true, rule: 'objective-id', reveal })\n\t\tseen.add(id)\n\t\tif (!isWords(each?.text))\n\t\t\tproblems.push({ message: `The objective \"${id || index + 1}\" has no words`, error: true, rule: 'objective-text', reveal })\n\t})\n\treturn problems\n}\n\n/**\n * Objectives as data on the map (campaign plan EQ3): a map's objectives (`MapObjective`, kept in `GameMap.data.objectives`,\n * written by the editor's Objectives panel) given at the start to every player a person plays, as the world is made\n * from the map; those given by a rule wait for the rules (`giveMapObjective(world, id)`). Done and failed as any\n * objective is (`world.objectives.complete`, `fail`); a game that is won by them has `objectiveVictory` as its\n * `victory`. The map's checks say what is wrong with them (`checkMapObjectives`)\n *\n * @beta\n */\nexport function mapObjectives(): GamePack {\n\tconst atStart = defineHook({\n\t\thook: 'mapStart',\n\t\tid: MAP_OBJECTIVES,\n\t\trun(world) {\n\t\t\tfor (const objective of mapObjectivesOf(world.map)) if (objective.at === 'start') giveMapObjective(world, objective.id)\n\t\t}\n\t})\n\treturn { id: MAP_OBJECTIVES, hooks: [atStart], check: (map) => checkMapObjectives(map) }\n}\n","import type { AiConditionData } from './ai/rules'\nimport { playCinematic } from './cinematics'\nimport { defineComponent } from './components'\nimport type { PlayerId } from './entity'\nimport { gameOver } from './engineEvents'\nimport { defineEvent } from './events'\nimport type { GameMap } from './map'\nimport type { MapProblem } from './mapFields'\nimport { giveMapObjective, mapObjectivePlayers, mapObjectivesOf } from './mapObjectives'\nimport type { Vec2 } from './math'\nimport type { MessageRef } from './messages'\nimport type { GamePack } from './packs/pack'\nimport type { Registry, System } from './registry'\nimport { defeat } from './systems/victory'\nimport { defineTimer } from './timers'\nimport type { PlayerRelation, World } from './world'\n\n/*\n * Mission rules as data (campaign plan MS1): what a mission scripts without code, kept on the map (`GameMap.data.rules`),\n * written in the editor's Rules panel, and run by the mission rules pack (`missionRules` of `@v12-engine/engine/ai`, where the\n * computer players' kit it asks the conditions of lives: `ai/missionRules.ts`). A rule is `when` a\n * condition of the computer players' language (`AiConditionData`, `docs/ai.md`: the hero nears the camp, a region has\n * units in it, an objective is done, a word was told, so many seconds went by) and `do` a list of actions from a closed\n * set: give, complete or fail an objective of the map's, say a line, play a cinematic, spawn a prefab, tell a computer\n * player a word, set what two players are to each other, start a timer, win, lose. No variables and no code by name:\n * what needs code is a pack of the game's, which the rules reach through the words they are told (`tellRules`) and\n * the event each firing is (`ruleFired`).\n *\n * The conditions are asked of a watcher: a brain with no modules of its own, seated at the player the rule is `as`\n * (the first person playing when it says none), which sees the whole map (an observer's session) and reads it as a\n * computer player does (`Brain.view`, `knowledge`), once a second. So `{ units: { of: 'enemy' } }` means that\n * player's enemies, and every form of the table in `docs/ai.md` works as it does for a brain. A rule fires as its\n * condition turns true, once (`once`) or each time, or again every so many seconds while it holds (`every`), as a\n * brain's rules do. What the rules remember (whether each held, when and how often it fired, the words told and not yet\n * heard, the timers started) is in the world's state, and the watchers' memory in the system's: a save mid-mission has\n * it all, and a game loaded from one goes on where it was\n */\n\n/**\n * The mission rules pack's id\n *\n * @beta\n */\nexport const MISSION_RULES = 'core.missionRules'\n\n/**\n * The key of the map's data its rules are kept under (`GameMap.data.rules`)\n *\n * @beta\n */\nexport const MAP_RULES_KEY = 'rules'\n\n/**\n * What a mission rule does, as plain data: one of a closed set of actions. Each takes who it is for (`to`) where that\n * matters: every player a person plays when left out (`mapObjectivePlayers`), as the map's objectives are given\n *\n * @beta\n */\nexport type MissionActionData =\n\t/** An objective of the map's (`MapObjective`), by id: given (`give`, the default), done or failed (with why) */\n\t| { objective: { id: string; do?: 'give' | 'complete' | 'fail'; to?: PlayerId[]; reason?: MessageRef } }\n\t/** A line said (`world.dialog.say`): who speaks (a speaker of the view's), what (a message key, or the words), for how long */\n\t| { say: { speaker: string; text: MessageRef; seconds?: number; to?: PlayerId[] } }\n\t/** A cinematic of the view's played (`playCinematic`), to everyone when `to` is left out */\n\t| { cinematic: { id: string; to?: PlayerId[]; hold?: boolean; skippable?: boolean } }\n\t/**\n\t * A prefab of the game's spawned (`world.spawnPrefab`) at a place: a point or a region of the map by name, a named\n\t * thing of the map, or a point; for a player, or neutral\n\t */\n\t| { spawn: { prefab: string; at: string | Vec2; owner?: PlayerId; facing?: number } }\n\t/** A word told to a computer player (`world.computers.tell`), with what goes with it */\n\t| { tell: { computer: PlayerId; word: string; data?: unknown } }\n\t/** What two players are to each other from now on (`world.sides.setRelation`) */\n\t| { relation: { a: PlayerId; b: PlayerId; how: PlayerRelation } }\n\t/**\n\t * A timer started: so many seconds on, the rules are told its id as a word (a rule `when: { told: id }` fires), and\n\t * with `label` it counts down on the players' screens meanwhile (`world.timers.show`). Started again, it starts over\n\t */\n\t| { timer: { id: string; seconds: number; label?: MessageRef; to?: PlayerId[] } }\n\t/** The game is won by the players' team */\n\t| { win: true | { to?: PlayerId[] } }\n\t/** The players are out of the game (`defeat`) */\n\t| { lose: true | { to?: PlayerId[] } }\n\n/**\n * A rule of a mission, as the map keeps it and the mission rules pack runs it: `when` a condition of the computer\n * players' language holds, `do` its actions. Fires as the condition turns true; `once` the first time only, ever; with\n * `every`, again while it holds, at most so often. Asked `as` a player: whose the units of `of: 'mine'` are, whose\n * objectives `{ objective }` reads; the first player a person plays when left out\n *\n * @beta\n */\nexport interface MissionRule {\n\t/** What the log, the checks and the editor know it by; no two the same */\n\tid: string\n\t/** When it fires: plain data (`docs/ai.md`, \"Conditions\") */\n\twhen: AiConditionData\n\t/** What it does, in order */\n\tdo: MissionActionData[]\n\t/** The first time only, ever */\n\tonce?: boolean\n\t/** Seconds: fired again while its condition holds, at most so often */\n\tevery?: number\n\t/** The player the condition is asked for */\n\tas?: PlayerId\n}\n\n/** What the rules remember of one rule, in the world's state */\ninterface RuleMemory {\n\t/** Whether its condition held at the last check: a rule fires as it turns true */\n\twas?: boolean\n\t/** The tick it last fired at */\n\tfired?: number\n\t/** How many times it fired */\n\tcount: number\n}\n\n/** A word the rules were told and have not heard yet */\ninterface ToldWord {\n\tword: string\n\tdata?: unknown\n\ttick: number\n}\n\n/** What the rules keep in the world: plain data, into a save */\ninterface RulesState {\n\trules: Record<string, RuleMemory>\n\ttold: ToldWord[]\n\t/** The timers the rules started and have not heard yet, by their id in the rules, as the world numbers them */\n\ttimers: Record<string, number>\n}\n\n/**\n * What the mission rules remember: in the world's state, so that a save has it\n *\n * @internal\n */\nexport const missionRulesState = defineComponent<RulesState>('core.missionRules', { default: () => ({ rules: {}, told: [], timers: {} }) })\n\n/**\n * A mission rule fired: its id. For a pack of the game's that does what the rules cannot\n *\n * @beta\n */\nexport const ruleFired = defineEvent<{ rule: string }>('core.ruleFired')\n\n/**\n * What a mission rule is now, for the report and the tests: whether its condition held at the last check, how often it\n * fired and when it last did\n *\n * @beta\n */\nexport interface MissionRuleState {\n\tholds: boolean\n\tcount: number\n\tfired?: number\n}\n\nconst ACTIONS = ['objective', 'say', 'cinematic', 'spawn', 'tell', 'relation', 'timer', 'win', 'lose'] as const\n\n/** The form of an action, by its one key: none for data that is no action */\nconst actionKind = (action: unknown): (typeof ACTIONS)[number] | undefined => {\n\tif (typeof action !== 'object' || action === null) return undefined\n\tconst keys = Object.keys(action)\n\treturn keys.length === 1 && (ACTIONS as readonly string[]).includes(keys[0]) ? (keys[0] as (typeof ACTIONS)[number]) : undefined\n}\n\n/** Whether data is a rule's condition: an object of one form */\nconst isCondition = (when: unknown): when is AiConditionData => typeof when === 'object' && when !== null && Object.keys(when).length > 0\n\n/**\n * The rules a map keeps (`GameMap.data.rules`), in their order: none for a map with none. What is kept there and is no\n * rule (no id, no condition) is left out, so that a file changed by hand breaks no game that reads it; the map's checks\n * say so (`checkMissionRules`). Actions that are of no form the pack knows are left out of a rule the same way\n *\n * @beta\n */\nexport function missionRulesOf(map: { readonly data: Readonly<Record<string, unknown>> }): MissionRule[] {\n\tconst kept = map.data[MAP_RULES_KEY]\n\tif (!Array.isArray(kept)) return []\n\treturn kept\n\t\t.filter(\n\t\t\t(each): each is MissionRule =>\n\t\t\t\ttypeof each === 'object' && each !== null && typeof each.id === 'string' && each.id !== '' && isCondition(each.when)\n\t\t)\n\t\t.map((each) => ({\n\t\t\tid: each.id,\n\t\t\twhen: each.when,\n\t\t\tdo: Array.isArray(each.do) ? each.do.filter((action) => actionKind(action) !== undefined) : [],\n\t\t\t...(each.once !== undefined && { once: each.once === true }),\n\t\t\t...(typeof each.every === 'number' && each.every > 0 && { every: each.every }),\n\t\t\t...(typeof each.as === 'number' && { as: each.as })\n\t\t}))\n}\n\n/**\n * Tells the mission rules a word, as the game's code does for what the rules cannot know on their own (the boss fell,\n * the player chose): a rule `when: { told: word }` fires at the next check, and the word is heard no more after it.\n * What a rule's timer does as it goes off\n *\n * @beta\n */\nexport function tellRules(world: World, word: string, data?: unknown): void {\n\tworld.state(missionRulesState).told.push({ word, ...(data !== undefined && { data }), tick: world.tick })\n}\n\n/**\n * What a mission rule is now (`MissionRuleState`): none for a rule the world has not, or has not checked yet\n *\n * @beta\n */\nexport function missionRuleState(world: World, id: string): MissionRuleState | undefined {\n\tif (!world.states.has(missionRulesState)) return undefined\n\tconst kept = world.state(missionRulesState).rules[id]\n\treturn kept && { holds: !!kept.was, count: kept.count, ...(kept.fired !== undefined && { fired: kept.fired }) }\n}\n\n/** The names of the regions a condition asks about, wherever it is in it */\nfunction regionsNamed(when: unknown, out: string[] = []): string[] {\n\tif (typeof when !== 'object' || when === null) return out\n\tconst condition = when as Record<string, unknown>\n\tif ('region' in condition && typeof (condition.region as { name?: unknown })?.name === 'string')\n\t\tout.push((condition.region as { name: string }).name)\n\tfor (const key of ['all', 'any'] as const)\n\t\tif (Array.isArray(condition[key])) for (const each of condition[key] as unknown[]) regionsNamed(each, out)\n\tif ('not' in condition) regionsNamed(condition.not, out)\n\treturn out\n}\n\n/**\n * What is wrong with a map's rules (`GameMap.data.rules`): one with no id or with another's, one with no condition, an\n * action of no form the pack knows, a condition or an action naming what the map or the game has not (a region, an\n * objective, a prefab, a player). Each a click away in the Rules panel\n *\n * @beta\n */\nexport function checkMissionRules(map: GameMap, registry?: Registry): MapProblem[] {\n\tconst kept = map.data[MAP_RULES_KEY]\n\tif (kept === undefined) return []\n\tif (!Array.isArray(kept)) return [{ message: 'The map’s rules are not a list', error: true, rule: 'rules' }]\n\tconst problems: MapProblem[] = []\n\tconst seen = new Set<string>()\n\tconst regions = new Set(map.regions.map((region) => region.name))\n\tconst objectives = new Set(mapObjectivesOf(map).map((objective) => objective.id))\n\tconst players = new Set(map.players.map((player) => player.id))\n\tkept.forEach((each: Partial<MissionRule> | null, index) => {\n\t\tconst id = typeof each?.id === 'string' ? each.id : ''\n\t\tconst name = id || String(index + 1)\n\t\tconst reveal = { panel: 'rules', entry: id || String(index) }\n\t\tconst problem = (message: string, rule: string, error = true) => problems.push({ message, error, rule, reveal })\n\t\tif (!id) problem(`Rule ${index + 1} has no id`, 'rule-id')\n\t\telse if (seen.has(id)) problem(`Two rules have the id \"${id}\"`, 'rule-id')\n\t\tseen.add(id)\n\t\tif (!isCondition(each?.when)) problem(`The rule \"${name}\" has no condition`, 'rule-when')\n\t\telse\n\t\t\tfor (const region of regionsNamed(each!.when))\n\t\t\t\tif (!regions.has(region)) problem(`The rule \"${name}\" asks about a region \"${region}\" the map has not`, 'rule-name')\n\t\tif (each?.as !== undefined && !players.has(each.as)) problem(`The rule \"${name}\" is asked as a player ${each.as} the map has not`, 'rule-name')\n\t\tconst actions = Array.isArray(each?.do) ? each.do : []\n\t\tif (!actions.length) problem(`The rule \"${name}\" does nothing`, 'rule-action', false)\n\t\tfor (const action of actions as unknown[]) {\n\t\t\tconst kind = actionKind(action)\n\t\t\tif (!kind) {\n\t\t\t\tproblem(`The rule \"${name}\" has an action of no form the rules know (${Object.keys(action ?? {}).join(', ') || 'nothing'})`, 'rule-action')\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tconst data = (action as Record<string, Record<string, unknown>>)[kind]\n\t\t\tconst named = (player: unknown, what: string) => {\n\t\t\t\tif (typeof player === 'number' && !players.has(player)) problem(`The rule \"${name}\" ${what} a player ${player} the map has not`, 'rule-name')\n\t\t\t}\n\t\t\tif (kind === 'objective' && !objectives.has(String(data?.id ?? '')))\n\t\t\t\tproblem(`The rule \"${name}\" names an objective \"${data?.id ?? ''}\" the map has not`, 'rule-name')\n\t\t\tif (kind === 'spawn' && registry && !registry.prefabs.has(String(data?.prefab ?? '')))\n\t\t\t\tproblem(`The rule \"${name}\" spawns a prefab \"${data?.prefab ?? ''}\" the game has not`, 'rule-name')\n\t\t\tif (kind === 'spawn' && typeof data?.at === 'string' && !placeNamed(map, data.at))\n\t\t\t\tproblem(`The rule \"${name}\" spawns at \"${data.at}\", which the map has not`, 'rule-name')\n\t\t\tif (kind === 'spawn') named(data?.owner, 'spawns for')\n\t\t\tif (kind === 'tell') named(data?.computer, 'tells')\n\t\t\tif (kind === 'relation') {\n\t\t\t\tnamed(data?.a, 'sets')\n\t\t\t\tnamed(data?.b, 'sets')\n\t\t\t}\n\t\t\tif (typeof data === 'object' && data !== null && Array.isArray(data.to)) for (const player of data.to) named(player, 'is for')\n\t\t}\n\t})\n\treturn problems\n}\n\n/** Whether a map has a place of this name: a point, a region, or something placed and named */\nconst placeNamed = (map: GameMap, name: string): boolean =>\n\tmap.points.some((point) => point.name === name) ||\n\tmap.regions.some((region) => region.name === name) ||\n\tmap.objects.some((object) => object.name === name)\n\n/** Where a place is in the world: a point or a region of the map by name, a named thing, or the point given */\nfunction placeOf(world: World, at: string | Vec2): Vec2 | undefined {\n\tif (typeof at !== 'string') return { x: at.x, z: at.z }\n\tconst point = world.map.points.find((each) => each.name === at)\n\tif (point) return { x: point.x, z: point.z }\n\tconst region = world.map.regions.find((each) => each.name === at)\n\tif (region) return { x: region.shape.x, z: region.shape.z }\n\tconst named = world.named(at)\n\treturn named && { x: named.pos.x, z: named.pos.z }\n}\n\n/**\n * The players a rule's actions are for when they say none: the people, else everyone who can win or lose\n *\n * @internal\n */\nexport function rulePlayers(world: World): PlayerId[] {\n\tconst people = mapObjectivePlayers(world)\n\tif (people.length) return people\n\treturn [...world.players.values()]\n\t\t.filter((player) => !player.neutral && !player.creeps)\n\t\t.map((player) => player.id)\n\t\t.sort((a, b) => a - b)\n}\n\n/**\n * The timer of a rule's `timer` action: as it goes off, the rules are told its id, and the screens stop counting it\n *\n * @internal\n */\nexport const ruleTimer = defineTimer<{ word: string; to?: PlayerId[] }>('core.missionRules.timer', (world, { word, to }, timer) => {\n\tconst state = world.state(missionRulesState)\n\tif (state.timers[word] === timer.id) delete state.timers[word]\n\tfor (const player of to ?? []) world.timers.hide(player, timer.id)\n\ttellRules(world, word)\n})\n\n/**\n * Does one action of a rule, now\n *\n * @internal\n */\nexport function doMissionAction(world: World, rule: MissionRule, action: MissionActionData): void {\n\tconst warn = (line: string) => world.log.warn('rules', `the rule \"${rule.id}\" ${line}`)\n\tconst people = rulePlayers(world)\n\tif ('objective' in action) {\n\t\tconst { id, do: what = 'give', to = people, reason } = action.objective\n\t\tif (what === 'give') {\n\t\t\tif (!mapObjectivesOf(world.map).some((objective) => objective.id === id)) return warn(`gives an objective \"${id}\" the map has not`)\n\t\t\tgiveMapObjective(world, id, { players: to })\n\t\t} else\n\t\t\tfor (const player of to)\n\t\t\t\tif (world.objectives.has(player, id)) what === 'complete' ? world.objectives.complete(player, id) : world.objectives.fail(player, id, reason)\n\t} else if ('say' in action) {\n\t\tconst { speaker, text, seconds, to = people } = action.say\n\t\tworld.dialog.say(to, { speaker, text, ...(seconds !== undefined && { seconds }) })\n\t} else if ('cinematic' in action) {\n\t\tconst { id, to, hold, skippable } = action.cinematic\n\t\tplayCinematic(world, id, { to: to ?? 'everyone', hold, skippable })\n\t} else if ('spawn' in action) {\n\t\tconst { prefab, at, owner, facing } = action.spawn\n\t\tif (!world.registry.prefabs.has(prefab)) return warn(`spawns a prefab \"${prefab}\" the game has not`)\n\t\tconst place = placeOf(world, at)\n\t\tif (!place) return warn(`spawns at \"${String(at)}\", which the map has not`)\n\t\tworld.spawnPrefab(prefab, { at: place, owner, facing })\n\t} else if ('tell' in action) {\n\t\tconst { computer, word, data } = action.tell\n\t\tif (!world.computers.tell(computer, word, data)) warn(`tells player ${computer} \"${word}\", and the computer does not play them`)\n\t} else if ('relation' in action) {\n\t\tconst { a, b, how } = action.relation\n\t\tworld.sides.setRelation(a, b, how)\n\t} else if ('timer' in action) {\n\t\tconst { id, seconds, label, to = people } = action.timer\n\t\tconst state = world.state(missionRulesState)\n\t\tif (state.timers[id] !== undefined) world.timers.cancel(state.timers[id])\n\t\tconst shown = label === undefined ? [] : to\n\t\tconst timer = world.timers.after(seconds, ruleTimer, { word: id, ...(shown.length && { to: shown }) })\n\t\tstate.timers[id] = timer\n\t\tfor (const player of shown) world.timers.show(player, timer, { label: label! })\n\t} else if ('win' in action) {\n\t\tconst to = action.win === true ? people : (action.win.to ?? people)\n\t\tif (world.winner !== null || !to.length) return\n\t\tconst team = world.player(to[0]).team\n\t\tworld.winner = team\n\t\tworld.events.emit(gameOver, { winner: team })\n\t} else if ('lose' in action) {\n\t\tconst to = action.lose === true ? people : (action.lose.to ?? people)\n\t\tfor (const player of to) if (!world.player(player).defeated) defeat(world, player)\n\t}\n}\n\n/**\n * What a rule's condition is asked of: a watcher seated as a player, which reads the game as a computer player does\n * (`ai/computer.ts`'s `ruleWatcher`: a brain with no modules of its own, on an observer's session). The engine itself\n * carries none of the computer players' kit, so the pack that runs the rules is the kit's (`missionRules` of\n * `@v12-engine/engine/ai`), and hands this to `missionRulesPack`\n *\n * @internal\n */\nexport interface RulesWatcher {\n\t/** Reads the picture of the game anew */\n\tthink(): void\n\t/** Whether a condition holds for it now */\n\task(condition: AiConditionData): boolean\n\t/** A word told to the rules, for `{ told }` to see */\n\ttell(word: string, data: unknown, tick: number): void\n\t/** The word heard: taken, it is seen no more */\n\ttakeTold(word: string): void\n\t/** What it remembers, for a save, and back */\n\tsave(): unknown\n\trestore(memory: unknown): void\n}\n\n/**\n * The system that runs the rules: once a second, each watcher reads the picture, the words told since the last check\n * are heard, and each rule's condition is asked and its actions done as it turns true. The watchers' memory is the\n * system's to save\n */\nfunction rulesSystem(world: World, own: readonly MissionRule[], watch: (world: World, player: PlayerId) => RulesWatcher): System {\n\t// the map's rules and the code's, read as the first check comes: the system is made before the world has its map\n\tlet read: MissionRule[] | undefined\n\tconst rulesOf = (): MissionRule[] => {\n\t\tif (read) return read\n\t\tread = []\n\t\tconst ids = new Set<string>()\n\t\tfor (const rule of [...missionRulesOf(world.map), ...own]) {\n\t\t\tif (ids.has(rule.id)) {\n\t\t\t\tworld.log.warn('rules', `two rules are called \"${rule.id}\": the second is left out`)\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tids.add(rule.id)\n\t\t\tread.push(rule)\n\t\t}\n\t\treturn read\n\t}\n\tconst watchers = new Map<PlayerId, RulesWatcher>()\n\tlet restored: Record<string, unknown> | undefined\n\tconst defaultPlayer = (): PlayerId | undefined => rulePlayers(world)[0]\n\tconst watcher = (player: PlayerId): RulesWatcher | undefined => {\n\t\tlet made = watchers.get(player)\n\t\tif (made) return made\n\t\tif (!world.players.has(player)) return undefined\n\t\tmade = watch(world, player)\n\t\tconst memory = restored?.[player]\n\t\tif (memory !== undefined) made.restore(memory)\n\t\twatchers.set(player, made)\n\t\treturn made\n\t}\n\treturn {\n\t\tname: 'missionRules',\n\t\tphase: 'cleanup',\n\t\tevery: Math.max(1, Math.round(world.tickRate)),\n\t\toffset: 3,\n\t\tupdate() {\n\t\t\tconst rules = rulesOf()\n\t\t\tif (!rules.length) return\n\t\t\tconst state = world.state(missionRulesState)\n\t\t\t// the words told since the last check: heard by every watcher this once\n\t\t\tconst told = state.told.splice(0)\n\t\t\tconst asked = new Set<PlayerId>()\n\t\t\tfor (const rule of rules) {\n\t\t\t\tconst player = rule.as ?? defaultPlayer()\n\t\t\t\tif (player !== undefined) asked.add(player)\n\t\t\t}\n\t\t\tfor (const player of asked) {\n\t\t\t\tconst made = watcher(player)\n\t\t\t\tif (!made) continue\n\t\t\t\tmade.think()\n\t\t\t\tfor (const word of told) made.tell(word.word, word.data, word.tick)\n\t\t\t}\n\t\t\tfor (const rule of rules) {\n\t\t\t\tconst kept = (state.rules[rule.id] ??= { count: 0 })\n\t\t\t\tif (rule.once && kept.count > 0) continue\n\t\t\t\tconst player = rule.as ?? defaultPlayer()\n\t\t\t\tconst made = player === undefined ? undefined : watcher(player)\n\t\t\t\tif (!made) {\n\t\t\t\t\tif (kept.was === undefined)\n\t\t\t\t\t\tworld.log.warn('rules', `the rule \"${rule.id}\" is asked as a player ${player} the world has not: it never fires`)\n\t\t\t\t\tkept.was = false\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tconst holds = made.ask(rule.when)\n\t\t\t\tconst turned = holds && !kept.was\n\t\t\t\tkept.was = holds\n\t\t\t\tif (!holds) continue\n\t\t\t\tconst again = rule.every !== undefined && kept.fired !== undefined && world.tick - kept.fired >= Math.round(rule.every * world.tickRate)\n\t\t\t\tif (!turned && !again) continue\n\t\t\t\tkept.fired = world.tick\n\t\t\t\tkept.count++\n\t\t\t\tworld.log.info('rules', `the rule \"${rule.id}\" fires`)\n\t\t\t\tworld.events.emit(ruleFired, { rule: rule.id })\n\t\t\t\tfor (const action of rule.do) doMissionAction(world, rule, action)\n\t\t\t}\n\t\t\tfor (const made of watchers.values()) for (const word of new Set(told.map((each) => each.word))) made.takeTold(word)\n\t\t},\n\t\tsave: () => ({ watchers: Object.fromEntries([...watchers].map(([player, made]) => [player, made.save()])) }),\n\t\trestore: (_world, data) => {\n\t\t\trestored = (data as { watchers?: Record<string, unknown> } | undefined)?.watchers\n\t\t\tfor (const [player, made] of watchers) if (restored?.[player] !== undefined) made.restore(restored[player])\n\t\t}\n\t}\n}\n\n/**\n * The mission rules pack, given what asks a rule's condition (`RulesWatcher`): what `missionRules` of `@v12-engine/engine/ai`\n * makes, with a watcher of the computer players' kit. The map's rules and `rules` of the code's, run as the game plays\n *\n * @internal\n */\nexport function missionRulesPack(options: { rules?: MissionRule[]; watch: (world: World, player: PlayerId) => RulesWatcher }): GamePack {\n\tconst own = options.rules ?? []\n\treturn {\n\t\tid: MISSION_RULES,\n\t\tcomponents: [missionRulesState],\n\t\tevents: [ruleFired],\n\t\ttimers: [ruleTimer],\n\t\tsystems: [(world) => rulesSystem(world, own, options.watch)],\n\t\tcheck: (map, registry) => checkMissionRules(map, registry),\n\t\t...(own.length && { options: { rules: own.map((rule) => rule.id) } })\n\t}\n}\n"],"mappings":";;;;;;;AAqBA,IAAa,iBAAiB;;;;;;AAO9B,IAAa,qBAAqB;;AAiBlC,IAAM,WAAW,SAChB,OAAO,SAAS,WACb,KAAK,KAAK,MAAM,KAChB,OAAO,SAAS,YAAY,SAAS,QAAQ,OAAQ,KAAiB,QAAQ,YAAa,KAAiB,QAAQ;;;;;;;;AASxH,SAAgB,gBAAgB,KAA2E;CAC1G,MAAM,OAAO,IAAI,KAAK;CACtB,IAAI,CAAC,MAAM,QAAQ,IAAI,GAAG,OAAO,CAAC;CAClC,OAAO,KACL,QACC,SAA+B,OAAO,SAAS,YAAY,SAAS,QAAQ,OAAO,KAAK,OAAO,YAAY,KAAK,OAAO,MAAM,QAAQ,KAAK,IAAI,CAChJ,CAAC,CACA,KAAK,UAAU;EACf,IAAI,KAAK;EACT,MAAM,KAAK;EACX,GAAI,KAAK,WAAW,KAAA,KAAa,QAAQ,KAAK,MAAM,KAAK,EAAE,QAAQ,KAAK,OAAO;EAC/E,GAAI,KAAK,aAAa,KAAA,KAAa,EAAE,UAAU,KAAK,aAAa,MAAM;EACvE,IAAI,KAAK,OAAO,SAAS,SAAS;CACnC,EAAE;AACJ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SAAS,EAAE,UAAU,YAAY,OAAO,KAAK,QAAQ,KAAK,CAAC;EAC3D,QAAQ,KAAK,aAAa,kBAAkB,KAAK,QAAQ;EACzD,GAAI,IAAI,UAAU,EAAE,SAAS,EAAE,OAAO,IAAI,KAAK,SAAS,KAAK,EAAE,EAAE,EAAE;CACpE;AACD"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"navigation-worker.js","names":[],"sources":["../src/server/navigation-worker.ts"],"sourcesContent":["/**\n * A worker thread of a server's that builds navigations (S37): told what to build, it sends back what it built. Built\n * next to `server.js`, and not one of the engine's names: `nodeNavigationBuilder` starts it\n */\nimport { parentPort } from 'node:worker_threads'\nimport { serveNavigationBuilds } from '#engine/navigation/builds'\n\nif (parentPort) serveNavigationBuilds(parentPort as never)\n"],"mappings":";;;;;;;AAOA,IAAI,YAAY,sBAAsB,UAAmB"}