@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
package/dist/save.d.ts ADDED
@@ -0,0 +1,277 @@
1
+ import type { ErrorSite, WorldFailure } from './errors';
2
+ import { type EntityId } from './entity';
3
+ import type { FogSave } from './fog';
4
+ import type { GroundItem } from './items';
5
+ import type { AgentSave } from './navigation/navigation';
6
+ import { type EffectRef } from './effectRefs';
7
+ import type { PlayerInit, Purse } from './player';
8
+ import type { Registry } from './registry';
9
+ import { type SavedGround } from './ground';
10
+ import type { Delayed, Missile, Projectile, Reveal, World, WorldInternals, Zone } from './world';
11
+ /**
12
+ * A world saved: everything it takes to carry on with a game later, somewhere else, or from the same moment more
13
+ * than once. Plain data, and with `encodeSave` text: what is in the world points to definitions by id, and to
14
+ * other entities by id.
15
+ *
16
+ * What is not in it:
17
+ * - the game module (`WorldSave.game` names it), which `loadWorld` is given again;
18
+ * - navigation, which is built again from the terrain and the structures, with the agents put back where they were;
19
+ * - systems added while the game ran (`World.addSystem`), like a computer player: whoever loads adds them again,
20
+ * and what they keep in themselves (`System.save`) goes back into them as they are added;
21
+ * - state a game module keeps outside the world, like in a `WeakMap` keyed by it. Keep it in components instead
22
+ * (`World.state`, `Player.state`, `Entity.get`), which are in here.
23
+ *
24
+ * Two numbers say how old a save is, and they are not the same thing. `format` is the engine's: the shape of the save
25
+ * itself, which the engine brings up to date by itself. `version` is the game's: what the game keeps in a save (its
26
+ * unit types, its components), which the game brings up to date (`GameModule.saves`). A save is read through both
27
+ * (`updateSave`), the engine's first
28
+ *
29
+ * @beta
30
+ */
31
+ export interface WorldSave {
32
+ /** The shape of the save itself (`SAVE_FORMAT`): the engine's to change, and to bring an older one up to */
33
+ format: typeof SAVE_FORMAT;
34
+ /** Id of the game module the world was made with */
35
+ game: string;
36
+ /** The version of what the game keeps in a save (`GameModule.saves.version`): 1 for a game that says none */
37
+ version: number;
38
+ /**
39
+ * Which rules it was made with exactly, mods and code included (see `gameHash`): whether it can be loaded as it is.
40
+ * What a game does about a save of other rules is its own to say (`GameModule.saves.onMismatch`)
41
+ */
42
+ hash: string;
43
+ tickRate: number;
44
+ tick: number;
45
+ winner: number | null;
46
+ /** The parts of the game switched off for having thrown (`world.disabled`): off again in the world loaded. None when left out */
47
+ disabled?: ErrorSite[];
48
+ /** Why the game ended on an error (`world.failure`), for a save taken of one that did */
49
+ failure?: WorldFailure;
50
+ rng: number;
51
+ internals: WorldInternals;
52
+ cheats: World['cheats'];
53
+ /** The entity each object of the map became, by the object's id (`World.mapEntities`): as `[object, entity]`. None when left out */
54
+ mapEntities?: [number, EntityId][];
55
+ /** The ground: all of it, or the map the world was made from and what changed of it since (S36, format 3) */
56
+ terrain: SavedGround;
57
+ players: PlayerSave[];
58
+ fog: FogSave;
59
+ /** Where walkable space was at: movement looks for a new path when it changes */
60
+ navVersion: number;
61
+ /** Everything in the world, in the order it was put there */
62
+ entities: EntitySave[];
63
+ /** Entities that left the world but are still pointed at, like the caster of something that has yet to land */
64
+ detached: EntitySave[];
65
+ /** Ids of the entities that act, in the order they are gone through: who goes first can decide what happens */
66
+ actors: EntityId[];
67
+ /** Scenery each team sees, by team */
68
+ sceneryInSight: Record<number, EntityId[]>;
69
+ projectiles: Projectile[];
70
+ missiles: MissileSave[];
71
+ /** What missiles sent together have passed through, which they share */
72
+ missileHits: EntityId[][];
73
+ delayed: DelayedSave[];
74
+ zones: ZoneSave[];
75
+ reveals: Reveal[];
76
+ items: GroundItem[];
77
+ /** State of game modules and mods for the whole game, by component id (see `World.state`) */
78
+ state: Record<string, unknown>;
79
+ /** What systems keep in themselves (`System.save`), by their name */
80
+ systems?: Record<string, unknown>;
81
+ }
82
+ /**
83
+ * The format saves are written in now: a save of another is refused. The engine keeps no steps up from an older one
84
+ * while it and its games are made (a game's own versions have `SaveRules.migrate`)
85
+ *
86
+ * @beta
87
+ */
88
+ export declare const SAVE_FORMAT = 5;
89
+ interface PlayerSave {
90
+ init: PlayerInit;
91
+ resources: Purse;
92
+ supplyUsed: number;
93
+ supplyCap: number;
94
+ /** The game's other pools (`GameRules.supply.pools`): left out of a save made before there were any */
95
+ supplies?: Record<string, {
96
+ used: number;
97
+ cap: number;
98
+ }>;
99
+ established: boolean;
100
+ defeated: boolean;
101
+ upgrades: [string, number][];
102
+ upgradesVersion: number;
103
+ researching: string[];
104
+ /** State of game modules and mods for the player, by component id */
105
+ state: Record<string, unknown>;
106
+ }
107
+ /**
108
+ * An entity: its type, and every field it has, as plain data. `agent` is how it moves, when it does
109
+ *
110
+ * @beta
111
+ */
112
+ export type EntitySave = {
113
+ id: EntityId;
114
+ type: string;
115
+ owner: number;
116
+ agent?: AgentSave;
117
+ } & Record<string, unknown>;
118
+ type MissileSave = Omit<Missile, 'hit' | 'effect'> & {
119
+ hit: number;
120
+ effect: EffectRef;
121
+ };
122
+ type DelayedSave = Omit<Delayed, 'caster' | 'ability' | 'effects'> & {
123
+ caster: EntityId;
124
+ ability: string;
125
+ effects: EffectRef;
126
+ };
127
+ type ZoneSave = Omit<Zone, 'caster' | 'ability' | 'effect'> & {
128
+ caster: EntityId;
129
+ ability: string;
130
+ effect: EffectRef;
131
+ };
132
+ /**
133
+ * How a world is saved (`saveWorld`)
134
+ *
135
+ * @beta
136
+ */
137
+ export interface SaveWorldOptions {
138
+ /**
139
+ * Whether the world's crowd is put back from what the save keeps of it, as loading the save puts it (determinism
140
+ * D2): the game saved and a game loaded from the save then go on exactly the same. A save keeps where each agent is
141
+ * and where it goes, not the crowd's own working (the order it moves its agents in, the paths it is part way
142
+ * along), which cannot be put back as it was. Yes when left out; `false` for a look at the state that leaves the
143
+ * world as it was (`worldState`, `worldHash`)
144
+ *
145
+ * @beta
146
+ */
147
+ reseat?: boolean;
148
+ }
149
+ /**
150
+ * Saves a world, between two ticks. Throws, saying where, when something in it is not plain data
151
+ *
152
+ * @beta
153
+ */
154
+ export declare function saveWorld(world: World, options?: SaveWorldOptions): WorldSave;
155
+ /** The players of a save, as a world is made with them */
156
+ export declare const savedPlayers: (save: WorldSave) => PlayerInit[];
157
+ /**
158
+ * Fills a world just made from the game module and the terrain and players of the save with the rest of it. The save
159
+ * is one of the format and the version read now: an older one goes through `updateSave` first, as `loadWorld` does
160
+ */
161
+ export declare function restoreWorld(world: World, save: WorldSave): void;
162
+ /**
163
+ * How a game's saves outlive its patches (`GameModule.saves`). Any change to a game's rules changes which rules they
164
+ * are exactly (`registry.hash`), and most changes are nothing to a save: a number tuned, a bug fixed. A game that
165
+ * declares this loads such a save as it is. A change a save cannot be read through (a unit type renamed, a component
166
+ * of another shape) takes a new `version`, and a step that brings the saves made before up to it
167
+ *
168
+ * @beta
169
+ */
170
+ export interface SaveRules {
171
+ /**
172
+ * The version of what the game keeps in a save: a whole number from 1, and 1 when left out. One more with every
173
+ * patch that saves made before have to be changed for, together with the step that changes them (`migrate`). A save
174
+ * says which it is of (`WorldSave.version`); one of a version newer than the game's is refused
175
+ */
176
+ version?: number;
177
+ /**
178
+ * What brings an older save up to date. A step for each version, by the version it starts from (`{ 3: … }` makes a
179
+ * save of version 3 one of version 4), run one after the other; or one function for all of it, told the version the
180
+ * save is of and the one it is to be of. A save of a version with no step after it is refused, saying so: a version
181
+ * with nothing to change has the step `(save) => save`
182
+ */
183
+ migrate?: Record<number, SaveMigration> | ((save: WorldSave, from: number, to: number) => WorldSave | void);
184
+ /**
185
+ * What becomes of a save of the game's version made with other rules, its code, its numbers or its mods having
186
+ * changed since: `load` it as it is, `refuse` it, or a function that says which, given the save and the hash of the
187
+ * rules now. `load` when left out
188
+ */
189
+ onMismatch?: 'load' | 'refuse' | ((save: WorldSave, hash: string) => 'load' | 'refuse');
190
+ }
191
+ /**
192
+ * A step of a game's own, from one version of its saves to the next. The save is plain data in the engine's format
193
+ * of now (the engine's own steps run first), and a copy: the step changes it in place, or gives another
194
+ *
195
+ * @beta
196
+ */
197
+ export type SaveMigration = (save: WorldSave) => WorldSave | void;
198
+ /**
199
+ * Why a save is not loaded:
200
+ * - `notASave`: it is not a save, or says nothing readable of its format or its version
201
+ * - `game`: it is another game's
202
+ * - `newer`: it was made by a newer version of the game, or of the engine, than this one
203
+ * - `noWay`: it is of an older version of the game's saves, and the game has no step from there (`SaveRules.migrate`)
204
+ * - `rules`: it was made with other rules, and the game does not load those (`SaveRules.onMismatch`)
205
+ * - `missing`: it has in it what the game no longer has (`SaveError.missing`)
206
+ * - `ground`: its ground is a map of the game as it was, which the game no longer has as it was (S36)
207
+ *
208
+ * @beta
209
+ */
210
+ export type SaveRefusal = 'notASave' | 'game' | 'newer' | 'noWay' | 'rules' | 'missing' | 'ground';
211
+ /**
212
+ * What a save has in it that the game does not have, by kind: their ids
213
+ *
214
+ * @beta
215
+ */
216
+ export type SaveMissing = Partial<Record<'unit' | 'ability' | 'buff' | 'item' | 'upgrade' | 'order' | 'component' | 'timer' | 'sequence', string[]>>;
217
+ /**
218
+ * A save that is not loaded, and why: for a list of saves to say, in words of its own
219
+ *
220
+ * @beta
221
+ */
222
+ export declare class SaveError extends Error {
223
+ readonly reason: SaveRefusal;
224
+ /** For `missing`: what the save has that the game does not */
225
+ readonly missing?: SaveMissing | undefined;
226
+ constructor(message: string, reason: SaveRefusal,
227
+ /** For `missing`: what the save has that the game does not */
228
+ missing?: SaveMissing | undefined);
229
+ }
230
+ /**
231
+ * What of a save says whether a game reads it, the rest of it apart: kept beside a save, for a list of them to ask with
232
+ *
233
+ * @beta
234
+ */
235
+ export interface SaveHeader {
236
+ format: number;
237
+ game: string;
238
+ /** 1 when left out, as in a save from before games had versions of their saves */
239
+ version?: number;
240
+ hash: string;
241
+ }
242
+ /**
243
+ * The header of a save
244
+ *
245
+ * @beta
246
+ */
247
+ export declare const saveHeader: (save: SaveHeader) => SaveHeader;
248
+ /**
249
+ * Whether a game loads a save, as far as the save's header says (`saveHeader`): nothing, or why not. For a list of
250
+ * saves, which has no need to read each of them whole. What only the whole save says (something in it the game no
251
+ * longer has, a game that decides save by save) is found as it is loaded (`updateSave`, `loadWorld`)
252
+ *
253
+ * @beta
254
+ */
255
+ export declare function saveProblem(header: SaveHeader, registry: Registry): SaveError | undefined;
256
+ /**
257
+ * A save as the game reads it now, whatever it was saved by: brought up from an older version by the game's (`GameModule.saves.migrate`), each one version at a time. `loadWorld` runs
258
+ * it; a tool that keeps saves up to date runs it by itself. The save handed in is not changed. Throws a `SaveError`,
259
+ * which says why, for one that cannot be read: another game's, newer than this game, of a version the game has no
260
+ * step from, made with other rules by a game that refuses those (`anyVersion` loads it all the same), or with
261
+ * something in it the game no longer has, all of which the error names
262
+ *
263
+ * @beta
264
+ */
265
+ export declare function updateSave(data: unknown, registry: Registry, options?: {
266
+ anyVersion?: boolean;
267
+ }): WorldSave;
268
+ /**
269
+ * A save as text. JSON, but for numbers JSON has no words for, which game state has: buffs that last forever
270
+ * (`Infinity`), something never hurt (`-Infinity`)
271
+ *
272
+ * @beta
273
+ */
274
+ export declare function encodeSave(save: WorldSave): string;
275
+ /** @beta */
276
+ export declare function decodeSave(text: string): WorldSave;
277
+ export {};
@@ -0,0 +1,56 @@
1
+ import { type GameModule } from './game';
2
+ import { type GameMap, type MapFile } from './map';
3
+ import type { World } from './world';
4
+ /**
5
+ * A situation for a test to start from, set up in the editor: a map made for it, or a world saved at the moment that
6
+ * matters (in the editor's play mode). Kept in the tests' scenarios (`<scenarios>/<game>/<name>.scenario.json`: `tests/scenarios` unless the project says otherwise), or in a game's folder,
7
+ * and loaded with what was named in the editor found by name. It says which format it was saved with, and is brought
8
+ * up to date like a map (`readScenario`): one that no longer loads fails its test with what is wrong
9
+ *
10
+ * @beta
11
+ */
12
+ export type ScenarioFile = {
13
+ format: number;
14
+ name: string;
15
+ /** The game it is of, by the id of its module */
16
+ game: string;
17
+ /** What it is for, to read in a list */
18
+ description?: string;
19
+ } & ({
20
+ kind: 'map';
21
+ map: MapFile;
22
+ } | {
23
+ kind: 'save';
24
+ save: string;
25
+ });
26
+ /**
27
+ * The format scenarios are written in now
28
+ *
29
+ * @beta
30
+ */
31
+ export declare const SCENARIO_FORMAT = 1;
32
+ /**
33
+ * A scenario file as it is now, checked. Throws on what is wrong with it
34
+ *
35
+ * @beta
36
+ */
37
+ export declare function readScenario(data: unknown): ScenarioFile;
38
+ /**
39
+ * A map made for a test, as a scenario
40
+ *
41
+ * @beta
42
+ */
43
+ export declare function scenarioOfMap(map: GameMap, name: string, game: string, description?: string): ScenarioFile;
44
+ /**
45
+ * A world at the moment that matters, as a scenario
46
+ *
47
+ * @beta
48
+ */
49
+ export declare function scenarioOfWorld(world: World, name: string, description?: string): ScenarioFile;
50
+ /**
51
+ * The world of a scenario, with the game's module: a map made into a world as a game would make it (with the seed 1,
52
+ * so that it is the same every time), or a saved world loaded as it was
53
+ *
54
+ * @beta
55
+ */
56
+ export declare function scenarioWorld(scenario: ScenarioFile, game: GameModule): Promise<World>;
@@ -0,0 +1,67 @@
1
+ import type { System, SystemPhase } from './registry';
2
+ import type { World } from './world';
3
+ /**
4
+ * The parts of a tick, in the order they run. The player commands of the tick have been applied before any of them.
5
+ * - `commands`: first, for what reacts to the commands, or adds some of its own
6
+ * - `decide`: units choose and carry out what they do: abilities, orders
7
+ * - `move`: everything that moves, moves
8
+ * - `resolve`: what follows from where things ended up: attacks land, buildings go up, units are trained
9
+ * - `cleanup`: bookkeeping once everything happened: what runs out, what each team sees, who won
10
+ *
11
+ * @beta
12
+ */
13
+ export declare const PHASES: readonly SystemPhase[];
14
+ /**
15
+ * What the scheduler measured of a system: milliseconds per tick, averaged, with the ticks it does not run counted as nothing
16
+ *
17
+ * @beta
18
+ */
19
+ export interface SystemTiming {
20
+ name: string;
21
+ phase: SystemPhase;
22
+ ms: number;
23
+ }
24
+ /**
25
+ * Runs the systems of a world in their order, each as often as it asks. The order is worked out whenever a system
26
+ * is added or taken out: by phase first, then by what each says it comes `before` or `after`, then in the order
27
+ * they were added. Measures each one while `profiling` is on, for the stats panel.
28
+ *
29
+ * @beta
30
+ */
31
+ export declare class Scheduler {
32
+ private readonly added;
33
+ private ordered;
34
+ private readonly timings;
35
+ /** Whether to time each system. Costs two clock readings per system per tick, so it is off unless someone looks */
36
+ profiling: boolean;
37
+ constructor(systems: System[]);
38
+ /** The systems, in the order they run */
39
+ get systems(): readonly System[];
40
+ /** Adds a system to a world that is already running, like a computer player */
41
+ add(system: System): void;
42
+ /** Takes a system out by name. False when there is none of that name */
43
+ remove(name: string): boolean;
44
+ /** Runs one tick of every system that is due. Each is given the time since it last ran */
45
+ run(world: World): void;
46
+ /** Runs a system. One that throws comes to what the world says of errors (`World.caught`): switched off, where it says so */
47
+ private update;
48
+ private readonly off;
49
+ /** Switches a system off: it no longer runs, and stays off when others are added */
50
+ disable(name: string): void;
51
+ /** What each system takes, in the order they run. Empty until `profiling` has been on for a while */
52
+ timing(): SystemTiming[];
53
+ private check;
54
+ }
55
+ /** What `order` sorts: a system, or anything else that runs in turn and says what it comes before and after (a brain's modules) */
56
+ export interface Ordered {
57
+ name: string;
58
+ phase?: SystemPhase;
59
+ before?: string[];
60
+ after?: string[];
61
+ }
62
+ /**
63
+ * Sorts systems by phase, then by `before` and `after`, keeping the order they were given in where nothing says
64
+ * otherwise. Names that are not among them are passed over: what they named may have been left out of the game.
65
+ * The modules of a computer player's brain are put in their order by it too (`ai/brain.ts`)
66
+ */
67
+ export declare function order<T extends Ordered>(systems: T[]): T[];