@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,49 @@
1
+ import type { Entity } from '#engine/entity';
2
+ import { type PlayerFacts } from '#engine/shared';
3
+ import { type Cost } from '#engine/defs';
4
+ import type { ProductionKind } from '#engine/hooks';
5
+ import type { System } from '#engine/registry';
6
+ import type { World } from '#engine/world';
7
+ /**
8
+ * Lets the `beforeProduce` hook have its say about something about to be made, then has the player pay for it.
9
+ * What it ends up costing and how long it takes, or undefined when it is not made (and the player was told why).
10
+ * `producer` is the building it is made in, or the worker putting down a structure
11
+ */
12
+ export declare function startProducing(world: World, producer: Entity, kind: ProductionKind, id: string, cost: Cost | undefined, time: number): {
13
+ cost: Cost;
14
+ time: number;
15
+ } | undefined;
16
+ /** Queues a unit for training. Returns false (and tells the player why) when that is not possible. */
17
+ export declare function enqueueProduction(world: World, building: Entity, unitType: string): boolean;
18
+ /**
19
+ * What there is to know about a player for whether they can make something, see `trainRefusal`
20
+ *
21
+ * @beta
22
+ */
23
+ export declare function playerFacts(world: World, playerId: number): PlayerFacts;
24
+ /**
25
+ * Levels of an upgrade a player has, counting the one being researched
26
+ *
27
+ * @beta
28
+ */
29
+ export declare function upgradeLevel(world: World, playerId: number, upgrade: string): {
30
+ level: number;
31
+ researching: boolean;
32
+ };
33
+ /** Queues an upgrade. One level at a time, and only in one building at once. */
34
+ export declare function enqueueResearch(world: World, building: Entity, upgrade: string): boolean;
35
+ /** Queues bringing a fallen hero back */
36
+ export declare function enqueueRevive(world: World, building: Entity, heroId: number): boolean;
37
+ /**
38
+ * Queues upgrading a building into a type it can become (`UnitTypeDef.upgradesTo`): `into`, one of them, or the first
39
+ * where none is named. One at a time
40
+ */
41
+ export declare function enqueueMorph(world: World, building: Entity, into?: string): boolean;
42
+ export declare function cancelProduction(world: World, building: Entity, index: number): boolean;
43
+ export declare const productionSystem: System;
44
+ /** A unit made, to those who see it */
45
+ export declare const toldTrained: import("..").ReplicatedEvent;
46
+ /** Research done: to its side */
47
+ export declare const toldResearched: import("..").ReplicatedEvent;
48
+ /** A building starting to become another, to those who see it */
49
+ export declare const toldUpgradeStarted: import("..").ReplicatedEvent;
@@ -0,0 +1,40 @@
1
+ import type { Entity, ProductionItem, ProductionState } from '#engine/entity';
2
+ import type { World } from '#engine/world';
3
+ import type { EntityState, ProductionInfo, QueueItemState } from '#engine/session/protocol';
4
+ /**
5
+ * What a building makes (`UnitTypeDef.trains`, `researches`, `upgradesTo`, `revives`): its queue, and where what comes
6
+ * out goes. Set as it is spawned (and as its type changes), for a type that makes anything. Its owner and their allies
7
+ * are told the queue and the rally point; everyone who sees it how far it is in turning into another type
8
+ * (`ProductionInfo`)
9
+ *
10
+ * @beta
11
+ */
12
+ export declare const productionQueue: import("#engine/components").Component<ProductionState, ProductionInfo>;
13
+ /**
14
+ * What a building makes, and where it goes: none for a type that makes nothing (`productionQueue`)
15
+ *
16
+ * @beta
17
+ */
18
+ export declare const productionOf: (entity: Entity) => ProductionState | undefined;
19
+ /**
20
+ * What a building in a snapshot makes, the first being made: empty for one that makes nothing, or another's (a
21
+ * screen's, a computer player's view)
22
+ *
23
+ * @beta
24
+ */
25
+ export declare const queueOf: (state: EntityState) => readonly QueueItemState[];
26
+ /**
27
+ * The type a building in a snapshot is turning into, and how far, 0..1: undefined for one that is not
28
+ *
29
+ * @beta
30
+ */
31
+ export declare function upgradeOf(state: EntityState): {
32
+ to: string;
33
+ progress: number;
34
+ } | undefined;
35
+ /** What a building had queued, given back: the money paid, a hero no longer coming back, research no longer under way */
36
+ export declare function giveBack(world: World, building: Entity, item: ProductionItem): void;
37
+ /** Gives back everything a building had queued, for when it is destroyed */
38
+ export declare function cancelAllProduction(world: World, building: Entity): void;
39
+ /** A building's becoming another called off, to those who see it */
40
+ export declare const toldUpgradeCancelled: import("..").ReplicatedEvent;
@@ -0,0 +1,14 @@
1
+ import type { System } from '#engine/registry';
2
+ import type { World } from '#engine/world';
3
+ /** Puts a player out of the game: they are told, and see the whole map from then on */
4
+ export declare function defeat(world: World, playerId: number): void;
5
+ /**
6
+ * The rule of a melee game: whoever has no building left is out, and the last team in the game wins.
7
+ * Players only take part once they have had a building, so a world with nothing but a few units
8
+ * in it, like most tests, has no losers. Game modules with other ways to win bring their own system.
9
+ *
10
+ * @beta
11
+ */
12
+ export declare const lastTeamStanding: System;
13
+ /** Whether the player's team won, lost or plays on (`Snapshot.outcome`): an observer neither wins nor loses */
14
+ export declare const outcomePart: import("..").SnapshotPart<keyof import("..").Snapshot>;
package/dist/talk.d.ts ADDED
@@ -0,0 +1,65 @@
1
+ import type { PlayerId } from './entity';
2
+ import type { Registry } from './registry';
3
+ import type { Vec2 } from './math';
4
+ import type { World } from './world';
5
+ /**
6
+ * When each player's last ones of each kind went out (`ping:1`, the world's times): the world's, and saved with it, so
7
+ * that a player who used up the limit is still refused in the game loaded from a save, as in the game that went on
8
+ */
9
+ export declare const sent: import("./components").Component<Record<string, number[]>, Record<string, number[]>>;
10
+ /**
11
+ * Whether a player may send another of a kind now: and counts it, when they may
12
+ *
13
+ * @beta
14
+ */
15
+ export declare function allowed(world: World, player: PlayerId, kind: string, limit: {
16
+ most: number;
17
+ within: number;
18
+ }): boolean;
19
+ /**
20
+ * The kinds of ping hero arena games have: a game's are its rules' (`GameRules.talk.pings.kinds`), `look` first
21
+ *
22
+ * @beta
23
+ */
24
+ export declare const PING_KINDS: readonly ['look', 'danger', 'assist', 'onMyWay'];
25
+ /**
26
+ * A kind of ping: one of `GameRules.talk.pings.kinds`
27
+ *
28
+ * @beta
29
+ */
30
+ export type PingKind = string;
31
+ /**
32
+ * The kinds of ping a game's rules let go (`GameRules.talk.pings.kinds`), as they are now: its list, or what it works
33
+ * out from the registry (a file of the game's the editor writes)
34
+ *
35
+ * @beta
36
+ */
37
+ export declare function pingKinds(registry: Registry): readonly string[];
38
+ /**
39
+ * A player marks a spot of the map (`pinged`) for their allies (`to: 'allies'`, when left out) or for everyone
40
+ * (`'all'`): told to them and to who watches, as sessions do. Of a kind the game's rules have
41
+ * (`GameRules.talk.pings.kinds`), as many in a while as they let (`GameRules.talk`), and as the `beforeTalk` hook lets it,
42
+ * which may change who hears it
43
+ *
44
+ * @beta
45
+ */
46
+ export declare function ping(world: World, player: PlayerId, point: Vec2, kind?: string, to?: string, by?: string): void;
47
+ /**
48
+ * Who a line of chat or a ping is for: the player's side, everyone in the game, or who watches alone (`observers`:
49
+ * what one who watches says, which no player hears; a host gives every line of theirs this, `SessionHost`)
50
+ *
51
+ * @beta
52
+ */
53
+ export type ChatAudience = 'allies' | 'all' | 'observers';
54
+ /**
55
+ * A player says a line (`chatted`): to their side, or to everyone, and to who watches either way. Spaces run
56
+ * together, and cut to the game's length (`GameRules.talk`); nothing for an empty line, a message for too many in a
57
+ * while; and as the `beforeTalk` hook lets it, which may change the words or who hears them
58
+ *
59
+ * @beta
60
+ */
61
+ export declare function chat(world: World, player: PlayerId, text: string, to?: string, by?: string): void;
62
+ /** A ping: to everyone where it is to all, else to the pinger's side; one who watches pinged, to who watches */
63
+ export declare const toldPing: import("./replication").ReplicatedEvent;
64
+ /** A line of chat: to everyone where it is to all, else to the speaker's side; one who watches said it, to who watches */
65
+ export declare const toldChat: import("./replication").ReplicatedEvent;
package/dist/tech.d.ts ADDED
@@ -0,0 +1,62 @@
1
+ import { type Entity, type PlayerId } from './entity';
2
+ import type { World } from './world';
3
+ import { type Message } from './messages';
4
+ /**
5
+ * Types of the finished buildings a player has, with what those count as
6
+ *
7
+ * @beta
8
+ */
9
+ export declare function techOf(world: World, player: PlayerId): Set<string>;
10
+ /**
11
+ * What of a list of requirements a player does not have
12
+ *
13
+ * @beta
14
+ */
15
+ export declare function missing(world: World, player: PlayerId, requires: string[] | undefined, tech?: Set<string>): string[];
16
+ /**
17
+ * Checks requirements and tells the player what is missing. True when there is nothing in the way
18
+ *
19
+ * @beta
20
+ */
21
+ export declare function meets(world: World, player: PlayerId, requires: string[] | undefined): boolean;
22
+ /**
23
+ * Why a player may not make something as far as what it requires goes, or nothing: the finished buildings it
24
+ * requires, and then the `requirement` hook (see `Requirement`). For a unit or structure type, or a level of research
25
+ *
26
+ * @beta
27
+ */
28
+ export declare function unlockRefusal(world: World, player: PlayerId, kind: 'unit' | 'upgrade', id: string, requires: string[] | undefined, level?: number): Message | undefined;
29
+ /**
30
+ * Checks that something is the player's to make at all (`isAvailable`: their race, the `available` hook), then what it
31
+ * requires, by `unlockRefusal`, and tells the player what stands in the way. True when nothing does
32
+ *
33
+ * @beta
34
+ */
35
+ export declare function unlocked(world: World, player: PlayerId, kind: 'unit' | 'upgrade', id: string, requires: string[] | undefined, level?: number): boolean;
36
+ /**
37
+ * Turns an entity into another type, where it stands: a building upgraded, a unit transformed (a druid into a bear, a
38
+ * siege tank set up). Everything of the type is the new one's: stats, how it moves (and on the ground or in the air),
39
+ * whether it fights, gathers or carries, its abilities (those of the old type it keeps are kept as they were, at their
40
+ * levels and cooldowns), and what it makes. What it went through stays: health lost, mana, buffs, experience, items.
41
+ * The parts of the game it had none of are given it as `spawn` gives them (`Component.onSpawn`), and the `morphed` hook
42
+ * runs: what a pack gives it of its own for its new type (the heroes pack: a hero's level, a shop's wares)
43
+ *
44
+ * @beta
45
+ */
46
+ export declare function morph(world: World, entity: Entity, into: string): void;
47
+ /** What became another, to those who see it */
48
+ export declare const toldMorphed: import("./replication").ReplicatedEvent;
49
+ /**
50
+ * What the `requirement` hook decided for a player, where it is not what the requirements say: what their screen could
51
+ * not work out for itself (`PlayerState.own.unlocks`). Nothing where the hook agrees with them all
52
+ *
53
+ * @beta
54
+ */
55
+ export declare function decidedUnlocks(world: World, player: PlayerId): Record<string, Message | null> | undefined;
56
+ /**
57
+ * What the `available` hook decided for a player, where it is not what their race says: what their screen could not
58
+ * work out for itself (`PlayerState.own.availability`). Nothing where the hook agrees
59
+ *
60
+ * @beta
61
+ */
62
+ export declare function decidedAvailability(world: World, player: PlayerId): Record<string, boolean> | undefined;
@@ -0,0 +1,38 @@
1
+ import type { Registry } from './registry';
2
+ /**
3
+ * A thing of a tech tree: a unit or building type, or an upgrade, on its tier (0: made from the start)
4
+ *
5
+ * @beta
6
+ */
7
+ export interface TechNode {
8
+ id: string;
9
+ kind: 'unit' | 'building' | 'upgrade';
10
+ name: string;
11
+ tier: number;
12
+ /** The race it is of, where it says */
13
+ race?: string;
14
+ }
15
+ /**
16
+ * How one thing of a tech tree leads to another: `from` makes `to` (trains, builds, hires, researches, upgrades to),
17
+ * or `to` requires `from`
18
+ *
19
+ * @beta
20
+ */
21
+ export interface TechEdge {
22
+ from: string;
23
+ to: string;
24
+ kind: 'trains' | 'builds' | 'hires' | 'researches' | 'upgradesTo' | 'requires';
25
+ }
26
+ /**
27
+ * The tech tree of a game's rules: its things that are made or make something (scenery and the map's creeps left
28
+ * out), the edges between them, and each one's tier. Tiers go by what makes what from what nothing makes and from the
29
+ * buildings that make the builders, require nothing and are no other's upgrade (a hall; else, where everything is
30
+ * made of something, the buildings that require nothing, are no upgrade and make something),
31
+ * each thing after what it requires; a loop of requirements stops at the number of things
32
+ *
33
+ * @beta
34
+ */
35
+ export declare function techTree(registry: Pick<Registry, 'units' | 'upgrades'>): {
36
+ nodes: TechNode[];
37
+ edges: TechEdge[];
38
+ };
@@ -0,0 +1,173 @@
1
+ import { type Vec2 } from './math';
2
+ /** @beta */
3
+ export interface TerrainMesh {
4
+ positions: Float32Array;
5
+ indices: Uint32Array;
6
+ }
7
+ /**
8
+ * What covers a cell: nothing, water that can be waded through, or water nothing on foot crosses
9
+ *
10
+ * @beta
11
+ */
12
+ export declare const WATER_NONE = 0;
13
+ /** @beta */
14
+ export declare const WATER_SHALLOW = 1;
15
+ /** @beta */
16
+ export declare const WATER_DEEP = 2;
17
+ /**
18
+ * Water and paint of a terrain, next to its shape. Left out for plain ground
19
+ *
20
+ * @beta
21
+ */
22
+ export interface TerrainSurface {
23
+ /** `WATER_*` per cell, row by row */
24
+ water?: Uint8Array;
25
+ /** Height of the surface of the water per vertex, for drawing it. Only means something around wet cells */
26
+ waterHeights?: Float32Array;
27
+ /** What the ground is painted with per cell, row by row. 0 is left to the slope, what the rest are is up to the client */
28
+ tiles?: Uint8Array;
29
+ /** What scenery keeps off each cell (`BLOCKS_BUILD`, `BLOCKS_WALK`), row by row: see `MapDoodad.blocks` */
30
+ blocked?: Uint8Array;
31
+ /** The game's own layers of cells (`CellLayerDef`), by id: a value per cell, row by row */
32
+ cells?: Record<string, Uint8Array>;
33
+ }
34
+ /**
35
+ * Heightfield ground. World space spans [0, width] x [0, depth] with one height sample per unit.
36
+ * Rendering, navigation and the simulation all read from this same data.
37
+ *
38
+ * Next to the height, every cell has a level: the ground floor is 0, each cliff up is one more. The height is
39
+ * what things stand on and where the eye sees a cliff, the level is what the rules go by: who sees whom
40
+ * and who shoots uphill. Ramps belong to the lower level until halfway up.
41
+ *
42
+ * @beta
43
+ */
44
+ export declare class Terrain {
45
+ readonly width: number;
46
+ readonly depth: number;
47
+ readonly heights: Float32Array;
48
+ readonly vertsX: number;
49
+ readonly vertsZ: number;
50
+ /** Level per cell, row by row. The fog works out what is seen from them once: `world.fog.levelsChanged()` after writing to them in a running world */
51
+ readonly levels: Uint8Array;
52
+ /** `WATER_*` per cell, row by row */
53
+ readonly water: Uint8Array;
54
+ /** Height of the surface of the water per vertex */
55
+ readonly waterHeights: Float32Array;
56
+ /** Paint per cell, row by row */
57
+ readonly tiles: Uint8Array;
58
+ /** What scenery keeps off each cell, row by row: 1 building there, 2 walking and building (see `MapDoodad.blocks`) */
59
+ readonly blocked: Uint8Array;
60
+ /**
61
+ * The game's own layers of cells, by id (`CellLayerDef`): where the bushes are, what burns. A value per cell, row by
62
+ * row; a layer nobody has painted is not there, and reads 0 everywhere (`cellAt`)
63
+ */
64
+ readonly cells: Record<string, Uint8Array>;
65
+ /**
66
+ * The part of the map play happens in, in cells, when it is not all of it (`GameMap.bounds`): nothing on foot goes
67
+ * outside it, nothing is built there, and the camera keeps to it. The edge beyond is scenery
68
+ */
69
+ bounds?: {
70
+ x: number;
71
+ z: number;
72
+ width: number;
73
+ depth: number;
74
+ };
75
+ constructor(width: number, depth: number, heights: Float32Array, levels?: Uint8Array, surface?: TerrainSurface);
76
+ /** The value of a layer of cells (`cells`) at a point: 0 off the ground, or where the layer is not there */
77
+ cellAt(layer: string, x: number, z: number): number;
78
+ /** A layer of cells, made empty when it is not there yet */
79
+ cellLayer(layer: string): Uint8Array;
80
+ /**
81
+ * Becomes another terrain, of whatever size, in place: what holds on to this one (the camera, what draws the ground)
82
+ * sees the new one. For the editor, when a map is resized
83
+ */
84
+ replace(other: Terrain): void;
85
+ /** Whether a cell is in the part of the map play happens in (`bounds`) */
86
+ inPlay(cx: number, cz: number): boolean;
87
+ /** `WATER_*` of the cell a point is in */
88
+ waterAt(x: number, z: number): number;
89
+ vertexHeight(ix: number, iz: number): number;
90
+ /** Level of the cell a point is in */
91
+ levelAt(x: number, z: number): number;
92
+ contains(x: number, z: number): boolean;
93
+ /** Height at any point, interpolated over the same triangles `buildMesh` produces. */
94
+ heightAt(x: number, z: number): number;
95
+ /** Surface normal (unnormalized y is always positive). */
96
+ normalAt(x: number, z: number, out: {
97
+ x: number;
98
+ y: number;
99
+ z: number;
100
+ }): void;
101
+ /** Steepness in radians, 0 = flat. */
102
+ slopeAt(x: number, z: number): number;
103
+ /** First intersection of a ray with the ground, or null. */
104
+ raycast(ox: number, oy: number, oz: number, dx: number, dy: number, dz: number, maxDist?: number): {
105
+ x: number;
106
+ y: number;
107
+ z: number;
108
+ } | null;
109
+ /** @param walkable leaves out what nothing on foot may cross, for the navigation */
110
+ buildMesh(walkable?: boolean): TerrainMesh;
111
+ /** Whether any cell is deep water: what boats go on */
112
+ get hasDeepWater(): boolean;
113
+ /**
114
+ * The deep water as a mesh, at its surface: where what goes on water can go (`UnitTypeDef.naval`). Under a bridge
115
+ * too. Empty where the map has no deep water
116
+ */
117
+ buildWaterMesh(): TerrainMesh;
118
+ /** The height of the water's surface at a point, over the same triangles as the ground */
119
+ waterHeightAt(x: number, z: number): number;
120
+ }
121
+ /**
122
+ * A way up a plateau
123
+ *
124
+ * @beta
125
+ */
126
+ export interface RampSpec {
127
+ /** The ramp comes down on the side of the plateau that faces this point */
128
+ towards: Vec2;
129
+ /** How wide it is, in world units */
130
+ width?: number;
131
+ }
132
+ /**
133
+ * High ground: a roughly round area lifted by whole levels, with cliffs all around except where a ramp leads up
134
+ *
135
+ * @beta
136
+ */
137
+ export interface PlateauSpec {
138
+ x: number;
139
+ z: number;
140
+ radius: number;
141
+ /** How many levels it rises above what is around it. One when left out */
142
+ levels?: number;
143
+ ramps?: RampSpec[];
144
+ }
145
+ /** @beta */
146
+ export interface TerrainGenOptions {
147
+ width: number;
148
+ depth: number;
149
+ seed: number;
150
+ /** Height of the rolling hills */
151
+ hillHeight?: number;
152
+ /** Size of the hills in world units */
153
+ hillScale?: number;
154
+ /** Steep unwalkable rock formations */
155
+ rocks?: {
156
+ x: number;
157
+ z: number;
158
+ radius: number;
159
+ height: number;
160
+ }[];
161
+ /** Areas levelled to a constant height, for bases */
162
+ flats?: {
163
+ x: number;
164
+ z: number;
165
+ radius: number;
166
+ }[];
167
+ /** High ground with cliffs and ramps */
168
+ plateaus?: PlateauSpec[];
169
+ /** How much higher one level stands than the one below */
170
+ cliffHeight?: number;
171
+ }
172
+ /** @beta */
173
+ export declare function generateTerrain(options: TerrainGenOptions): Terrain;
@@ -0,0 +1,29 @@
1
+ /**
2
+ * A terrain as plain data: in a save, and sent to a remote player as the game starts
3
+ *
4
+ * @beta
5
+ */
6
+ export interface TerrainSave {
7
+ width: number;
8
+ depth: number;
9
+ /**
10
+ * Each layer as packed bytes (see `packBytes`), or, where every cell holds the same, that value: a map without water
11
+ * or cliffs, of one ground, says so in a few characters rather than a few hundred thousand
12
+ */
13
+ heights: string | number;
14
+ levels: string | number;
15
+ water: string | number;
16
+ waterHeights: string | number;
17
+ tiles: string | number;
18
+ /** What scenery keeps off each cell. Left out by saves from before there was any */
19
+ blocked?: string | number;
20
+ /** The game's layers of cells (`Terrain.cells`), by id, as the other layers. Left out when there are none */
21
+ cells?: Record<string, string | number>;
22
+ /** The part of the map play happens in, when it is not all of it */
23
+ bounds?: {
24
+ x: number;
25
+ z: number;
26
+ width: number;
27
+ depth: number;
28
+ };
29
+ }
@@ -0,0 +1,58 @@
1
+ /**
2
+ * `@v12-engine/engine/testing`: what a game's tests are written with. A world runs in a test as it does in a page, with no
3
+ * screen: these make one, step it and give its units orders, so that a test says what happens in the game and little
4
+ * else.
5
+ *
6
+ * const world = await testWorld(myGame.rules)
7
+ * const knight = world.spawn('knight', 1, { x: 10, z: 10 })
8
+ * order(world, [knight], { type: 'move', point: { x: 30, z: 10 } })
9
+ * run(world, 5, () => knight.pos.x > 29)
10
+ */
11
+ import type { Entity } from './entity';
12
+ import { type GameModule } from './game';
13
+ import type { PlayerInit } from './player';
14
+ import type { Logger } from './log';
15
+ import type { OrderInit } from './registry';
16
+ import { Terrain } from './terrain';
17
+ import type { World } from './world';
18
+ /**
19
+ * Flat ground, `size` cells a side: 48 when left out
20
+ *
21
+ * @beta
22
+ */
23
+ export declare const flatTerrain: (size?: number) => Terrain;
24
+ /**
25
+ * The players of a test world, when a test says none: a neutral one, and two who are enemies
26
+ *
27
+ * @beta
28
+ */
29
+ export declare const TEST_PLAYERS: PlayerInit[];
30
+ /**
31
+ * A small world of a game for a test: flat ground, a neutral player and two enemies (`TEST_PLAYERS`), the same every
32
+ * time (seed 7). Each of them is the test's to say otherwise
33
+ *
34
+ * @beta
35
+ */
36
+ export declare function testWorld(game: GameModule, options?: {
37
+ terrain?: Terrain;
38
+ size?: number;
39
+ players?: PlayerInit[];
40
+ seed?: number;
41
+ log?: Logger;
42
+ }): Promise<World>;
43
+ /**
44
+ * Steps the world for up to `seconds`, stopping early once `until` holds. Returns the time that went by in it
45
+ *
46
+ * @beta
47
+ */
48
+ export declare function run(world: World, seconds: number, until?: () => boolean): number;
49
+ /**
50
+ * Gives units an order, as their owner would: taken up at the next tick. `queue` adds it after what they are doing
51
+ *
52
+ * @beta
53
+ */
54
+ export declare const order: (world: World, entities: Entity[], init: OrderInit, queue?: boolean) => void;
55
+ export { fixtureGame, fixtureMap } from './fixture';
56
+ export { type BrainResults, type ComputerMeasures, defineSimulation, playGame, type Counted, type SimulatedGame, type SimulateOptions, simulate, type Simulation, winRates } from './simulate';
57
+ export { brainOf, checkComputerSave, type ComputerWatch, type DecisionRecorder, type DecisionsApart, expectDecision, type FairPlay, fairPlay, type RecordedDecision, recordDecisions, thinkOnce, watchComputer, type WatchOptions } from './aiTesting';
58
+ export { type Apart, checkDeterminism, type DeterminismOptions, type DeterminismReport, type Difference, firstDifference, worldFingerprint, worldHash, worldState } from './determinism';