@v12-engine/engine 0.0.0-stage → 0.1.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 (341) hide show
  1. package/LICENSE +21 -0
  2. package/dist/abilities/buffs.d.ts +83 -0
  3. package/dist/abilities/castTold.d.ts +12 -0
  4. package/dist/abilities/charges.d.ts +28 -0
  5. package/dist/abilities/dispel.d.ts +9 -0
  6. package/dist/abilities/effectFields.d.ts +10 -0
  7. package/dist/abilities/effects/buff.d.ts +8 -0
  8. package/dist/abilities/effects/core.d.ts +1 -0
  9. package/dist/abilities/effects/damage.d.ts +1 -0
  10. package/dist/abilities/effects/heal.d.ts +2 -0
  11. package/dist/abilities/effects/missile.d.ts +1 -0
  12. package/dist/abilities/effects/moves.d.ts +11 -0
  13. package/dist/abilities/effects/passives.d.ts +15 -0
  14. package/dist/abilities/effects/sight.d.ts +4 -0
  15. package/dist/abilities/effects/spawn.d.ts +2 -0
  16. package/dist/abilities/effects/timed.d.ts +4 -0
  17. package/dist/abilities/effects/trade.d.ts +1 -0
  18. package/dist/abilities/effects.d.ts +122 -0
  19. package/dist/abilities/land.d.ts +21 -0
  20. package/dist/abilities/scaled.d.ts +21 -0
  21. package/dist/abilities/text.d.ts +113 -0
  22. package/dist/ai/area.d.ts +53 -0
  23. package/dist/ai/brain.d.ts +528 -0
  24. package/dist/ai/budget.d.ts +67 -0
  25. package/dist/ai/checks.d.ts +115 -0
  26. package/dist/ai/computer.d.ts +166 -0
  27. package/dist/ai/defence.d.ts +108 -0
  28. package/dist/ai/define.d.ts +21 -0
  29. package/dist/ai/economy.d.ts +129 -0
  30. package/dist/ai/geometry.d.ts +35 -0
  31. package/dist/ai/goals.d.ts +360 -0
  32. package/dist/ai/index.d.ts +38 -0
  33. package/dist/ai/knowledge.d.ts +418 -0
  34. package/dist/ai/lanes.d.ts +232 -0
  35. package/dist/ai/melee/build.d.ts +61 -0
  36. package/dist/ai/melee/goals.d.ts +299 -0
  37. package/dist/ai/melee/heroes.d.ts +27 -0
  38. package/dist/ai/melee/index.d.ts +14 -0
  39. package/dist/ai/melee/production.d.ts +8 -0
  40. package/dist/ai/melee/surrender.d.ts +24 -0
  41. package/dist/ai/micro.d.ts +278 -0
  42. package/dist/ai/mission.d.ts +195 -0
  43. package/dist/ai/missionRules.d.ts +18 -0
  44. package/dist/ai/module.d.ts +116 -0
  45. package/dist/ai/options.d.ts +61 -0
  46. package/dist/ai/plans/build.d.ts +280 -0
  47. package/dist/ai/plans/placement.d.ts +82 -0
  48. package/dist/ai/plans/plans.d.ts +105 -0
  49. package/dist/ai/plans/production.d.ts +210 -0
  50. package/dist/ai/plans/purse.d.ts +73 -0
  51. package/dist/ai/plans/tech.d.ts +37 -0
  52. package/dist/ai/profiles.d.ts +204 -0
  53. package/dist/ai/reach.d.ts +4 -0
  54. package/dist/ai/report.d.ts +203 -0
  55. package/dist/ai/roles.d.ts +133 -0
  56. package/dist/ai/rules.d.ts +288 -0
  57. package/dist/ai/scouting.d.ts +98 -0
  58. package/dist/ai/settings.d.ts +73 -0
  59. package/dist/ai/squads.d.ts +429 -0
  60. package/dist/ai/strength.d.ts +167 -0
  61. package/dist/ai/task.d.ts +118 -0
  62. package/dist/ai/tasks/attack.d.ts +7 -0
  63. package/dist/ai/tasks/capture.d.ts +21 -0
  64. package/dist/ai/tasks/creep.d.ts +16 -0
  65. package/dist/ai/tasks/defend.d.ts +29 -0
  66. package/dist/ai/tasks/drop.d.ts +34 -0
  67. package/dist/ai/tasks/escort.d.ts +16 -0
  68. package/dist/ai/tasks/gather.d.ts +23 -0
  69. package/dist/ai/tasks/harass.d.ts +7 -0
  70. package/dist/ai/tasks/hold.d.ts +20 -0
  71. package/dist/ai/tasks/index.d.ts +32 -0
  72. package/dist/ai/tasks/move.d.ts +19 -0
  73. package/dist/ai/tasks/patrol.d.ts +8 -0
  74. package/dist/ai/tasks/retreat.d.ts +20 -0
  75. package/dist/ai/tasks/scout.d.ts +29 -0
  76. package/dist/ai/tasks/shared.d.ts +74 -0
  77. package/dist/ai/team.d.ts +155 -0
  78. package/dist/ai/threat.d.ts +91 -0
  79. package/dist/ai/view.d.ts +366 -0
  80. package/dist/ai/waves.d.ts +126 -0
  81. package/dist/ai.js +6239 -0
  82. package/dist/ai.js.map +1 -0
  83. package/dist/aiTesting.d.ts +179 -0
  84. package/dist/areas.d.ts +149 -0
  85. package/dist/attacks.d.ts +66 -0
  86. package/dist/attributes.d.ts +66 -0
  87. package/dist/brain-BvVdUhX8.js +7659 -0
  88. package/dist/brain-BvVdUhX8.js.map +1 -0
  89. package/dist/builds-C6LfgvEU.js +460 -0
  90. package/dist/builds-C6LfgvEU.js.map +1 -0
  91. package/dist/bytes.d.ts +6 -0
  92. package/dist/camps.d.ts +95 -0
  93. package/dist/capture.d.ts +131 -0
  94. package/dist/cellLayers.d.ts +75 -0
  95. package/dist/cinematics.d.ts +194 -0
  96. package/dist/clock.d.ts +32 -0
  97. package/dist/commands.d.ts +235 -0
  98. package/dist/components.d.ts +184 -0
  99. package/dist/computers.d.ts +108 -0
  100. package/dist/concealment.d.ts +61 -0
  101. package/dist/coreComponents-syuh2fPG.js +5149 -0
  102. package/dist/coreComponents-syuh2fPG.js.map +1 -0
  103. package/dist/coreComponents.d.ts +1 -0
  104. package/dist/dashing.d.ts +8 -0
  105. package/dist/debug.d.ts +36 -0
  106. package/dist/debug.js +3 -0
  107. package/dist/debugCommands-CzjrSm66.js +14739 -0
  108. package/dist/debugCommands-CzjrSm66.js.map +1 -0
  109. package/dist/debugCommands.d.ts +213 -0
  110. package/dist/debugging.d.ts +10 -0
  111. package/dist/definitions.d.ts +43 -0
  112. package/dist/defs.d.ts +1162 -0
  113. package/dist/denying.d.ts +81 -0
  114. package/dist/destructibles.d.ts +27 -0
  115. package/dist/determinism-BCymQwiE.js +518 -0
  116. package/dist/determinism-BCymQwiE.js.map +1 -0
  117. package/dist/determinism.d.ts +121 -0
  118. package/dist/dialog.d.ts +94 -0
  119. package/dist/effectRefs.d.ts +16 -0
  120. package/dist/effects.d.ts +80 -0
  121. package/dist/endings.d.ts +22 -0
  122. package/dist/engagement.d.ts +108 -0
  123. package/dist/engineEvents.d.ts +710 -0
  124. package/dist/entity.d.ts +409 -0
  125. package/dist/entityIndex.d.ts +50 -0
  126. package/dist/errors.d.ts +85 -0
  127. package/dist/events.d.ts +97 -0
  128. package/dist/exactMath.d.ts +63 -0
  129. package/dist/features.d.ts +10 -0
  130. package/dist/fields.d.ts +114 -0
  131. package/dist/fixture.d.ts +17 -0
  132. package/dist/fog.d.ts +110 -0
  133. package/dist/formation.d.ts +111 -0
  134. package/dist/friendlyFire.d.ts +26 -0
  135. package/dist/game-DiJEN-Ks.js +5800 -0
  136. package/dist/game-DiJEN-Ks.js.map +1 -0
  137. package/dist/game.d.ts +501 -0
  138. package/dist/gameData.d.ts +325 -0
  139. package/dist/gameFiles.d.ts +26 -0
  140. package/dist/gates.d.ts +28 -0
  141. package/dist/generate.d.ts +403 -0
  142. package/dist/generateWorker.d.ts +39 -0
  143. package/dist/grid.d.ts +53 -0
  144. package/dist/ground.d.ts +127 -0
  145. package/dist/groundSpeed.d.ts +22 -0
  146. package/dist/hero.d.ts +177 -0
  147. package/dist/home.d.ts +14 -0
  148. package/dist/hooks.d.ts +780 -0
  149. package/dist/hotReload.d.ts +76 -0
  150. package/dist/ids.d.ts +26 -0
  151. package/dist/index.d.ts +227 -0
  152. package/dist/index.js +4701 -0
  153. package/dist/index.js.map +1 -0
  154. package/dist/inspect-D9dWHmZ0.js +491 -0
  155. package/dist/inspect-D9dWHmZ0.js.map +1 -0
  156. package/dist/inspect.d.ts +176 -0
  157. package/dist/inventory.d.ts +18 -0
  158. package/dist/items.d.ts +91 -0
  159. package/dist/lanes.d.ts +213 -0
  160. package/dist/life.d.ts +53 -0
  161. package/dist/local-Dkovq42k.js +1379 -0
  162. package/dist/local-Dkovq42k.js.map +1 -0
  163. package/dist/log.d.ts +140 -0
  164. package/dist/manaBurn.d.ts +39 -0
  165. package/dist/map/file.d.ts +114 -0
  166. package/dist/map/images.d.ts +18 -0
  167. package/dist/map/look.d.ts +47 -0
  168. package/dist/map/pathProfile.d.ts +13 -0
  169. package/dist/map/resize.d.ts +54 -0
  170. package/dist/map/schema.d.ts +10 -0
  171. package/dist/map/terrain.d.ts +32 -0
  172. package/dist/map/types.d.ts +613 -0
  173. package/dist/map.d.ts +7 -0
  174. package/dist/mapCheck/cells.d.ts +19 -0
  175. package/dist/mapCheck/rule.d.ts +30 -0
  176. package/dist/mapCheck/rules/names.d.ts +3 -0
  177. package/dist/mapCheck/rules/objects.d.ts +3 -0
  178. package/dist/mapCheck/rules/paths.d.ts +3 -0
  179. package/dist/mapCheck/rules/players.d.ts +3 -0
  180. package/dist/mapCheck/rules/races.d.ts +3 -0
  181. package/dist/mapCheck/rules/random.d.ts +3 -0
  182. package/dist/mapCheck/rules/regions.d.ts +3 -0
  183. package/dist/mapCheck/rules/targets.d.ts +3 -0
  184. package/dist/mapCheck/rules/walking.d.ts +3 -0
  185. package/dist/mapCheck.d.ts +23 -0
  186. package/dist/mapFields.d.ts +364 -0
  187. package/dist/mapFile.d.ts +23 -0
  188. package/dist/mapMeasure.d.ts +95 -0
  189. package/dist/mapMerge.d.ts +19 -0
  190. package/dist/mapObjectives.d.ts +82 -0
  191. package/dist/mapObjects.d.ts +1 -0
  192. package/dist/math.d.ts +44 -0
  193. package/dist/messages.d.ts +150 -0
  194. package/dist/missionRules-C-bGxm0Q.js +523 -0
  195. package/dist/missionRules-C-bGxm0Q.js.map +1 -0
  196. package/dist/missionRules.d.ts +179 -0
  197. package/dist/mods.d.ts +146 -0
  198. package/dist/names.d.ts +93 -0
  199. package/dist/navigation/agentParams.d.ts +4 -0
  200. package/dist/navigation/air.d.ts +89 -0
  201. package/dist/navigation/builds.d.ts +140 -0
  202. package/dist/navigation/groundAreas.d.ts +23 -0
  203. package/dist/navigation/navigation.d.ts +127 -0
  204. package/dist/navigation/recast.d.ts +214 -0
  205. package/dist/navigation/sidePaths.d.ts +69 -0
  206. package/dist/navigation/sized.d.ts +1 -0
  207. package/dist/navigation-worker.js +11 -0
  208. package/dist/navigation-worker.js.map +1 -0
  209. package/dist/nearest.d.ts +8 -0
  210. package/dist/noise.d.ts +12 -0
  211. package/dist/objectives.d.ts +93 -0
  212. package/dist/orders/basic.d.ts +96 -0
  213. package/dist/orders/build.d.ts +91 -0
  214. package/dist/orders/cast.d.ts +105 -0
  215. package/dist/orders/facts.d.ts +14 -0
  216. package/dist/orders/harvest.d.ts +94 -0
  217. package/dist/orders/idle.d.ts +7 -0
  218. package/dist/orders/items.d.ts +14 -0
  219. package/dist/orders/queue.d.ts +24 -0
  220. package/dist/pack.schema.json +6621 -0
  221. package/dist/packs/director/index.d.ts +81 -0
  222. package/dist/packs/heroes/campaign.d.ts +137 -0
  223. package/dist/packs/heroes/carry.d.ts +59 -0
  224. package/dist/packs/heroes/commands.d.ts +6 -0
  225. package/dist/packs/heroes/hire.d.ts +9 -0
  226. package/dist/packs/heroes/index.d.ts +12 -0
  227. package/dist/packs/heroes/making.d.ts +16 -0
  228. package/dist/packs/heroes/respawn.d.ts +42 -0
  229. package/dist/packs/moba/index.d.ts +34 -0
  230. package/dist/packs/pack.d.ts +84 -0
  231. package/dist/packs-g5thvmGn.js +3199 -0
  232. package/dist/packs-g5thvmGn.js.map +1 -0
  233. package/dist/packs.d.ts +84 -0
  234. package/dist/paths.d.ts +51 -0
  235. package/dist/plain.d.ts +17 -0
  236. package/dist/player.d.ts +117 -0
  237. package/dist/portals.d.ts +66 -0
  238. package/dist/prefabs.d.ts +139 -0
  239. package/dist/presetBuildings.d.ts +52 -0
  240. package/dist/presetGround.d.ts +22 -0
  241. package/dist/profiles-B3NS9jwk.js +335 -0
  242. package/dist/profiles-B3NS9jwk.js.map +1 -0
  243. package/dist/races.d.ts +136 -0
  244. package/dist/randomGroups.d.ts +2 -0
  245. package/dist/registry.d.ts +464 -0
  246. package/dist/remains.d.ts +119 -0
  247. package/dist/replication.d.ts +103 -0
  248. package/dist/rng.d.ts +17 -0
  249. package/dist/rules.d.ts +395 -0
  250. package/dist/rulesCheck.d.ts +37 -0
  251. package/dist/runes.d.ts +41 -0
  252. package/dist/save.d.ts +277 -0
  253. package/dist/scenario.d.ts +56 -0
  254. package/dist/scheduler.d.ts +67 -0
  255. package/dist/score.d.ts +306 -0
  256. package/dist/sequences.d.ts +132 -0
  257. package/dist/server/doorman.d.ts +21 -0
  258. package/dist/server/gameServer.d.ts +346 -0
  259. package/dist/server/index.d.ts +24 -0
  260. package/dist/server/lobby.d.ts +1 -0
  261. package/dist/server/log.d.ts +13 -0
  262. package/dist/server/match.d.ts +24 -0
  263. package/dist/server/mode.d.ts +168 -0
  264. package/dist/server/navigation-worker.d.ts +1 -0
  265. package/dist/server/navigation.d.ts +11 -0
  266. package/dist/server/ops.d.ts +78 -0
  267. package/dist/server/packs.d.ts +15 -0
  268. package/dist/server/ratings.d.ts +62 -0
  269. package/dist/server/relay.d.ts +34 -0
  270. package/dist/server/rooms.d.ts +162 -0
  271. package/dist/server/seat.d.ts +2 -0
  272. package/dist/server/seatSettings.d.ts +15 -0
  273. package/dist/server/secret.d.ts +5 -0
  274. package/dist/server/start.d.ts +54 -0
  275. package/dist/server/websocket.d.ts +74 -0
  276. package/dist/server.js +2861 -0
  277. package/dist/server.js.map +1 -0
  278. package/dist/session/can.d.ts +20 -0
  279. package/dist/session/commandReplay.d.ts +92 -0
  280. package/dist/session/debug.d.ts +65 -0
  281. package/dist/session/delay.d.ts +15 -0
  282. package/dist/session/delta.d.ts +98 -0
  283. package/dist/session/entityState.d.ts +1 -0
  284. package/dist/session/local.d.ts +214 -0
  285. package/dist/session/memory.d.ts +27 -0
  286. package/dist/session/protocol.d.ts +1155 -0
  287. package/dist/session/remote.d.ts +530 -0
  288. package/dist/session/replay.d.ts +114 -0
  289. package/dist/session/seed.d.ts +7 -0
  290. package/dist/session/share.d.ts +78 -0
  291. package/dist/session/socket.d.ts +8 -0
  292. package/dist/session/wire.d.ts +153 -0
  293. package/dist/session/worker.d.ts +227 -0
  294. package/dist/shared.d.ts +171 -0
  295. package/dist/sides.d.ts +75 -0
  296. package/dist/sight.d.ts +27 -0
  297. package/dist/simulate-oXBiw1Ff.js +167 -0
  298. package/dist/simulate-oXBiw1Ff.js.map +1 -0
  299. package/dist/simulate-worker.d.ts +1 -0
  300. package/dist/simulate-worker.js +28 -0
  301. package/dist/simulate-worker.js.map +1 -0
  302. package/dist/simulate.d.ts +154 -0
  303. package/dist/smart.d.ts +9 -0
  304. package/dist/spatial.d.ts +62 -0
  305. package/dist/spawning.d.ts +33 -0
  306. package/dist/stances.d.ts +76 -0
  307. package/dist/start.d.ts +71 -0
  308. package/dist/stats.d.ts +122 -0
  309. package/dist/summons.d.ts +63 -0
  310. package/dist/systems/abilities.d.ts +3 -0
  311. package/dist/systems/combat.d.ts +71 -0
  312. package/dist/systems/combatTold.d.ts +14 -0
  313. package/dist/systems/construction.d.ts +34 -0
  314. package/dist/systems/economy.d.ts +21 -0
  315. package/dist/systems/fog.d.ts +19 -0
  316. package/dist/systems/life.d.ts +3 -0
  317. package/dist/systems/movement.d.ts +105 -0
  318. package/dist/systems/orders.d.ts +7 -0
  319. package/dist/systems/production.d.ts +49 -0
  320. package/dist/systems/productionQueue.d.ts +40 -0
  321. package/dist/systems/victory.d.ts +14 -0
  322. package/dist/talk.d.ts +65 -0
  323. package/dist/tech.d.ts +62 -0
  324. package/dist/techTree.d.ts +38 -0
  325. package/dist/terrain.d.ts +173 -0
  326. package/dist/terrainSave.d.ts +29 -0
  327. package/dist/testing.d.ts +58 -0
  328. package/dist/testing.js +822 -0
  329. package/dist/testing.js.map +1 -0
  330. package/dist/tiles.d.ts +34 -0
  331. package/dist/timers.d.ts +146 -0
  332. package/dist/tomes.d.ts +48 -0
  333. package/dist/trade.d.ts +28 -0
  334. package/dist/transport.d.ts +76 -0
  335. package/dist/tunables.d.ts +45 -0
  336. package/dist/upkeep.d.ts +16 -0
  337. package/dist/veterancy.d.ts +80 -0
  338. package/dist/walls.d.ts +86 -0
  339. package/dist/world.d.ts +1118 -0
  340. package/package.json +80 -5
  341. package/README.md +0 -3
@@ -0,0 +1,1155 @@
1
+ import type { SystemTiming } from '#engine/scheduler';
2
+ import type { DataKind, DataValues } from '#engine/gameData';
3
+ import type { Logger } from '#engine/log';
4
+ import type { Command, ModCommand } from '#engine/commands';
5
+ import type { ChatAudience, PingKind } from '#engine/talk';
6
+ import type { Cost, DamageType, ResourceKind, Stats } from '#engine/defs';
7
+ import type { PlayerId } from '#engine/entity';
8
+ import type { Vec2 } from '#engine/math';
9
+ import type { SaidLine } from '#engine/dialog';
10
+ import type { Message } from '#engine/messages';
11
+ import type { ObjectiveState, ObjectiveStatus } from '#engine/objectives';
12
+ import type { ShownTimer } from '#engine/timers';
13
+ import type { WorldSave } from '#engine/save';
14
+ import type { Registry } from '#engine/registry';
15
+ import type { Inspection, InspectTarget, LoggedEvent, WorldListing } from '#engine/inspect';
16
+ import type { Lane } from '#engine/lanes';
17
+ import type { MapCamera, MapDoodad, MapEnvironment, MapPath, MapRegion } from '#engine/map';
18
+ import type { Terrain } from '#engine/terrain';
19
+ import type { TerrainPatch } from '#engine/ground';
20
+ import type { MessageKind } from '#engine/world';
21
+ import type { ScoreLineState, ScoreState } from '#engine/score';
22
+ /**
23
+ * What travels between the simulation and a player's screen.
24
+ *
25
+ * A client never touches the world. It gets snapshots of what its player is allowed
26
+ * to know and sends commands back. Today both ends live in the same page, later the
27
+ * simulation runs on a server, and nothing on the client has to change for that.
28
+ * Everything in here is plain data for that reason: it has to survive being sent.
29
+ */
30
+ /** @beta */
31
+ export interface QueueItemState {
32
+ kind: 'unit' | 'upgrade' | 'revive' | 'morph';
33
+ id: string;
34
+ /** 0..1 */
35
+ progress: number;
36
+ }
37
+ /** @beta */
38
+ export interface AbilityInfo {
39
+ id: string;
40
+ level: number;
41
+ /** Seconds until it can be used again */
42
+ cooldown: number;
43
+ /** Uses left, of an ability with charges, while it holds fewer than it can (all of them when left out: `chargesLeft`) */
44
+ charges?: number;
45
+ /** Seconds until the next use is back, while it holds fewer than it can */
46
+ refill?: number;
47
+ autocast: boolean;
48
+ /**
49
+ * What the game's `canCast` hook decided, where it is not what the declared costs say: a reason it cannot be used
50
+ * now, or null for one it can be used for all that ("free while Clearcasting"). Left out when there is nothing to add
51
+ */
52
+ decided?: Message | null;
53
+ }
54
+ /**
55
+ * An ability of a unit as everyone who sees it may be told (`GameRules.hud.shareAbilities`): what it is and its
56
+ * level, and how much of its cooldown is left where the rules share that too
57
+ *
58
+ * @beta
59
+ */
60
+ export interface SharedAbility {
61
+ /** The ability's id */
62
+ id: string;
63
+ /** Its level: 1 and up, those not learned are not told */
64
+ level: number;
65
+ /**
66
+ * Seconds until it can be used again: with `shareAbilities: 'cooldowns'` alone. Whole seconds, rounded up, from a
67
+ * host (`quantize`): the plate counts down between
68
+ */
69
+ cooldown?: number;
70
+ }
71
+ /**
72
+ * Something a unit carries
73
+ *
74
+ * @beta
75
+ */
76
+ export interface CarriedItem {
77
+ /** Which one of the unit's items, for commands */
78
+ id: number;
79
+ item: string;
80
+ charges: number;
81
+ /** Seconds until it can be used again */
82
+ cooldown: number;
83
+ /**
84
+ * Uses left of the ability it casts, where that has charges (`AbilityDef.charges`) and holds fewer than it can: all
85
+ * of them when left out. None, and it cannot be used until one comes back
86
+ */
87
+ uses?: number;
88
+ }
89
+ /**
90
+ * What everyone who sees a unit is told of its items (`inventorySlots`' snapshot): what it carries; its owner and their
91
+ * allies the slots too, for commands
92
+ *
93
+ * @beta
94
+ */
95
+ export interface InventoryInfo {
96
+ /** The items it carries, by id: anyone who sees the unit sees that */
97
+ items: string[];
98
+ /** One entry per slot, null for the empty ones: for its owner and their allies */
99
+ slots?: (CarriedItem | null)[];
100
+ }
101
+ /**
102
+ * What a worker's owner and their allies are told of what it carries (`gathering`'s snapshot)
103
+ *
104
+ * @beta
105
+ */
106
+ export interface GatheringInfo {
107
+ /** How much of it */
108
+ carrying: number;
109
+ /** What it is that it carries, or last gathered. Null for a worker that has not gathered anything yet */
110
+ kind: ResourceKind | null;
111
+ }
112
+ /**
113
+ * What a building's owner and their allies are told of what it makes (`productionQueue`'s snapshot): its queue and where
114
+ * what comes out goes; and everyone who sees it, how far it is in turning into another type
115
+ *
116
+ * @beta
117
+ */
118
+ export interface ProductionInfo {
119
+ /** What it makes, the first being made: for its owner and their allies */
120
+ queue?: QueueItemState[];
121
+ /** Where what it makes goes once out: for its owner and their allies */
122
+ rally?: Vec2;
123
+ /** 0..1 while it turns into another type (`upgradeTo`, `UnitTypeDef.upgradesTo`): what every player who sees it sees */
124
+ upgrade?: number;
125
+ /** The type it turns into, while it does */
126
+ upgradeTo?: string;
127
+ }
128
+ /**
129
+ * An item lying on the ground
130
+ *
131
+ * @beta
132
+ */
133
+ export interface GroundItemState {
134
+ id: number;
135
+ item: string;
136
+ x: number;
137
+ z: number;
138
+ }
139
+ /** @beta */
140
+ export interface StockInfo {
141
+ item: string;
142
+ /** How many are left. Left out for what a shop never runs out of */
143
+ count?: number;
144
+ /** 0..1 towards the next one, when the shop is not full */
145
+ restock: number;
146
+ }
147
+ /**
148
+ * An ability a hero can put points into
149
+ *
150
+ * @beta
151
+ */
152
+ export interface LearnableInfo {
153
+ id: string;
154
+ level: number;
155
+ maxLevel: number;
156
+ /** Hero level needed for the next level of the ability */
157
+ needs: number;
158
+ /** Whether a point can go into it right now */
159
+ available: boolean;
160
+ }
161
+ /**
162
+ * A hero's experience: what it has, at what the level it is at started and at what the next one does (`HeroSent.xp`)
163
+ *
164
+ * @beta
165
+ */
166
+ export interface XpInfo {
167
+ /** Experience in total, whole */
168
+ xp: number;
169
+ /** What the level it is at took */
170
+ levelXp: number;
171
+ /** What the next level takes */
172
+ nextXp: number;
173
+ }
174
+ /**
175
+ * A hero of the player, for the row of portraits. Fallen ones are in here too
176
+ *
177
+ * @beta
178
+ */
179
+ export interface HeroSummary {
180
+ id: number;
181
+ type: string;
182
+ level: number;
183
+ alive: boolean;
184
+ /** 0..1 */
185
+ hp: number;
186
+ mana: number;
187
+ points: number;
188
+ /** 0..1 while being brought back: at an altar, or coming back by itself (`withRespawn`) */
189
+ reviving?: number;
190
+ /** Seconds until it comes back by itself, while it waits to (`withRespawn`) */
191
+ respawnIn?: number;
192
+ /** What bringing it back would cost */
193
+ reviveCost?: Cost;
194
+ }
195
+ /**
196
+ * The part of an entity only its owner and their allies get to know
197
+ *
198
+ * @beta
199
+ */
200
+ export interface OwnEntityState {
201
+ /** Another player's, which this one may command: its owner shares control with them (`world.shareControl`) */
202
+ shared?: boolean;
203
+ /** Inside something, like a worker in a mine */
204
+ hidden: boolean;
205
+ /** Type of the order being carried out */
206
+ order: string | null;
207
+ /** What it is about to build, for a build order */
208
+ build?: string;
209
+ /** Orders in the queue, the current one included */
210
+ orders: number;
211
+ passive: boolean;
212
+ fighting: boolean;
213
+ /** Where it is walking to right now */
214
+ goal?: Vec2;
215
+ /** Destinations of the orders waiting in the queue: none while nothing waits */
216
+ waypoints?: Vec2[];
217
+ abilities?: AbilityInfo[];
218
+ }
219
+ /** @beta */
220
+ export interface EntityState {
221
+ id: number;
222
+ type: string;
223
+ owner: PlayerId;
224
+ x: number;
225
+ z: number;
226
+ facing: number;
227
+ hp: number;
228
+ /** The stats that are not what its type starts with. Whoever sees a unit can tell what it is capable of */
229
+ stats?: Partial<Stats>;
230
+ /** What its shields still hold */
231
+ shield?: number;
232
+ /** On its way through the air: from where to where, and how high it rises in between */
233
+ leap?: {
234
+ from: Vec2;
235
+ to: Vec2;
236
+ height: number;
237
+ };
238
+ /** False for a structure that is out of sight and shown the way it was last seen */
239
+ visible: boolean;
240
+ /** Left out when it is what the unit type says */
241
+ maxHp?: number;
242
+ mana?: number;
243
+ maxMana?: number;
244
+ /** Ids of the buffs on it */
245
+ buffs?: string[];
246
+ /** How many of each of its buffs that stack it carries, for the ones it carries any of */
247
+ stacks?: Record<string, number>;
248
+ /**
249
+ * Seconds left of each of its `buffs`, in their order (whole seconds, rounded up, from a host: the plate counts
250
+ * down between); -1 for one kept up by an aura or a passive (`BuffInstance.kept`) or that lasts until it is
251
+ * taken off. Where the rules share them (`GameRules.hud.shareBuffTimes`)
252
+ *
253
+ * @beta
254
+ */
255
+ buffTimes?: number[];
256
+ /**
257
+ * The abilities it has learned, for whoever sees it, its side's or not, where the rules share them
258
+ * (`GameRules.hud.shareAbilities`). Its side has them in `own.abilities` all the same
259
+ *
260
+ * @beta
261
+ */
262
+ abilities?: SharedAbility[];
263
+ /** What is left in a resource */
264
+ resource?: number;
265
+ /** The resource it stands on (`UnitTypeDef.builtOn`, a cursed mine on a gold mine), by id */
266
+ on?: number;
267
+ /** Doing nothing until woken, like a creep sleeping through the night */
268
+ asleep?: boolean;
269
+ /** How big it is drawn, when that is not 1 */
270
+ scale?: number;
271
+ /** Which of the models of its type it is drawn with, when the map says */
272
+ look?: string;
273
+ /** Seconds left and seconds in all, for what is gone by itself after a while, like a ward */
274
+ lifetime?: {
275
+ left: number;
276
+ total: number;
277
+ };
278
+ /** Invisible to enemies right now. Whoever gets this sees it all the same: it is theirs, or they found it */
279
+ unseen?: boolean;
280
+ /** Components of game modules and mods that are sent to this player (see `Component.replicate`), by id */
281
+ components?: Record<string, unknown>;
282
+ /** The name the map or the rules gave it (`world.named`), for whoever knows of it: "the gate", "the hero" */
283
+ name?: string;
284
+ own?: OwnEntityState;
285
+ }
286
+ /** @beta */
287
+ export interface PlayerState {
288
+ id: PlayerId;
289
+ name: string;
290
+ team: number;
291
+ color: [number, number, number];
292
+ neutral: boolean;
293
+ /** Whether they are the creeps: hostile to everyone, but no one's rival */
294
+ creeps?: boolean;
295
+ /** The race they play (`raceOf`): left out in a game without races */
296
+ race?: string;
297
+ defeated: boolean;
298
+ /** What they are to the player the snapshot is for: by their teams, or as the rules set it (`setRelation`) */
299
+ relation: 'self' | 'ally' | 'enemy' | 'neutral';
300
+ /**
301
+ * What the player the snapshot is for shares with this ally (`shareWith`): their units' control, and their team's
302
+ * sight (always, for an ally of their team). Left out for who is not an ally
303
+ */
304
+ shared?: {
305
+ control: boolean;
306
+ vision: boolean;
307
+ };
308
+ /** Only filled in for the player the snapshot is for */
309
+ own?: {
310
+ /** What the player has of each resource, by resource id */
311
+ resources: Record<ResourceKind, number>;
312
+ supplyUsed: number;
313
+ supplyCap: number;
314
+ /** The game's other pools of supply, by name (`GameRules.supply.pools`): left out in a game with none */
315
+ supplies?: Record<string, {
316
+ used: number;
317
+ cap: number;
318
+ }>;
319
+ /** What the size of the army costs in income */
320
+ upkeep: {
321
+ tier: number;
322
+ name: string;
323
+ income: number;
324
+ };
325
+ upgrades: Record<string, number>;
326
+ researching: string[];
327
+ /** Types of the finished buildings the player has, with what those count as */
328
+ tech: string[];
329
+ heroes: HeroSummary[];
330
+ /** What the player is set to do, in a mission. Empty in a game without objectives */
331
+ objectives: ObjectiveState[];
332
+ /** The timers the rules show the player (`world.timers.show`): their words and the tick each goes off at */
333
+ timers?: ShownTimer[];
334
+ /**
335
+ * What the game's `requirement` hook decided, where it differs from what the requirements say (see
336
+ * `PlayerFacts.unlocks`): by unit or structure type, and `upgrade:<id>` for the next level. Left out without one
337
+ */
338
+ unlocks?: Record<string, Message | null>;
339
+ /**
340
+ * What the game's `available` hook decided, where it differs from what their race says (see
341
+ * `PlayerFacts.availability`): by unit or structure type, and `upgrade:<id>`. Left out without one
342
+ */
343
+ availability?: Record<string, boolean>;
344
+ };
345
+ }
346
+ /** @beta */
347
+ export interface ProjectileState {
348
+ id: number;
349
+ x: number;
350
+ z: number;
351
+ /** The type of what shot it, known even when the shooter is out of sight: what it looks like */
352
+ kind: string;
353
+ owner: PlayerId;
354
+ crit: boolean;
355
+ damageType: DamageType;
356
+ /** A look the rules gave it (see `Projectile.look`) */
357
+ look?: string;
358
+ /** Entity it was fired by, when that one is known to the player */
359
+ source?: number;
360
+ /** Entity it is after, when that one is known to the player */
361
+ target?: number;
362
+ /** Where it was fired from and where it comes down, for shots that are lobbed at a spot */
363
+ from?: Vec2;
364
+ to?: Vec2;
365
+ }
366
+ /**
367
+ * What an ability sent on its way, like a tornado
368
+ *
369
+ * @beta
370
+ */
371
+ export interface MissileState {
372
+ id: number;
373
+ ability: string;
374
+ level: number;
375
+ /** Entity that sent it, when that one is known to the player */
376
+ source?: number;
377
+ x: number;
378
+ z: number;
379
+ radius: number;
380
+ /** The way it is heading, in radians */
381
+ heading: number;
382
+ /** How far it is with taking shape, 0..1, while it has not set off yet */
383
+ forming?: number;
384
+ /** How much of its way it has come, 0..1, for the ones that go a known way */
385
+ progress?: number;
386
+ /** How high above the ground its arc carries it now, for what is thrown in one (`EffectFields.arc`) */
387
+ arc?: number;
388
+ }
389
+ /**
390
+ * What the players are told happened during a tick, which cannot be read from the state afterwards: each kind by its
391
+ * `type` (design review E7). The engine's are told by its replications (`replicateEvent(key, type, tell)`, typed by
392
+ * this entry); a pack's or a game's own added by declaration merging, as `OrderStates` is. A screen's handlers are
393
+ * keyed by the same names (`SessionEventOf`)
394
+ *
395
+ * @beta
396
+ */
397
+ export interface SessionEvents {
398
+ /**
399
+ * Something died. What killed it (`killer`, `killerType`, `from`, where it stood) when the player sees it; how:
400
+ * an attack of the killer's, the blow's damage type, the ability, how much too much, a critical strike, and what
401
+ * the rules made of it (`how`, set in the `death` hook: `'exploded'`). For the screen to show it its way
402
+ */
403
+ death: {
404
+ type: 'death';
405
+ id: number;
406
+ from?: Vec2;
407
+ killer?: number;
408
+ killerType?: string;
409
+ attack: boolean;
410
+ damageType?: DamageType;
411
+ ability?: string;
412
+ overkill?: number;
413
+ crit?: boolean;
414
+ how?: string;
415
+ /** Why, when it was not of damage (`DeathReason`): `cancelled`, `expired`, a game's own word */
416
+ reason?: string;
417
+ /** The blow's words of the game's own (`DamageOptions.tags`) */
418
+ tags?: string[];
419
+ };
420
+ /**
421
+ * Cells of one of the game's layers (`Terrain.cells`) were set to `value` (`world.setCells`): the session's ground has
422
+ * it already, for the screen to draw again. Told where the player's team sees the cells, and as they come into its sight
423
+ * where it does not (`TeamMemory.cells`): an observer is told of all
424
+ */
425
+ cells: {
426
+ type: 'cells';
427
+ layer: string;
428
+ at: number[];
429
+ value: number;
430
+ };
431
+ /**
432
+ * A part of the ground was reshaped (`world.reshapeGround`, the editor's Play here): the session's ground has it
433
+ * already, for the screen to draw again. Told to everyone
434
+ */
435
+ ground: {
436
+ type: 'ground';
437
+ patch: TerrainPatch;
438
+ };
439
+ /**
440
+ * Something the player does not see moved in a layer of cells where the player sees the ground (`ConcealmentOptions.rustle`):
441
+ * where, and whether it stepped in. Not who: for the screen to shake the bushes there
442
+ *
443
+ * @beta
444
+ */
445
+ rustle: {
446
+ type: 'rustle';
447
+ layer: string;
448
+ x: number;
449
+ z: number;
450
+ entered?: boolean;
451
+ };
452
+ /** What the map looks like beyond its ground, as it is now (`world.setEnvironment`), and the seconds to ease into it over */
453
+ environment: {
454
+ type: 'environment';
455
+ environment: MapEnvironment;
456
+ over?: number;
457
+ };
458
+ /**
459
+ * A definition changed while the game runs (`world.redefine`), a copy made with `copyOf`: a screen with a registry of
460
+ * its own puts it in. Told to everyone
461
+ */
462
+ redefined: {
463
+ type: 'redefined';
464
+ kind: DataKind;
465
+ definition: string;
466
+ values: DataValues;
467
+ };
468
+ /** An attack started, at `target` when the player sees it */
469
+ /** `weapon`: which of its attacks swings, by place (`UnitTypeDef.attacks`); the first when left out */
470
+ attack: {
471
+ type: 'attack';
472
+ id: number;
473
+ target?: number;
474
+ weapon?: number;
475
+ };
476
+ /** Damage dealt to an entity the player sees: by whom when the player sees that too, with what, how much */
477
+ damage: {
478
+ type: 'damage';
479
+ id: number;
480
+ amount: number;
481
+ damageType: DamageType;
482
+ source?: number;
483
+ sourceType?: string;
484
+ attack: boolean;
485
+ crit: boolean;
486
+ /** The ability that dealt it, where the player sees the source (`source`) */
487
+ ability?: string;
488
+ tags?: string[];
489
+ };
490
+ /** Health given back to an entity the player sees */
491
+ heal: {
492
+ type: 'heal';
493
+ id: number;
494
+ amount: number;
495
+ source?: number;
496
+ };
497
+ /**
498
+ * A buff put on an entity the player sees (`on`), put on again at another level (`renewed`), or taken off or run
499
+ * out. Once as it begins and once as it ends: a renewal at the same level is not told
500
+ */
501
+ buff: {
502
+ type: 'buff';
503
+ id: number;
504
+ buff: string;
505
+ on: boolean;
506
+ level?: number;
507
+ renewed?: boolean;
508
+ source?: number;
509
+ };
510
+ /** A unit came out of `building`, where the player sees that too */
511
+ trained: {
512
+ type: 'trained';
513
+ id: number;
514
+ building?: number;
515
+ };
516
+ /** A structure was put down to be built, to go up over `buildTime` seconds as builders work (`EntityState.construction`) */
517
+ constructionStarted: {
518
+ type: 'constructionStarted';
519
+ id: number;
520
+ buildTime: number;
521
+ };
522
+ /** A structure was finished (or put down whole, `UnitTypeDef.construction: 'instant'`) */
523
+ built: {
524
+ type: 'built';
525
+ id: number;
526
+ };
527
+ /** A construction was called off by its owner: it dies next, its death's reason `cancelled` */
528
+ constructionCancelled: {
529
+ type: 'constructionCancelled';
530
+ id: number;
531
+ };
532
+ /** A building started to turn into another type (`to`) over `time` seconds (`EntityState.upgrade`) */
533
+ upgradeStarted: {
534
+ type: 'upgradeStarted';
535
+ id: number;
536
+ to: string;
537
+ time: number;
538
+ };
539
+ /** That was called off */
540
+ upgradeCancelled: {
541
+ type: 'upgradeCancelled';
542
+ id: number;
543
+ to: string;
544
+ };
545
+ /** An entity became another type (`from`: what it was): an upgrade done, a morph */
546
+ morphed: {
547
+ type: 'morphed';
548
+ id: number;
549
+ from: string;
550
+ };
551
+ /** A hero was brought back */
552
+ revived: {
553
+ type: 'revived';
554
+ id: number;
555
+ };
556
+ /** An entity picked an item up */
557
+ picked: {
558
+ type: 'picked';
559
+ id: number;
560
+ item: string;
561
+ };
562
+ /** Research of the player or an ally finished */
563
+ researched: {
564
+ type: 'researched';
565
+ upgrade: string;
566
+ level: number;
567
+ building: number;
568
+ };
569
+ /** A shot arrived: at its target when it had one, missing (`miss`), or struck critically */
570
+ shot: {
571
+ type: 'shot';
572
+ id: number;
573
+ x: number;
574
+ z: number;
575
+ target?: number;
576
+ miss: boolean;
577
+ crit: boolean;
578
+ };
579
+ /** A channelled ability started to be kept up (`on`, for `duration` seconds), or ended: done, or `interrupted` */
580
+ channel: {
581
+ type: 'channel';
582
+ id: number;
583
+ ability: string;
584
+ on: boolean;
585
+ duration?: number;
586
+ interrupted?: boolean;
587
+ };
588
+ /** What an ability sent on its way struck an entity */
589
+ missileHit: {
590
+ type: 'missileHit';
591
+ missile: number;
592
+ target: number;
593
+ };
594
+ /** A critical strike landed on the entity */
595
+ crit: {
596
+ type: 'crit';
597
+ id: number;
598
+ amount: number;
599
+ };
600
+ /** An attack up a cliff went wide, at this spot */
601
+ miss: {
602
+ type: 'miss';
603
+ x: number;
604
+ z: number;
605
+ };
606
+ /** A shot that hits an area came down */
607
+ impact: {
608
+ type: 'impact';
609
+ x: number;
610
+ z: number;
611
+ radius: number;
612
+ };
613
+ /** A worker struck what it is mending */
614
+ work: {
615
+ type: 'work';
616
+ id: number;
617
+ };
618
+ /** A worker struck what it is gathering from */
619
+ chop: {
620
+ type: 'chop';
621
+ id: number;
622
+ target: number;
623
+ };
624
+ /** An ability went off. `radius` is there for the ones that hit an area */
625
+ levelUp: {
626
+ type: 'levelUp';
627
+ id: number;
628
+ level: number;
629
+ };
630
+ /** Experience a hero of the player's or an ally's earned, and the level it is at after it */
631
+ xp: {
632
+ type: 'xp';
633
+ id: number;
634
+ amount: number;
635
+ level: number;
636
+ };
637
+ /**
638
+ * 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
639
+ * an effect (above 0). Not regeneration
640
+ */
641
+ mana: {
642
+ type: 'mana';
643
+ id: number;
644
+ amount: number;
645
+ ability?: string;
646
+ };
647
+ /** A pool of the game's own on a unit of the player's or an ally's changed (`resourceChanged`) */
648
+ resource: {
649
+ type: 'resource';
650
+ id: number;
651
+ kind: string;
652
+ amount: number;
653
+ reason?: string;
654
+ };
655
+ /** Gold for a kill */
656
+ bounty: {
657
+ type: 'bounty';
658
+ x: number;
659
+ z: number;
660
+ amount: number;
661
+ };
662
+ /** Someone started to cast. `duration` is how long until it goes off */
663
+ windup: {
664
+ type: 'windup';
665
+ id: number;
666
+ ability: string;
667
+ level: number;
668
+ x: number;
669
+ z: number;
670
+ duration: number;
671
+ };
672
+ /** `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 */
673
+ cast: {
674
+ type: 'cast';
675
+ id?: number;
676
+ ability: string;
677
+ level: number;
678
+ x: number;
679
+ z: number;
680
+ target?: number;
681
+ radius?: number;
682
+ charged?: boolean;
683
+ };
684
+ /** 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 */
685
+ strike: {
686
+ type: 'strike';
687
+ id?: number;
688
+ ability: string;
689
+ level: number;
690
+ x: number;
691
+ z: number;
692
+ target?: number;
693
+ radius?: number;
694
+ impact?: string;
695
+ };
696
+ /** Something to tell the player. The client finds the words for it, see `Message` */
697
+ message: {
698
+ type: 'message';
699
+ message: Message;
700
+ kind: MessageKind;
701
+ seconds?: number;
702
+ };
703
+ /** A command the player sent (`seq`, what `send` gave) was carried out: refused, with why, or not */
704
+ command: {
705
+ type: 'command';
706
+ seq: number;
707
+ refusal?: Message;
708
+ };
709
+ /** An objective of the player was given (`was` undefined), got further along, or was done or failed */
710
+ objective: {
711
+ type: 'objective';
712
+ objective: ObjectiveState;
713
+ was?: ObjectiveStatus;
714
+ };
715
+ /** Someone says a line to the player: who, what, and for how long (see `world.dialog`) */
716
+ line: {
717
+ type: 'line';
718
+ line: SaidLine;
719
+ };
720
+ /** The line was skipped: it ends now */
721
+ lineEnded: {
722
+ type: 'lineEnded';
723
+ id: number;
724
+ };
725
+ /** One of the view's cinematics plays (see `playCinematic`) */
726
+ cinematic: {
727
+ type: 'cinematic';
728
+ cinematic: string;
729
+ hold: boolean;
730
+ skippable: boolean;
731
+ params?: Record<string, unknown>;
732
+ };
733
+ /** The rules cue the cinematic playing (see `cueCinematic`) */
734
+ cinematicCue: {
735
+ type: 'cinematicCue';
736
+ cue: string;
737
+ params?: Record<string, unknown>;
738
+ };
739
+ /**
740
+ * One of the view's effects plays, as the rules said (`world.effect`): `id` is the rules' handle on it, `fx` its name,
741
+ * at a place (`x`, `y`, `z`) or on an entity (`on`, at a `point`), its knobs, the seed of its random parts
742
+ */
743
+ fx: {
744
+ type: 'fx';
745
+ id: number;
746
+ fx: string;
747
+ x?: number;
748
+ y?: number;
749
+ z?: number;
750
+ on?: number;
751
+ point?: string;
752
+ params?: Record<string, unknown>;
753
+ seed: number;
754
+ overFog?: boolean;
755
+ };
756
+ /** An effect the rules played stops (`world.stopEffect`) */
757
+ fxStop: {
758
+ type: 'fxStop';
759
+ id: number;
760
+ fade?: number;
761
+ };
762
+ /** A player of the side marked a spot of the map, or any player for everyone (`to`, see `ping`) */
763
+ /** `by`: the name of who watches, for one of theirs (`to: 'observers'`) */
764
+ ping: {
765
+ type: 'ping';
766
+ player: PlayerId;
767
+ x: number;
768
+ z: number;
769
+ kind: PingKind;
770
+ to: ChatAudience;
771
+ by?: string;
772
+ };
773
+ /** A line of chat for the player: of their side, or to everyone (see `chat`) */
774
+ /** `by`: the name of who watches, for a line of theirs (`to: 'observers'`) */
775
+ chat: {
776
+ type: 'chat';
777
+ player: PlayerId;
778
+ text: string;
779
+ to: ChatAudience;
780
+ by?: string;
781
+ };
782
+ /** An event of the game's own that goes to the screen (see `defineEvent`): its id, and what it says */
783
+ game: {
784
+ type: 'game';
785
+ event: string;
786
+ payload: unknown;
787
+ };
788
+ }
789
+ /**
790
+ * Things that happened during a tick and cannot be read from the state afterwards: one of `SessionEvents`
791
+ *
792
+ * @beta
793
+ */
794
+ export type SessionEvent = SessionEvents[keyof SessionEvents];
795
+ /**
796
+ * How the game stands for the player
797
+ *
798
+ * @beta
799
+ */
800
+ export type Outcome = 'playing' | 'victory' | 'defeat';
801
+ /**
802
+ * Everything one player knows about the game at the end of a tick
803
+ *
804
+ * @beta
805
+ */
806
+ export interface Snapshot {
807
+ tick: number;
808
+ /**
809
+ * The switches of the debug tools as they stand, for a player who may use them (`world.debugPlayers`): `explored`,
810
+ * the whole map explored (`debug.explore`)
811
+ */
812
+ debug?: {
813
+ noCooldowns: boolean;
814
+ noManaCosts: boolean;
815
+ invulnerable: boolean;
816
+ speed: number;
817
+ explored?: boolean;
818
+ };
819
+ /** Hour of the day, 0..24, in a game with days and nights */
820
+ hour?: number;
821
+ outcome: Outcome;
822
+ entities: EntityState[];
823
+ players: PlayerState[];
824
+ projectiles: ProjectileState[];
825
+ missiles: MissileState[];
826
+ /** Items on the ground, where the player can see the ground */
827
+ items: GroundItemState[];
828
+ /** Spots someone sees for a while. Everyone can tell, not only whoever it is */
829
+ reveals: RevealState[];
830
+ /** Corpses where the player can see the ground, by the id of who died there (see `raiseDead`). None when left out */
831
+ corpses?: CorpseState[];
832
+ events: SessionEvent[];
833
+ /** What the game tells the player about itself, see `GameModule.report` */
834
+ report?: Record<string, unknown>;
835
+ /**
836
+ * The score of the players the player is told of (`GameRules.score`: `live`, then `end`), told again at most once
837
+ * in `refresh` seconds. None in a game that counts nothing
838
+ *
839
+ * @beta
840
+ */
841
+ score?: ScoreState;
842
+ /**
843
+ * The score's timeline, of the same players: told again at each point of it (`ScoreRules.every`)
844
+ *
845
+ * @beta
846
+ */
847
+ scoreLine?: ScoreLineState;
848
+ }
849
+ /**
850
+ * A corpse as the player sees it: the id the unit had, of what type, where
851
+ *
852
+ * @beta
853
+ */
854
+ export interface CorpseState {
855
+ id: number;
856
+ type: string;
857
+ x: number;
858
+ z: number;
859
+ }
860
+ /** @beta */
861
+ export interface RevealState {
862
+ id: number;
863
+ x: number;
864
+ z: number;
865
+ radius: number;
866
+ /** Seconds it goes on */
867
+ left: number;
868
+ /** The player's team is the one that sees it */
869
+ ours: boolean;
870
+ }
871
+ /** A creep camp. Where they are is part of the map, which everyone knows */
872
+ /**
873
+ * A deposit of the game's money, as the map shows it (`GameSession.mines`)
874
+ *
875
+ * @beta
876
+ */
877
+ export interface MineInfo {
878
+ id: number;
879
+ x: number;
880
+ z: number;
881
+ }
882
+ /** @beta */
883
+ export interface CampInfo {
884
+ id: number;
885
+ x: number;
886
+ z: number;
887
+ /** Levels of its creeps added up */
888
+ level: number;
889
+ /** Whether the player has seen that the camp is empty */
890
+ cleared: boolean;
891
+ }
892
+ /**
893
+ * What the player's team sees of the map. The arrays are per cell, row by row
894
+ *
895
+ * @beta
896
+ */
897
+ export interface FogState {
898
+ width: number;
899
+ depth: number;
900
+ /** Changes whenever the arrays did */
901
+ version: number;
902
+ /** The whole map is lit, a debug switch */
903
+ revealed: boolean;
904
+ visible: Uint8Array;
905
+ explored: Uint8Array;
906
+ }
907
+ type WithoutPlayer<T> = T extends unknown ? Omit<T, 'player'> : never;
908
+ /**
909
+ * A command as the client writes it. Who it comes from is decided by the session, never by the sender
910
+ *
911
+ * @beta
912
+ */
913
+ export type PlayerCommand = WithoutPlayer<Command> | ModCommand;
914
+ /**
915
+ * Whether a command is one of the engine's of a kind, narrowed to its shape (`isCommand(sent, 'order')`: its units and
916
+ * its order): what reads a command it did not write, a game's own (`ModCommand`) passed over
917
+ *
918
+ * @beta
919
+ */
920
+ export declare function isCommand<K extends Command['type']>(command: PlayerCommand, type: K): command is Extract<WithoutPlayer<Command>, {
921
+ type: K;
922
+ }>;
923
+ /**
924
+ * What the debug tools of a client see of the simulation: an entity as the rules have it, and the events and hooks of
925
+ * the last seconds. Plain data, as the snapshots are, so that it works the same with a simulation somewhere else: the
926
+ * client says what it wants to follow, and reads what came back last
927
+ *
928
+ * @beta
929
+ */
930
+ export interface SessionDebug {
931
+ /** Follows an entity, a player or the world, or nothing. Its inspection comes back from then on */
932
+ inspect(target: InspectTarget | null): void;
933
+ /** What is followed, as it stood when last heard of. Null when nothing is followed, or it is gone */
934
+ readonly inspection: Inspection | null;
935
+ /** Changes a number, or a switch (a boolean), of what is followed, where its inspection shows it (`InspectedSection.path` and the key) */
936
+ set(path: (string | number)[], value: number | boolean): void;
937
+ /** Whether the list of everything in the world comes back. Off until asked for: the world can be big */
938
+ listing: boolean;
939
+ /** Every player and entity of the world, out of sight, hidden and scenery too, as when last heard of. Null while not listing */
940
+ readonly world: WorldListing | null;
941
+ /** Whether the events and hooks are logged. Off until asked for: logging costs a little */
942
+ logging: boolean;
943
+ /** The events and hooks of the last seconds, oldest first */
944
+ log(): readonly LoggedEvent[];
945
+ /** Forgets what was logged so far */
946
+ clearLog(): void;
947
+ }
948
+ /**
949
+ * What a session can do besides being a seat, each where it can (`GameSession.can`): a game played in this page holds
950
+ * 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
951
+ * for as `session.can.pace?.advance()`: there or not
952
+ *
953
+ * @beta
954
+ */
955
+ export interface SessionCan {
956
+ /** 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 */
957
+ readonly pace?: SessionPace;
958
+ /** Saves of the world as it stands, and the last checkpoint: a game played in this page */
959
+ readonly saves?: SessionSaves;
960
+ /** The debug tools' view of the simulation, where the session allows it */
961
+ readonly inspect?: SessionDebug;
962
+ /** Where the time of a simulation run elsewhere in this page went of late: a worker (S54) */
963
+ readonly timing?: SessionTiming;
964
+ /** What a computer player's brain reads besides the snapshot: a seat in the simulation's own thread */
965
+ readonly computer?: SessionComputer;
966
+ }
967
+ /**
968
+ * The pace a session holds the game at (`SessionCan.pace`)
969
+ *
970
+ * @beta
971
+ */
972
+ export interface SessionPace {
973
+ /** 1 as it goes, 0 held (a pause menu, a cinematic that has the game wait) */
974
+ speed: number;
975
+ /** Moves a held game on by `ticks` (one when left out): a step */
976
+ advance(ticks?: number): void;
977
+ }
978
+ /**
979
+ * Saves of the world a session plays (`SessionCan.saves`)
980
+ *
981
+ * @beta
982
+ */
983
+ export interface SessionSaves {
984
+ /** A save of the world as it stands: at once in this thread, a message there and back in a worker */
985
+ save(): Promise<WorldSave>;
986
+ /**
987
+ * The last moment the rules marked to start again from (`world.checkpoint`), with what it is called, and a save of
988
+ * the world as it stood: a scene can load it for "Retry from wave 6"
989
+ */
990
+ readonly checkpoint?: {
991
+ label: Message;
992
+ save: WorldSave;
993
+ };
994
+ }
995
+ /**
996
+ * Where the time of a simulation run elsewhere went of late (`SessionCan.timing`)
997
+ *
998
+ * @beta
999
+ */
1000
+ export interface SessionTiming {
1001
+ /**
1002
+ * Milliseconds a tick took, evened out, the longest, what sending the page what changed took, what the page took to
1003
+ * take it in, and each system's share (`world.scheduler.timing()`) while they are measured (`profile`)
1004
+ */
1005
+ timing(): {
1006
+ tick: number;
1007
+ tickMax: number;
1008
+ send: number;
1009
+ receive?: number;
1010
+ systems?: SystemTiming[];
1011
+ } | undefined;
1012
+ /** Measures the simulation's systems, or stops (it costs a little): what the stats window asks while it is open */
1013
+ profile?(on: boolean): void;
1014
+ }
1015
+ /**
1016
+ * What a computer player's seat gives its brain besides the snapshot (`SessionCan.computer`)
1017
+ *
1018
+ * @beta
1019
+ */
1020
+ export interface SessionComputer {
1021
+ /**
1022
+ * Where the game's money is mined (a resource of `Registry.currency`: gold mines), as a player knows from the map,
1023
+ * under the fog too: what a computer player looks to for another hall
1024
+ */
1025
+ mines(): readonly MineInfo[];
1026
+ /** The lanes of the map (`lanesOf`), as everyone knows them from the map: what a computer player of lanes walks with its waves */
1027
+ lanes(): readonly Lane[];
1028
+ /**
1029
+ * What happened since the last snapshot, not yet given in one: a copy. The brain's save keeps what it heard since it
1030
+ * last thought (`restoreEvents`), so that a game loaded from the save hears it too
1031
+ */
1032
+ pendingEvents(): SessionEvent[];
1033
+ /** Takes back what `pendingEvents` gave, ahead of what has happened since: in a game loaded from a save */
1034
+ restoreEvents(events: readonly SessionEvent[]): void;
1035
+ }
1036
+ /**
1037
+ * A seat in a game: the only thing a client needs to play
1038
+ *
1039
+ * @beta
1040
+ */
1041
+ export interface GameSession {
1042
+ readonly playerId: PlayerId;
1043
+ readonly team: number;
1044
+ /** The map and the game data are the same for everyone and known up front */
1045
+ readonly terrain: Terrain;
1046
+ /**
1047
+ * What the map looks like beyond its ground, for the screen: its water, sky, weather. Nothing when it does not say.
1048
+ * As it was when the session began: what the rules change after comes as `environment` events
1049
+ */
1050
+ readonly environment?: MapEnvironment;
1051
+ /** The scenery of the map, for the screen: none when it has none (see `MapDoodad`) */
1052
+ readonly doodads: readonly MapDoodad[];
1053
+ /** The regions of the map, for the screen: what mist in places lies over by name (see `MapRegion`, `AreaRef`) */
1054
+ readonly regions: readonly MapRegion[];
1055
+ /** The views of the map saved under names, for cinematics and a player's first view (see `MapCamera`) */
1056
+ readonly cameras: readonly MapCamera[];
1057
+ /** The paths of the map (a road), for the screen: a cinematic's camera on a rail along one (see `MapPath`) */
1058
+ readonly paths: readonly MapPath[];
1059
+ readonly registry: Registry;
1060
+ readonly tickRate: number;
1061
+ /**
1062
+ * What the game says about what it does (`World.log`), where the session has it: a game played in the page. A
1063
+ * server's game says it on the server, and a player is not given it
1064
+ */
1065
+ readonly log?: Logger;
1066
+ /**
1067
+ * Why the game ended on an error in its rules, once it has (`World.failure`): what the player is told. A game that
1068
+ * failed does not go on; a client says so, and offers what there is to offer
1069
+ */
1070
+ readonly failure?: {
1071
+ message: string;
1072
+ } | null;
1073
+ /** How far the current frame is between the last two snapshots, 0..1 */
1074
+ readonly alpha: number;
1075
+ /** State to start from */
1076
+ snapshot(): Snapshot;
1077
+ /** Lets time pass. Returns the snapshots that came in since the last call, oldest first */
1078
+ update(dt: number): Snapshot[];
1079
+ /** Sends a command, to be carried out at the next tick. What it gives is told back with how it went (a `command` event) */
1080
+ send(command: PlayerCommand): number;
1081
+ fog(): FogState;
1082
+ camps(): readonly CampInfo[];
1083
+ /** Whether the player could build this here, as far as they can tell */
1084
+ canPlace(unitType: string, point: Vec2): boolean;
1085
+ /**
1086
+ * Which cells of the ground a building would cover there are in the way, as far as the player can tell, row by row
1087
+ * from its corner (`placementCells`): what a preview draws cell by cell. None for one built on a resource, or where
1088
+ * the session does not say @beta
1089
+ */
1090
+ placeCells?(unitType: string, point: Vec2): readonly boolean[] | undefined;
1091
+ /** Route a unit would take, over the ground the player knows */
1092
+ findPath(from: Vec2, to: Vec2, flying?: boolean): Vec2[] | null;
1093
+ /**
1094
+ * What this kind of session can do besides being a seat (`SessionCan`): hold the pace, save, show the debug tools,
1095
+ * tell its timing, serve a computer player. A seat over a wire can none of it; a game in this page most of it
1096
+ */
1097
+ readonly can: SessionCan;
1098
+ /** Whether the player only watches, and sees everything (every player's resources among it): see `LocalSession.observer` */
1099
+ readonly observer?: boolean;
1100
+ /** Milliseconds a message takes to the simulation and back, where it runs elsewhere. Nothing in the page */
1101
+ readonly ping?: number;
1102
+ dispose(): void;
1103
+ }
1104
+ /**
1105
+ * The version of what goes over the wire between a host and its players: the messages here and in `session/remote.ts`,
1106
+ * and how deltas are made (`session/delta.ts`). The host says it in its welcome and a player says it when joining a
1107
+ * server; a player of another version is refused with a reason, not left to fail somewhere strange. Raised by one on
1108
+ * any change of their shape, which a game's own data (`Registry.dataHash`) does not show
1109
+ *
1110
+ * @beta
1111
+ */
1112
+ export declare const PROTOCOL_VERSION = 13;
1113
+ /**
1114
+ * A game of a server, as its list says it (`GET /games`): its room (what to connect to, `ws://host:port/<room>`; none for
1115
+ * a server of one game), the game and mode, where it is at, its seats taken and free, who watches, and its settings
1116
+ * (the map, among them, where the mode offers one)
1117
+ *
1118
+ * @beta
1119
+ */
1120
+ export interface GameListing {
1121
+ room: string;
1122
+ game: string;
1123
+ mode: string;
1124
+ phase: 'lobby' | 'game' | 'ended';
1125
+ /** Seats players hold, seats nobody holds a player could, seats the computer plays */
1126
+ players: number;
1127
+ free: number;
1128
+ computer: number;
1129
+ watchers: number;
1130
+ settings: Record<string, string>;
1131
+ /** Whether it takes no new games: stopping */
1132
+ draining: boolean;
1133
+ /** How its players are rated, on average, where the server keeps ratings (`Ratings`) */
1134
+ rating?: number;
1135
+ }
1136
+ /**
1137
+ * A kind of game a server lets players make a room of, as its list says it (`GET /games`'s `kinds`): what to ask
1138
+ * `POST /games` for (`{ kind: id, settings }`), what it is called, and the settings it offers (a map, among them)
1139
+ *
1140
+ * @beta
1141
+ */
1142
+ export interface GameKindListing {
1143
+ id: string;
1144
+ name: string;
1145
+ /** 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 */
1146
+ queue?: string;
1147
+ waiting?: number;
1148
+ needed?: number;
1149
+ settings: Record<string, {
1150
+ label: string;
1151
+ options: string[];
1152
+ default: string;
1153
+ }>;
1154
+ }
1155
+ export {};