@v12-engine/engine 0.1.1 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/abilities/amounts.d.ts +28 -0
- package/dist/abilities/amounts.js +74 -0
- package/dist/abilities/amounts.js.map +1 -0
- package/dist/abilities/buffs.d.ts +106 -6
- package/dist/abilities/buffs.js +443 -0
- package/dist/abilities/buffs.js.map +1 -0
- package/dist/abilities/castTold.d.ts +2 -0
- package/dist/abilities/castTold.js +66 -0
- package/dist/abilities/castTold.js.map +1 -0
- package/dist/abilities/chance.d.ts +38 -0
- package/dist/abilities/chance.js +77 -0
- package/dist/abilities/chance.js.map +1 -0
- package/dist/abilities/charges.d.ts +18 -0
- package/dist/abilities/charges.js +101 -0
- package/dist/abilities/charges.js.map +1 -0
- package/dist/abilities/control.d.ts +28 -0
- package/dist/abilities/control.js +113 -0
- package/dist/abilities/control.js.map +1 -0
- package/dist/abilities/dispel.js +51 -0
- package/dist/abilities/dispel.js.map +1 -0
- package/dist/abilities/effectFields.d.ts +1 -1
- package/dist/abilities/effectFields.js +676 -0
- package/dist/abilities/effectFields.js.map +1 -0
- package/dist/abilities/effectIndex.d.ts +27 -0
- package/dist/abilities/effectIndex.js +64 -0
- package/dist/abilities/effectIndex.js.map +1 -0
- package/dist/abilities/effects/buff.d.ts +9 -3
- package/dist/abilities/effects/buff.js +84 -0
- package/dist/abilities/effects/buff.js.map +1 -0
- package/dist/abilities/effects/conditions.d.ts +2 -0
- package/dist/abilities/effects/conditions.js +41 -0
- package/dist/abilities/effects/conditions.js.map +1 -0
- package/dist/abilities/effects/core.js +54 -0
- package/dist/abilities/effects/core.js.map +1 -0
- package/dist/abilities/effects/damage.d.ts +1 -1
- package/dist/abilities/effects/damage.js +43 -0
- package/dist/abilities/effects/damage.js.map +1 -0
- package/dist/abilities/effects/heal.d.ts +2 -2
- package/dist/abilities/effects/heal.js +51 -0
- package/dist/abilities/effects/heal.js.map +1 -0
- package/dist/abilities/effects/missile.d.ts +13 -1
- package/dist/abilities/effects/missile.js +104 -0
- package/dist/abilities/effects/missile.js.map +1 -0
- package/dist/abilities/effects/morph.d.ts +5 -0
- package/dist/abilities/effects/morph.js +43 -0
- package/dist/abilities/effects/morph.js.map +1 -0
- package/dist/abilities/effects/moves.d.ts +16 -4
- package/dist/abilities/effects/moves.js +212 -0
- package/dist/abilities/effects/moves.js.map +1 -0
- package/dist/abilities/effects/passives.d.ts +19 -9
- package/dist/abilities/effects/passives.js +131 -0
- package/dist/abilities/effects/passives.js.map +1 -0
- package/dist/abilities/effects/proxy.d.ts +5 -0
- package/dist/abilities/effects/proxy.js +60 -0
- package/dist/abilities/effects/proxy.js.map +1 -0
- package/dist/abilities/effects/sight.d.ts +2 -2
- package/dist/abilities/effects/sight.js +39 -0
- package/dist/abilities/effects/sight.js.map +1 -0
- package/dist/abilities/effects/spawn.d.ts +5 -2
- package/dist/abilities/effects/spawn.js +40 -0
- package/dist/abilities/effects/spawn.js.map +1 -0
- package/dist/abilities/effects/timed.d.ts +2 -2
- package/dist/abilities/effects/timed.js +96 -0
- package/dist/abilities/effects/timed.js.map +1 -0
- package/dist/abilities/effects/trade.d.ts +1 -1
- package/dist/abilities/effects/trade.js +25 -0
- package/dist/abilities/effects/trade.js.map +1 -0
- package/dist/abilities/effects.d.ts +97 -23
- package/dist/abilities/effects.js +860 -0
- package/dist/abilities/effects.js.map +1 -0
- package/dist/abilities/land.d.ts +38 -4
- package/dist/abilities/land.js +189 -0
- package/dist/abilities/land.js.map +1 -0
- package/dist/abilities/recast.d.ts +45 -0
- package/dist/abilities/recast.js +118 -0
- package/dist/abilities/recast.js.map +1 -0
- package/dist/abilities/scaled.js +40 -0
- package/dist/abilities/scaled.js.map +1 -0
- package/dist/abilities/screen.d.ts +6 -0
- package/dist/abilities/screen.js +83 -0
- package/dist/abilities/screen.js.map +1 -0
- package/dist/abilities/shapes.d.ts +66 -0
- package/dist/abilities/shapes.js +122 -0
- package/dist/abilities/shapes.js.map +1 -0
- package/dist/abilities/text.d.ts +14 -2
- package/dist/abilities/text.js +204 -0
- package/dist/abilities/text.js.map +1 -0
- package/dist/abilities/triggers.d.ts +98 -0
- package/dist/abilities/triggers.js +351 -0
- package/dist/abilities/triggers.js.map +1 -0
- package/dist/abilityChanges.d.ts +131 -0
- package/dist/abilityChanges.js +345 -0
- package/dist/abilityChanges.js.map +1 -0
- package/dist/ai/area.d.ts +4 -1
- package/dist/ai/brain.d.ts +4 -1
- package/dist/ai/brain.js +844 -0
- package/dist/ai/brain.js.map +1 -0
- package/dist/ai/budget.js +74 -0
- package/dist/ai/budget.js.map +1 -0
- package/dist/ai/checks.d.ts +9 -1
- package/dist/ai/checks.js +242 -0
- package/dist/ai/checks.js.map +1 -0
- package/dist/ai/computer.d.ts +11 -4
- package/dist/ai/computer.js +251 -0
- package/dist/ai/computer.js.map +1 -0
- package/dist/ai/defence.d.ts +4 -0
- package/dist/ai/defence.js +430 -0
- package/dist/ai/defence.js.map +1 -0
- package/dist/ai/define.d.ts +3 -2
- package/dist/ai/define.js +31 -0
- package/dist/ai/define.js.map +1 -0
- package/dist/ai/economy.d.ts +10 -7
- package/dist/ai/economy.js +780 -0
- package/dist/ai/economy.js.map +1 -0
- package/dist/ai/geometry.js +38 -0
- package/dist/ai/geometry.js.map +1 -0
- package/dist/ai/goals.d.ts +1 -0
- package/dist/ai/goals.js +560 -0
- package/dist/ai/goals.js.map +1 -0
- package/dist/ai/knowledge.d.ts +72 -7
- package/dist/ai/knowledge.js +804 -0
- package/dist/ai/knowledge.js.map +1 -0
- package/dist/ai/lanes.d.ts +10 -2
- package/dist/ai/lanes.js +715 -0
- package/dist/ai/lanes.js.map +1 -0
- package/dist/ai/melee/build.js +264 -0
- package/dist/ai/melee/build.js.map +1 -0
- package/dist/ai/melee/goals.d.ts +7 -0
- package/dist/ai/melee/goals.js +720 -0
- package/dist/ai/melee/goals.js.map +1 -0
- package/dist/ai/melee/heroes.js +68 -0
- package/dist/ai/melee/heroes.js.map +1 -0
- package/dist/ai/melee/index.d.ts +1 -1
- package/dist/ai/melee/index.js +51 -0
- package/dist/ai/melee/index.js.map +1 -0
- package/dist/ai/melee/production.js +29 -0
- package/dist/ai/melee/production.js.map +1 -0
- package/dist/ai/melee/surrender.js +64 -0
- package/dist/ai/melee/surrender.js.map +1 -0
- package/dist/ai/micro.d.ts +9 -0
- package/dist/ai/micro.js +1316 -0
- package/dist/ai/micro.js.map +1 -0
- package/dist/ai/mission.d.ts +9 -2
- package/dist/ai/mission.js +538 -0
- package/dist/ai/mission.js.map +1 -0
- package/dist/ai/missionRules.d.ts +1 -1
- package/dist/ai/missionRules.js +26 -0
- package/dist/ai/missionRules.js.map +1 -0
- package/dist/ai/module.d.ts +6 -2
- package/dist/ai/module.js +37 -0
- package/dist/ai/module.js.map +1 -0
- package/dist/ai/options.d.ts +3 -3
- package/dist/ai/plans/build.d.ts +20 -1
- package/dist/ai/plans/build.js +608 -0
- package/dist/ai/plans/build.js.map +1 -0
- package/dist/ai/plans/placement.d.ts +4 -1
- package/dist/ai/plans/placement.js +295 -0
- package/dist/ai/plans/placement.js.map +1 -0
- package/dist/ai/plans/plans.d.ts +9 -0
- package/dist/ai/plans/plans.js +110 -0
- package/dist/ai/plans/plans.js.map +1 -0
- package/dist/ai/plans/production.d.ts +14 -2
- package/dist/ai/plans/production.js +434 -0
- package/dist/ai/plans/production.js.map +1 -0
- package/dist/ai/plans/purse.d.ts +6 -3
- package/dist/ai/plans/purse.js +139 -0
- package/dist/ai/plans/purse.js.map +1 -0
- package/dist/ai/plans/tech.d.ts +6 -0
- package/dist/ai/plans/tech.js +122 -0
- package/dist/ai/plans/tech.js.map +1 -0
- package/dist/ai/profiles.d.ts +4 -4
- package/dist/{profiles-B3NS9jwk.js → ai/profiles.js} +3 -98
- package/dist/ai/profiles.js.map +1 -0
- package/dist/ai/reach.js +54 -0
- package/dist/ai/reach.js.map +1 -0
- package/dist/ai/report.d.ts +8 -0
- package/dist/ai/report.js +87 -0
- package/dist/ai/report.js.map +1 -0
- package/dist/ai/roles.d.ts +4 -0
- package/dist/ai/roles.js +207 -0
- package/dist/ai/roles.js.map +1 -0
- package/dist/ai/rules.d.ts +8 -2
- package/dist/ai/rules.js +416 -0
- package/dist/ai/rules.js.map +1 -0
- package/dist/ai/scouting.d.ts +6 -0
- package/dist/ai/scouting.js +324 -0
- package/dist/ai/scouting.js.map +1 -0
- package/dist/ai/settings.js +99 -0
- package/dist/ai/settings.js.map +1 -0
- package/dist/ai/squads.d.ts +21 -2
- package/dist/ai/squads.js +916 -0
- package/dist/ai/squads.js.map +1 -0
- package/dist/ai/strength.js +320 -0
- package/dist/ai/strength.js.map +1 -0
- package/dist/ai/task.d.ts +3 -1
- package/dist/ai/task.js +17 -0
- package/dist/ai/task.js.map +1 -0
- package/dist/ai/tasks/attack.js +24 -0
- package/dist/ai/tasks/attack.js.map +1 -0
- package/dist/ai/tasks/capture.d.ts +3 -3
- package/dist/ai/tasks/capture.js +37 -0
- package/dist/ai/tasks/capture.js.map +1 -0
- package/dist/ai/tasks/creep.js +29 -0
- package/dist/ai/tasks/creep.js.map +1 -0
- package/dist/ai/tasks/defend.js +61 -0
- package/dist/ai/tasks/defend.js.map +1 -0
- package/dist/ai/tasks/drop.js +81 -0
- package/dist/ai/tasks/drop.js.map +1 -0
- package/dist/ai/tasks/escort.js +59 -0
- package/dist/ai/tasks/escort.js.map +1 -0
- package/dist/ai/tasks/gather.js +48 -0
- package/dist/ai/tasks/gather.js.map +1 -0
- package/dist/ai/tasks/harass.js +39 -0
- package/dist/ai/tasks/harass.js.map +1 -0
- package/dist/ai/tasks/hold.js +32 -0
- package/dist/ai/tasks/hold.js.map +1 -0
- package/dist/ai/tasks/index.js +34 -0
- package/dist/ai/tasks/index.js.map +1 -0
- package/dist/ai/tasks/move.js +26 -0
- package/dist/ai/tasks/move.js.map +1 -0
- package/dist/ai/tasks/patrol.js +59 -0
- package/dist/ai/tasks/patrol.js.map +1 -0
- package/dist/ai/tasks/retreat.js +28 -0
- package/dist/ai/tasks/retreat.js.map +1 -0
- package/dist/ai/tasks/scout.js +73 -0
- package/dist/ai/tasks/scout.js.map +1 -0
- package/dist/ai/tasks/shared.d.ts +1 -1
- package/dist/ai/tasks/shared.js +137 -0
- package/dist/ai/tasks/shared.js.map +1 -0
- package/dist/ai/team.d.ts +18 -1
- package/dist/ai/team.js +492 -0
- package/dist/ai/team.js.map +1 -0
- package/dist/ai/threat.d.ts +6 -0
- package/dist/ai/threat.js +206 -0
- package/dist/ai/threat.js.map +1 -0
- package/dist/ai/view.d.ts +21 -7
- package/dist/ai/view.js +677 -0
- package/dist/ai/view.js.map +1 -0
- package/dist/ai/waves.d.ts +6 -0
- package/dist/ai/waves.js +410 -0
- package/dist/ai/waves.js.map +1 -0
- package/dist/ai.js +54 -6239
- package/dist/aiTesting.d.ts +6 -3
- package/dist/aiTesting.js +229 -0
- package/dist/aiTesting.js.map +1 -0
- package/dist/areas.d.ts +4 -1
- package/dist/areas.js +295 -0
- package/dist/areas.js.map +1 -0
- package/dist/attacks.d.ts +3 -3
- package/dist/attacks.js +127 -0
- package/dist/attacks.js.map +1 -0
- package/dist/burning.d.ts +267 -0
- package/dist/burning.js +795 -0
- package/dist/burning.js.map +1 -0
- package/dist/bytes.js +21 -0
- package/dist/bytes.js.map +1 -0
- package/dist/callings.d.ts +71 -0
- package/dist/callings.js +157 -0
- package/dist/callings.js.map +1 -0
- package/dist/cameraOrders.d.ts +78 -0
- package/dist/cameraOrders.js +114 -0
- package/dist/cameraOrders.js.map +1 -0
- package/dist/camps.d.ts +70 -4
- package/dist/camps.js +501 -0
- package/dist/camps.js.map +1 -0
- package/dist/capture.d.ts +15 -3
- package/dist/capture.js +304 -0
- package/dist/capture.js.map +1 -0
- package/dist/cellLayers.d.ts +78 -13
- package/dist/cellLayers.js +275 -0
- package/dist/cellLayers.js.map +1 -0
- package/dist/cellPatches.d.ts +24 -0
- package/dist/cellPatches.js +73 -0
- package/dist/cellPatches.js.map +1 -0
- package/dist/cinematics.d.ts +10 -5
- package/dist/cinematics.js +161 -0
- package/dist/cinematics.js.map +1 -0
- package/dist/clock.d.ts +2 -2
- package/dist/clock.js +78 -0
- package/dist/clock.js.map +1 -0
- package/dist/commands.d.ts +36 -4
- package/dist/commands.js +636 -0
- package/dist/commands.js.map +1 -0
- package/dist/components.d.ts +31 -10
- package/dist/components.js +74 -0
- package/dist/components.js.map +1 -0
- package/dist/computers.d.ts +4 -4
- package/dist/computers.js +194 -0
- package/dist/computers.js.map +1 -0
- package/dist/concealment.d.ts +25 -2
- package/dist/concealment.js +409 -0
- package/dist/concealment.js.map +1 -0
- package/dist/coreComponents.js +130 -0
- package/dist/coreComponents.js.map +1 -0
- package/dist/createGame.d.ts +306 -0
- package/dist/createGame.js +405 -0
- package/dist/createGame.js.map +1 -0
- package/dist/dashing.d.ts +18 -2
- package/dist/dashing.js +41 -0
- package/dist/dashing.js.map +1 -0
- package/dist/debug.d.ts +8 -0
- package/dist/debug.js +5 -3
- package/dist/debug2.js +76 -0
- package/dist/debug2.js.map +1 -0
- package/dist/debugCommands.d.ts +6 -6
- package/dist/debugCommands.js +537 -0
- package/dist/debugCommands.js.map +1 -0
- package/dist/debugging.d.ts +1 -0
- package/dist/defaultSets.d.ts +183 -0
- package/dist/defaultSets.js +216 -0
- package/dist/defaultSets.js.map +1 -0
- package/dist/definitions.d.ts +6 -0
- package/dist/definitions.js +78 -0
- package/dist/definitions.js.map +1 -0
- package/dist/defs.d.ts +1895 -165
- package/dist/defs.js +380 -0
- package/dist/defs.js.map +1 -0
- package/dist/denying.d.ts +4 -4
- package/dist/denying.js +106 -0
- package/dist/denying.js.map +1 -0
- package/dist/destructibles.d.ts +2 -2
- package/dist/destructibles.js +36 -0
- package/dist/destructibles.js.map +1 -0
- package/dist/determinism.d.ts +4 -4
- package/dist/determinism.js +247 -0
- package/dist/determinism.js.map +1 -0
- package/dist/dialog.d.ts +17 -2
- package/dist/dialog.js +108 -0
- package/dist/dialog.js.map +1 -0
- package/dist/effectRefs.js +28 -0
- package/dist/effectRefs.js.map +1 -0
- package/dist/effects.d.ts +27 -11
- package/dist/effects.js +110 -0
- package/dist/effects.js.map +1 -0
- package/dist/endings.d.ts +1 -1
- package/dist/endings.js +78 -0
- package/dist/endings.js.map +1 -0
- package/dist/engagement.d.ts +40 -6
- package/dist/engagement.js +530 -0
- package/dist/engagement.js.map +1 -0
- package/dist/engineEvents.d.ts +72 -9
- package/dist/engineEvents.js +520 -0
- package/dist/engineEvents.js.map +1 -0
- package/dist/entity.d.ts +275 -26
- package/dist/entity.js +441 -0
- package/dist/entity.js.map +1 -0
- package/dist/entityIndex.d.ts +10 -3
- package/dist/entityIndex.js +149 -0
- package/dist/entityIndex.js.map +1 -0
- package/dist/errors.d.ts +6 -2
- package/dist/errors.js +59 -0
- package/dist/errors.js.map +1 -0
- package/dist/events.d.ts +11 -5
- package/dist/events.js +158 -0
- package/dist/events.js.map +1 -0
- package/dist/exactMath.js +273 -0
- package/dist/exactMath.js.map +1 -0
- package/dist/features.d.ts +1 -1
- package/dist/features.js +127 -0
- package/dist/features.js.map +1 -0
- package/dist/fields.d.ts +25 -5
- package/dist/fields.js +140 -0
- package/dist/fields.js.map +1 -0
- package/dist/fixture.d.ts +3 -3
- package/dist/fixture.js +512 -0
- package/dist/fixture.js.map +1 -0
- package/dist/fog.d.ts +26 -3
- package/dist/fog.js +333 -0
- package/dist/fog.js.map +1 -0
- package/dist/foliage.d.ts +476 -0
- package/dist/foliage.js +1478 -0
- package/dist/foliage.js.map +1 -0
- package/dist/foliageDebug.d.ts +57 -0
- package/dist/foliageDebug.js +172 -0
- package/dist/foliageDebug.js.map +1 -0
- package/dist/foliageRegrowth.d.ts +20 -0
- package/dist/foliageRegrowth.js +332 -0
- package/dist/foliageRegrowth.js.map +1 -0
- package/dist/formState.d.ts +67 -0
- package/dist/formState.js +65 -0
- package/dist/formState.js.map +1 -0
- package/dist/formation.d.ts +46 -8
- package/dist/formation.js +297 -0
- package/dist/formation.js.map +1 -0
- package/dist/forms.d.ts +58 -0
- package/dist/forms.js +146 -0
- package/dist/forms.js.map +1 -0
- package/dist/friendlyFire.d.ts +2 -2
- package/dist/friendlyFire.js +37 -0
- package/dist/friendlyFire.js.map +1 -0
- package/dist/game.d.ts +141 -48
- package/dist/game.js +834 -0
- package/dist/game.js.map +1 -0
- package/dist/gameData.d.ts +96 -22
- package/dist/gameData.js +1690 -0
- package/dist/gameData.js.map +1 -0
- package/dist/gameFiles.d.ts +3 -3
- package/dist/gameFiles.js +14 -0
- package/dist/gameFiles.js.map +1 -0
- package/dist/gates.js +92 -0
- package/dist/gates.js.map +1 -0
- package/dist/generate.d.ts +28 -1
- package/dist/generate.js +1062 -0
- package/dist/generate.js.map +1 -0
- package/dist/generateWorker.d.ts +7 -3
- package/dist/generateWorker.js +86 -0
- package/dist/generateWorker.js.map +1 -0
- package/dist/grid.d.ts +9 -0
- package/dist/grid.js +102 -0
- package/dist/grid.js.map +1 -0
- package/dist/ground.d.ts +17 -1
- package/dist/ground.js +375 -0
- package/dist/ground.js.map +1 -0
- package/dist/groundObjects.d.ts +70 -0
- package/dist/groundObjects.js +371 -0
- package/dist/groundObjects.js.map +1 -0
- package/dist/groundSpeed.d.ts +20 -3
- package/dist/groundSpeed.js +117 -0
- package/dist/groundSpeed.js.map +1 -0
- package/dist/hero.d.ts +126 -10
- package/dist/hero.js +432 -0
- package/dist/hero.js.map +1 -0
- package/dist/holds.d.ts +94 -0
- package/dist/holds.js +305 -0
- package/dist/holds.js.map +1 -0
- package/dist/home.d.ts +1 -1
- package/dist/home.js +30 -0
- package/dist/home.js.map +1 -0
- package/dist/hooks.d.ts +339 -57
- package/dist/hooks.js +105 -0
- package/dist/hooks.js.map +1 -0
- package/dist/hotReload.d.ts +6 -5
- package/dist/hotReload.js +145 -0
- package/dist/hotReload.js.map +1 -0
- package/dist/ids.d.ts +3 -3
- package/dist/ids.js +30 -0
- package/dist/ids.js.map +1 -0
- package/dist/idsFile.d.ts +36 -0
- package/dist/idsFile.js +134 -0
- package/dist/idsFile.js.map +1 -0
- package/dist/index.d.ts +105 -68
- package/dist/index.js +194 -4701
- package/dist/inspect.d.ts +29 -2
- package/dist/{inspect-D9dWHmZ0.js → inspect.js} +21 -12
- package/dist/inspect.js.map +1 -0
- package/dist/inventory.d.ts +14 -1
- package/dist/inventory.js +84 -0
- package/dist/inventory.js.map +1 -0
- package/dist/items.d.ts +136 -8
- package/dist/items.js +585 -0
- package/dist/items.js.map +1 -0
- package/dist/lanes.d.ts +12 -3
- package/dist/lanes.js +496 -0
- package/dist/lanes.js.map +1 -0
- package/dist/life.d.ts +6 -2
- package/dist/life.js +287 -0
- package/dist/life.js.map +1 -0
- package/dist/log.d.ts +26 -3
- package/dist/log.js +192 -0
- package/dist/log.js.map +1 -0
- package/dist/manaBurn.d.ts +2 -2
- package/dist/manaBurn.js +75 -0
- package/dist/manaBurn.js.map +1 -0
- package/dist/map/file.d.ts +56 -3
- package/dist/map/file.js +264 -0
- package/dist/map/file.js.map +1 -0
- package/dist/map/images.js +61 -0
- package/dist/map/images.js.map +1 -0
- package/dist/map/look.d.ts +1 -1
- package/dist/map/look.js +30 -0
- package/dist/map/look.js.map +1 -0
- package/dist/map/pathProfile.js +183 -0
- package/dist/map/pathProfile.js.map +1 -0
- package/dist/map/resize.d.ts +4 -0
- package/dist/map/resize.js +136 -0
- package/dist/map/resize.js.map +1 -0
- package/dist/map/schema.js +257 -0
- package/dist/map/schema.js.map +1 -0
- package/dist/map/terrain.js +214 -0
- package/dist/map/terrain.js.map +1 -0
- package/dist/map/types.d.ts +92 -13
- package/dist/map/types.js +251 -0
- package/dist/map/types.js.map +1 -0
- package/dist/mapCheck/cells.js +94 -0
- package/dist/mapCheck/cells.js.map +1 -0
- package/dist/mapCheck/rules/foliage.d.ts +9 -0
- package/dist/mapCheck/rules/foliage.js +83 -0
- package/dist/mapCheck/rules/foliage.js.map +1 -0
- package/dist/mapCheck/rules/names.js +39 -0
- package/dist/mapCheck/rules/names.js.map +1 -0
- package/dist/mapCheck/rules/objects.d.ts +1 -1
- package/dist/mapCheck/rules/objects.js +56 -0
- package/dist/mapCheck/rules/objects.js.map +1 -0
- package/dist/mapCheck/rules/paths.js +32 -0
- package/dist/mapCheck/rules/paths.js.map +1 -0
- package/dist/mapCheck/rules/players.js +20 -0
- package/dist/mapCheck/rules/players.js.map +1 -0
- package/dist/mapCheck/rules/races.js +56 -0
- package/dist/mapCheck/rules/races.js.map +1 -0
- package/dist/mapCheck/rules/random.js +47 -0
- package/dist/mapCheck/rules/random.js.map +1 -0
- package/dist/mapCheck/rules/regions.js +30 -0
- package/dist/mapCheck/rules/regions.js.map +1 -0
- package/dist/mapCheck/rules/targets.js +31 -0
- package/dist/mapCheck/rules/targets.js.map +1 -0
- package/dist/mapCheck/rules/walking.js +45 -0
- package/dist/mapCheck/rules/walking.js.map +1 -0
- package/dist/mapCheck.d.ts +2 -2
- package/dist/mapCheck.js +63 -0
- package/dist/mapCheck.js.map +1 -0
- package/dist/mapFields.d.ts +25 -2
- package/dist/mapFields.js +134 -0
- package/dist/mapFields.js.map +1 -0
- package/dist/mapFile.js +176 -0
- package/dist/mapFile.js.map +1 -0
- package/dist/mapMeasure.d.ts +8 -0
- package/dist/mapMeasure.js +283 -0
- package/dist/mapMeasure.js.map +1 -0
- package/dist/mapMerge.d.ts +1 -0
- package/dist/mapMerge.js +172 -0
- package/dist/mapMerge.js.map +1 -0
- package/dist/mapObjectives.js +138 -0
- package/dist/mapObjectives.js.map +1 -0
- package/dist/mapObjects.js +80 -0
- package/dist/mapObjects.js.map +1 -0
- package/dist/math.d.ts +37 -7
- package/dist/math.js +155 -0
- package/dist/math.js.map +1 -0
- package/dist/messages.d.ts +71 -4
- package/dist/messages.js +29 -0
- package/dist/messages.js.map +1 -0
- package/dist/missionRules.d.ts +10 -2
- package/dist/{missionRules-C-bGxm0Q.js → missionRules.js} +30 -150
- package/dist/missionRules.js.map +1 -0
- package/dist/mods.d.ts +39 -20
- package/dist/mods.js +271 -0
- package/dist/mods.js.map +1 -0
- package/dist/moves.d.ts +87 -0
- package/dist/moves.js +539 -0
- package/dist/moves.js.map +1 -0
- package/dist/names.d.ts +7 -0
- package/dist/names.js +122 -0
- package/dist/names.js.map +1 -0
- package/dist/navigation/agentParams.js +14 -0
- package/dist/navigation/agentParams.js.map +1 -0
- package/dist/navigation/air.d.ts +7 -3
- package/dist/navigation/air.js +401 -0
- package/dist/navigation/air.js.map +1 -0
- package/dist/navigation/builds.d.ts +34 -2
- package/dist/navigation/builds.js +287 -0
- package/dist/navigation/builds.js.map +1 -0
- package/dist/navigation/groundAreas.d.ts +59 -1
- package/dist/navigation/groundAreas.js +407 -0
- package/dist/navigation/groundAreas.js.map +1 -0
- package/dist/navigation/navigation.d.ts +98 -9
- package/dist/navigation/recast.d.ts +194 -18
- package/dist/navigation/recast.js +1379 -0
- package/dist/navigation/recast.js.map +1 -0
- package/dist/navigation/sidePaths.d.ts +8 -3
- package/dist/navigation/sidePaths.js +241 -0
- package/dist/navigation/sidePaths.js.map +1 -0
- package/dist/navigation/sized.js +243 -0
- package/dist/navigation/sized.js.map +1 -0
- package/dist/nearest.js +32 -0
- package/dist/nearest.js.map +1 -0
- package/dist/noise.js +59 -0
- package/dist/noise.js.map +1 -0
- package/dist/objectives.d.ts +12 -3
- package/dist/objectives.js +144 -0
- package/dist/objectives.js.map +1 -0
- package/dist/orders/basic.d.ts +5 -5
- package/dist/orders/basic.js +417 -0
- package/dist/orders/basic.js.map +1 -0
- package/dist/orders/build.js +278 -0
- package/dist/orders/build.js.map +1 -0
- package/dist/orders/cast.d.ts +13 -3
- package/dist/orders/cast.js +558 -0
- package/dist/orders/cast.js.map +1 -0
- package/dist/orders/facts.js +16 -0
- package/dist/orders/facts.js.map +1 -0
- package/dist/orders/harvest.d.ts +21 -5
- package/dist/orders/harvest.js +540 -0
- package/dist/orders/harvest.js.map +1 -0
- package/dist/orders/idle.d.ts +3 -1
- package/dist/orders/idle.js +234 -0
- package/dist/orders/idle.js.map +1 -0
- package/dist/orders/items.js +92 -0
- package/dist/orders/items.js.map +1 -0
- package/dist/orders/queue.js +108 -0
- package/dist/orders/queue.js.map +1 -0
- package/dist/orders/waiting.d.ts +39 -0
- package/dist/orders/waiting.js +149 -0
- package/dist/orders/waiting.js.map +1 -0
- package/dist/pack.schema.js +13 -0
- package/dist/pack.schema.js.map +1 -0
- package/dist/pack.schema.json +7622 -841
- package/dist/packs/director/index.d.ts +13 -5
- package/dist/packs/director/index.js +204 -0
- package/dist/packs/director/index.js.map +1 -0
- package/dist/packs/heroes/campaign.d.ts +3 -2
- package/dist/packs/heroes/campaign.js +241 -0
- package/dist/packs/heroes/campaign.js.map +1 -0
- package/dist/packs/heroes/carry.d.ts +6 -0
- package/dist/packs/heroes/carry.js +112 -0
- package/dist/packs/heroes/carry.js.map +1 -0
- package/dist/packs/heroes/commands.js +115 -0
- package/dist/packs/heroes/commands.js.map +1 -0
- package/dist/packs/heroes/fallen.d.ts +43 -0
- package/dist/packs/heroes/fallen.js +61 -0
- package/dist/packs/heroes/fallen.js.map +1 -0
- package/dist/packs/heroes/hire.js +60 -0
- package/dist/packs/heroes/hire.js.map +1 -0
- package/dist/packs/heroes/index.d.ts +7 -6
- package/dist/packs/heroes/index.js +130 -0
- package/dist/packs/heroes/index.js.map +1 -0
- package/dist/packs/heroes/loop.d.ts +95 -0
- package/dist/packs/heroes/loop.js +250 -0
- package/dist/packs/heroes/loop.js.map +1 -0
- package/dist/packs/heroes/making.d.ts +6 -3
- package/dist/packs/heroes/making.js +55 -0
- package/dist/packs/heroes/making.js.map +1 -0
- package/dist/packs/heroes/respawn.d.ts +3 -3
- package/dist/packs/heroes/respawn.js +87 -0
- package/dist/packs/heroes/respawn.js.map +1 -0
- package/dist/packs/heroes/sets.d.ts +32 -0
- package/dist/packs/heroes/sets.js +51 -0
- package/dist/packs/heroes/sets.js.map +1 -0
- package/dist/packs/heroes/spells.d.ts +16 -0
- package/dist/packs/heroes/spells.js +269 -0
- package/dist/packs/heroes/spells.js.map +1 -0
- package/dist/packs/items/defaults.d.ts +43 -0
- package/dist/packs/items/defaults.js +1504 -0
- package/dist/packs/items/defaults.js.map +1 -0
- package/dist/packs/items/index.d.ts +27 -0
- package/dist/packs/items/index.js +214 -0
- package/dist/packs/items/index.js.map +1 -0
- package/dist/packs/moba/index.d.ts +3 -3
- package/dist/packs/moba/index.js +174 -0
- package/dist/packs/moba/index.js.map +1 -0
- package/dist/packs/pack.d.ts +15 -15
- package/dist/packs/pack.js +14 -0
- package/dist/packs/pack.js.map +1 -0
- package/dist/packs.d.ts +15 -7
- package/dist/packs.js +222 -0
- package/dist/packs.js.map +1 -0
- package/dist/paths.d.ts +2 -0
- package/dist/paths.js +109 -0
- package/dist/paths.js.map +1 -0
- package/dist/plain.js +57 -0
- package/dist/plain.js.map +1 -0
- package/dist/player.d.ts +33 -10
- package/dist/player.js +159 -0
- package/dist/player.js.map +1 -0
- package/dist/portals.d.ts +1 -1
- package/dist/portals.js +194 -0
- package/dist/portals.js.map +1 -0
- package/dist/prefabs.d.ts +25 -2
- package/dist/prefabs.js +239 -0
- package/dist/prefabs.js.map +1 -0
- package/dist/presetBuildings.js +58 -0
- package/dist/presetBuildings.js.map +1 -0
- package/dist/presetFoliage.d.ts +27 -0
- package/dist/presetFoliage.js +98 -0
- package/dist/presetFoliage.js.map +1 -0
- package/dist/presetGround.js +65 -0
- package/dist/presetGround.js.map +1 -0
- package/dist/proxies.d.ts +12 -0
- package/dist/proxies.js +79 -0
- package/dist/proxies.js.map +1 -0
- package/dist/query.d.ts +56 -0
- package/dist/query.js +88 -0
- package/dist/query.js.map +1 -0
- package/dist/races.d.ts +15 -14
- package/dist/races.js +172 -0
- package/dist/races.js.map +1 -0
- package/dist/randomGroups.js +91 -0
- package/dist/randomGroups.js.map +1 -0
- package/dist/registry.d.ts +117 -53
- package/dist/registry.js +323 -0
- package/dist/registry.js.map +1 -0
- package/dist/remains.d.ts +11 -9
- package/dist/remains.js +188 -0
- package/dist/remains.js.map +1 -0
- package/dist/replication.d.ts +12 -7
- package/dist/replication.js +100 -0
- package/dist/replication.js.map +1 -0
- package/dist/rng.d.ts +2 -0
- package/dist/rng.js +40 -0
- package/dist/rng.js.map +1 -0
- package/dist/rules.d.ts +186 -99
- package/dist/rules.js +179 -0
- package/dist/rules.js.map +1 -0
- package/dist/rulesCheck.d.ts +5 -4
- package/dist/rulesCheck.js +693 -0
- package/dist/rulesCheck.js.map +1 -0
- package/dist/runes.d.ts +2 -2
- package/dist/runes.js +80 -0
- package/dist/runes.js.map +1 -0
- package/dist/save.d.ts +37 -12
- package/dist/save.js +532 -0
- package/dist/save.js.map +1 -0
- package/dist/scenario.d.ts +2 -2
- package/dist/scenario.js +99 -0
- package/dist/scenario.js.map +1 -0
- package/dist/scheduler.d.ts +3 -0
- package/dist/scheduler.js +156 -0
- package/dist/scheduler.js.map +1 -0
- package/dist/score.d.ts +19 -19
- package/dist/score.js +709 -0
- package/dist/score.js.map +1 -0
- package/dist/sequences.d.ts +10 -6
- package/dist/sequences.js +206 -0
- package/dist/sequences.js.map +1 -0
- package/dist/server/doorman.js +154 -0
- package/dist/server/doorman.js.map +1 -0
- package/dist/server/gameServer.d.ts +16 -1
- package/dist/server/gameServer.js +643 -0
- package/dist/server/gameServer.js.map +1 -0
- package/dist/server/index.d.ts +1 -1
- package/dist/server/lobby.js +199 -0
- package/dist/server/lobby.js.map +1 -0
- package/dist/server/log.js +18 -0
- package/dist/server/log.js.map +1 -0
- package/dist/server/match.js +267 -0
- package/dist/server/match.js.map +1 -0
- package/dist/server/mode.d.ts +18 -9
- package/dist/server/mode.js +220 -0
- package/dist/server/mode.js.map +1 -0
- package/dist/{navigation-worker.js → server/navigation-worker.js} +1 -1
- package/dist/server/navigation-worker.js.map +1 -0
- package/dist/server/navigation.js +39 -0
- package/dist/server/navigation.js.map +1 -0
- package/dist/server/ops.d.ts +4 -0
- package/dist/server/ops.js +137 -0
- package/dist/server/ops.js.map +1 -0
- package/dist/server/packs.d.ts +3 -3
- package/dist/server/packs.js +32 -0
- package/dist/server/packs.js.map +1 -0
- package/dist/server/ratings.d.ts +5 -0
- package/dist/server/ratings.js +104 -0
- package/dist/server/ratings.js.map +1 -0
- package/dist/server/relay.d.ts +12 -2
- package/dist/server/relay.js +144 -0
- package/dist/server/relay.js.map +1 -0
- package/dist/server/rooms.d.ts +9 -2
- package/dist/server/rooms.js +442 -0
- package/dist/server/rooms.js.map +1 -0
- package/dist/server/seat.js +116 -0
- package/dist/server/seat.js.map +1 -0
- package/dist/server/seatSettings.d.ts +3 -3
- package/dist/server/seatSettings.js +63 -0
- package/dist/server/seatSettings.js.map +1 -0
- package/dist/server/secret.js +13 -0
- package/dist/server/secret.js.map +1 -0
- package/dist/server/start.d.ts +13 -6
- package/dist/server/start.js +76 -0
- package/dist/server/start.js.map +1 -0
- package/dist/server/websocket.d.ts +9 -1
- package/dist/server/websocket.js +306 -0
- package/dist/server/websocket.js.map +1 -0
- package/dist/server.js +15 -2861
- package/dist/session/can.js +26 -0
- package/dist/session/can.js.map +1 -0
- package/dist/session/commandReplay.d.ts +8 -2
- package/dist/session/commandReplay.js +293 -0
- package/dist/session/commandReplay.js.map +1 -0
- package/dist/session/debug.js +151 -0
- package/dist/session/debug.js.map +1 -0
- package/dist/session/delay.js +62 -0
- package/dist/session/delay.js.map +1 -0
- package/dist/session/delta.d.ts +14 -1
- package/dist/session/delta.js +407 -0
- package/dist/session/delta.js.map +1 -0
- package/dist/session/entityState.js +415 -0
- package/dist/session/entityState.js.map +1 -0
- package/dist/session/local.d.ts +47 -5
- package/dist/session/local.js +670 -0
- package/dist/session/local.js.map +1 -0
- package/dist/session/memory.d.ts +20 -2
- package/dist/session/memory.js +131 -0
- package/dist/session/memory.js.map +1 -0
- package/dist/session/protocol.d.ts +325 -31
- package/dist/session/protocol.js +55 -0
- package/dist/session/protocol.js.map +1 -0
- package/dist/session/remote.d.ts +74 -12
- package/dist/session/remote.js +1394 -0
- package/dist/session/remote.js.map +1 -0
- package/dist/session/replay.d.ts +11 -2
- package/dist/session/replay.js +160 -0
- package/dist/session/replay.js.map +1 -0
- package/dist/session/seed.js +12 -0
- package/dist/session/seed.js.map +1 -0
- package/dist/session/share.d.ts +5 -1
- package/dist/session/share.js +94 -0
- package/dist/session/share.js.map +1 -0
- package/dist/session/socket.d.ts +1 -1
- package/dist/session/socket.js +29 -0
- package/dist/session/socket.js.map +1 -0
- package/dist/session/wire.d.ts +5 -0
- package/dist/session/wire.js +84 -0
- package/dist/session/wire.js.map +1 -0
- package/dist/session/worker.d.ts +77 -12
- package/dist/session/worker.js +499 -0
- package/dist/session/worker.js.map +1 -0
- package/dist/shared.d.ts +31 -5
- package/dist/shared.js +166 -0
- package/dist/shared.js.map +1 -0
- package/dist/sides.d.ts +9 -3
- package/dist/sides.js +149 -0
- package/dist/sides.js.map +1 -0
- package/dist/sight.js +85 -0
- package/dist/sight.js.map +1 -0
- package/dist/simulate-worker.js +1 -1
- package/dist/simulate.d.ts +12 -8
- package/dist/{simulate-oXBiw1Ff.js → simulate.js} +10 -11
- package/dist/simulate.js.map +1 -0
- package/dist/smart.js +77 -0
- package/dist/smart.js.map +1 -0
- package/dist/spatial.d.ts +32 -16
- package/dist/spatial.js +234 -0
- package/dist/spatial.js.map +1 -0
- package/dist/spawning.d.ts +1 -0
- package/dist/spawning.js +224 -0
- package/dist/spawning.js.map +1 -0
- package/dist/stances.d.ts +6 -3
- package/dist/stances.js +169 -0
- package/dist/stances.js.map +1 -0
- package/dist/start.d.ts +10 -10
- package/dist/start.js +75 -0
- package/dist/start.js.map +1 -0
- package/dist/stats.d.ts +42 -16
- package/dist/stats.js +290 -0
- package/dist/stats.js.map +1 -0
- package/dist/summoned.d.ts +52 -0
- package/dist/summoned.js +38 -0
- package/dist/summoned.js.map +1 -0
- package/dist/summons.d.ts +10 -13
- package/dist/summons.js +271 -0
- package/dist/summons.js.map +1 -0
- package/dist/systems/abilities.js +224 -0
- package/dist/systems/abilities.js.map +1 -0
- package/dist/systems/combat.d.ts +35 -1
- package/dist/systems/combat.js +677 -0
- package/dist/systems/combat.js.map +1 -0
- package/dist/systems/combatTold.d.ts +3 -1
- package/dist/systems/combatTold.js +85 -0
- package/dist/systems/combatTold.js.map +1 -0
- package/dist/systems/construction.js +80 -0
- package/dist/systems/construction.js.map +1 -0
- package/dist/systems/economy.d.ts +0 -6
- package/dist/systems/economy.js +128 -0
- package/dist/systems/economy.js.map +1 -0
- package/dist/systems/fog.d.ts +1 -1
- package/dist/systems/fog.js +120 -0
- package/dist/systems/fog.js.map +1 -0
- package/dist/systems/life.js +32 -0
- package/dist/systems/life.js.map +1 -0
- package/dist/systems/movement.d.ts +24 -12
- package/dist/systems/movement.js +1247 -0
- package/dist/systems/movement.js.map +1 -0
- package/dist/systems/orders.js +64 -0
- package/dist/systems/orders.js.map +1 -0
- package/dist/systems/production.js +322 -0
- package/dist/systems/production.js.map +1 -0
- package/dist/systems/productionQueue.js +120 -0
- package/dist/systems/productionQueue.js.map +1 -0
- package/dist/systems/victory.d.ts +1 -1
- package/dist/systems/victory.js +56 -0
- package/dist/systems/victory.js.map +1 -0
- package/dist/talk.d.ts +6 -6
- package/dist/talk.js +153 -0
- package/dist/talk.js.map +1 -0
- package/dist/targeting.d.ts +142 -0
- package/dist/targeting.js +49 -0
- package/dist/targeting.js.map +1 -0
- package/dist/tech.d.ts +20 -3
- package/dist/tech.js +239 -0
- package/dist/tech.js.map +1 -0
- package/dist/techTree.d.ts +7 -0
- package/dist/techTree.js +90 -0
- package/dist/techTree.js.map +1 -0
- package/dist/terrain.d.ts +59 -7
- package/dist/terrain.js +389 -0
- package/dist/terrain.js.map +1 -0
- package/dist/terrainSave.d.ts +6 -0
- package/dist/terrainSave.js +74 -0
- package/dist/terrainSave.js.map +1 -0
- package/dist/testing.d.ts +8 -7
- package/dist/testing.js +13 -739
- package/dist/testing.js.map +1 -1
- package/dist/tiles.d.ts +1 -1
- package/dist/tiles.js +43 -0
- package/dist/tiles.js.map +1 -0
- package/dist/timers.d.ts +29 -4
- package/dist/timers.js +242 -0
- package/dist/timers.js.map +1 -0
- package/dist/tomes.d.ts +4 -4
- package/dist/tomes.js +94 -0
- package/dist/tomes.js.map +1 -0
- package/dist/trade.js +103 -0
- package/dist/trade.js.map +1 -0
- package/dist/transport.d.ts +6 -1
- package/dist/transport.js +281 -0
- package/dist/transport.js.map +1 -0
- package/dist/tunables.d.ts +10 -3
- package/dist/tunables.js +56 -0
- package/dist/tunables.js.map +1 -0
- package/dist/unitResources.d.ts +67 -0
- package/dist/unitResources.js +266 -0
- package/dist/unitResources.js.map +1 -0
- package/dist/upkeep.d.ts +6 -1
- package/dist/upkeep.js +26 -0
- package/dist/upkeep.js.map +1 -0
- package/dist/veterancy.d.ts +8 -3
- package/dist/veterancy.js +131 -0
- package/dist/veterancy.js.map +1 -0
- package/dist/vision.d.ts +36 -0
- package/dist/vision.js +133 -0
- package/dist/vision.js.map +1 -0
- package/dist/walls.d.ts +1 -1
- package/dist/walls.js +278 -0
- package/dist/walls.js.map +1 -0
- package/dist/world.d.ts +606 -88
- package/dist/world.js +1263 -0
- package/dist/world.js.map +1 -0
- package/package.json +2 -2
- package/dist/ai.js.map +0 -1
- package/dist/attributes.d.ts +0 -66
- package/dist/brain-BvVdUhX8.js +0 -7659
- package/dist/brain-BvVdUhX8.js.map +0 -1
- package/dist/builds-C6LfgvEU.js +0 -460
- package/dist/builds-C6LfgvEU.js.map +0 -1
- package/dist/coreComponents-syuh2fPG.js +0 -5149
- package/dist/coreComponents-syuh2fPG.js.map +0 -1
- package/dist/debugCommands-CzjrSm66.js +0 -14739
- package/dist/debugCommands-CzjrSm66.js.map +0 -1
- package/dist/determinism-BCymQwiE.js +0 -518
- package/dist/determinism-BCymQwiE.js.map +0 -1
- package/dist/game-DiJEN-Ks.js +0 -5800
- package/dist/game-DiJEN-Ks.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/inspect-D9dWHmZ0.js.map +0 -1
- package/dist/local-Dkovq42k.js +0 -1379
- package/dist/local-Dkovq42k.js.map +0 -1
- package/dist/missionRules-C-bGxm0Q.js.map +0 -1
- package/dist/navigation-worker.js.map +0 -1
- package/dist/packs-g5thvmGn.js +0 -3199
- package/dist/packs-g5thvmGn.js.map +0 -1
- package/dist/profiles-B3NS9jwk.js.map +0 -1
- package/dist/server.js.map +0 -1
- package/dist/simulate-oXBiw1Ff.js.map +0 -1
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
//#region src/targeting.ts
|
|
2
|
+
/**
|
|
3
|
+
* Every `AimKind`, in the order the aims are listed in tools
|
|
4
|
+
*
|
|
5
|
+
* @beta
|
|
6
|
+
*/
|
|
7
|
+
var AIM_KINDS = [
|
|
8
|
+
"none",
|
|
9
|
+
"unit",
|
|
10
|
+
"point",
|
|
11
|
+
"direction",
|
|
12
|
+
"vector",
|
|
13
|
+
"passive"
|
|
14
|
+
];
|
|
15
|
+
/**
|
|
16
|
+
* A way of aiming of a game's own: `defineTargeting({ id: 'wall', like: 'point', check, indicator })`, listed in
|
|
17
|
+
* `Rules.targetings` and named by an ability's `target`. Its name is said by declaring it in `AbilityTargetings`
|
|
18
|
+
* (`declare module '@v12-engine/engine' { interface AbilityTargetings { wall: true } }`), so that an ability's
|
|
19
|
+
* `target: 'wall'` is typed
|
|
20
|
+
*
|
|
21
|
+
* @beta
|
|
22
|
+
*/
|
|
23
|
+
function defineTargeting(def) {
|
|
24
|
+
if (AIM_KINDS.includes(def.id)) throw new Error(`"${def.id}" is a way of aiming of the engine's: a game's own needs a name of its own`);
|
|
25
|
+
return def;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* How an ability is aimed, as the engine's way it is or is like (`AimKind`): its `target` itself for the engine's, the
|
|
29
|
+
* `like` of a game's own (`Rules.targetings`). `none` for a name nothing defines
|
|
30
|
+
*
|
|
31
|
+
* @beta
|
|
32
|
+
*/
|
|
33
|
+
function aimKind(registry, ability) {
|
|
34
|
+
const { target } = ability;
|
|
35
|
+
if (AIM_KINDS.includes(target)) return target;
|
|
36
|
+
return registry.targetings.has(target) ? registry.targetings.get(target).like : "none";
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* A game's own way of aiming an ability (`Rules.targetings`), where its `target` names one
|
|
40
|
+
*
|
|
41
|
+
* @beta
|
|
42
|
+
*/
|
|
43
|
+
function targetingOf(registry, ability) {
|
|
44
|
+
return registry.targetings.has(ability.target) ? registry.targetings.get(ability.target) : void 0;
|
|
45
|
+
}
|
|
46
|
+
//#endregion
|
|
47
|
+
export { AIM_KINDS, aimKind, defineTargeting, targetingOf };
|
|
48
|
+
|
|
49
|
+
//# sourceMappingURL=targeting.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"targeting.js","names":[],"sources":["../src/targeting.ts"],"sourcesContent":["/**\n * How an ability is aimed (E2E-PLAN AB4): the engine's ways (`AbilityDef.target`: nothing, a unit, a point, a direction,\n * two points, passive) and a game's own (`defineTargeting`, listed in `Rules.targetings`): how the order checks and\n * aims it, and what the screen's indicator draws while the player aims it\n */\nimport type { AbilityDef, AimShape } from './defs'\nimport type { Entity } from './entity'\nimport type { Vec2 } from './math'\nimport type { MessageRef } from './messages'\nimport type { World } from './world'\n\n/**\n * The engine's ways of aiming an ability, what every way of a game's own is like (`Targeting.like`): at once\n * (`none`), at a unit, at a point (walked into range of), towards a point (from where the caster stands), along two\n * points (`vector`: where it starts, in range, and the way it goes from there), or not cast at all (`passive`)\n *\n * @beta\n */\nexport type AimKind = 'none' | 'unit' | 'point' | 'direction' | 'vector' | 'passive'\n\n/**\n * Every `AimKind`, in the order the aims are listed in tools\n *\n * @beta\n */\nexport const AIM_KINDS: readonly AimKind[] = ['none', 'unit', 'point', 'direction', 'vector', 'passive']\n\n/**\n * How an ability was aimed, as its order carries it: the unit, the point, and for two points (`vector`) where it goes\n * from the point (`to`)\n *\n * @beta\n */\nexport interface CastAim {\n\t/** The ability's level */\n\tlevel: number\n\t/** The unit the ability was aimed at, for a unit-aimed ability */\n\ttarget?: Entity\n\t/** The ground point it was aimed at, or the first point of a two-point ability */\n\tpoint?: Vec2\n\t/** For two points: the second, the way it goes from `point` */\n\tto?: Vec2\n}\n\n/**\n * Where an ability's effects go, from how it was aimed (`Targeting.aim`): their point, the unit they are for, and what\n * they go off from when not the caster (`EffectContext.origin`)\n *\n * @beta\n */\nexport interface CastAimed {\n\t/** Where the effects go, in world coordinates */\n\tpoint?: Vec2\n\t/** The unit the effects are for */\n\ttarget?: Entity\n\t/** What the effects go off from when it is not the caster: an entity or a point */\n\torigin?: Entity | Vec2\n}\n\n/**\n * A piece of what an indicator draws (`Targeting.indicator`): a shape (`AimShape`) at a place on the ground, turned\n * to `heading` (radians, 0 the way of +z) for one that points somewhere (a line, a cone, an arc)\n *\n * @beta\n */\nexport type AimPiece = AimShape & { at: Vec2; heading?: number }\n\n/**\n * What the screen knows as the player aims (`Targeting.indicator`): the ability and its level, where the caster\n * stands, where the pointer is on the ground, and for two points the first one, once it is given\n *\n * @beta\n */\nexport interface AimView {\n\t/** The ability being aimed */\n\tability: AbilityDef\n\t/** The level of the ability being aimed */\n\tlevel: number\n\t/** Where the caster stands, in world coordinates */\n\tfrom: Vec2\n\t/** Where the pointer is on the ground, when it is over the ground */\n\tpointer?: Vec2\n\t/** The first point of a two-point ability once it is given */\n\tstart?: Vec2\n}\n\n/**\n * A way of aiming of a game's own, for `AbilityDef.target` (`defineTargeting`): the engine's way it is like (what the\n * player gives, what the order walks to), and on top of that what may be aimed at (`check`), where the effects go\n * from what was aimed (`aim`), and what the screen draws while it is aimed (`indicator`)\n *\n * @beta\n */\nexport interface Targeting {\n\t/** What `AbilityDef.target` says for it */\n\treadonly id: string\n\t/** The engine's way it is like: what the player gives (a unit, a point, two points, nothing) and what the order walks to */\n\treadonly like: Exclude<AimKind, 'passive'>\n\t/**\n\t * Why it cannot be aimed so, or nothing where it can: asked as the order takes it and again as it goes off (the\n\t * player is told the reason). A wall only on open ground, a point only beside an ally\n\t */\n\tcheck?(world: World, caster: Entity, ability: AbilityDef, aim: CastAim): MessageRef | undefined\n\t/**\n\t * Where the effects go, from how it was aimed: over what the engine makes of it (its `point`, `target`, and for two\n\t * points the first as the `origin` and the second as the `point`)\n\t */\n\taim?(world: World, caster: Entity, ability: AbilityDef, aim: CastAim): CastAimed | undefined\n\t/**\n\t * What the screen draws on the ground while the player aims it, in place of the engine's (`aimOf`): pieces of the\n\t * shapes there are, each at a place, turned as it says. Code of the game's own, run on the screen: no world\n\t */\n\tindicator?(view: AimView): readonly AimPiece[] | undefined\n}\n\n/**\n * A way of aiming of a game's own: `defineTargeting({ id: 'wall', like: 'point', check, indicator })`, listed in\n * `Rules.targetings` and named by an ability's `target`. Its name is said by declaring it in `AbilityTargetings`\n * (`declare module '@v12-engine/engine' { interface AbilityTargetings { wall: true } }`), so that an ability's\n * `target: 'wall'` is typed\n *\n * @beta\n */\nexport function defineTargeting(def: Targeting): Targeting {\n\tif ((AIM_KINDS as readonly string[]).includes(def.id))\n\t\tthrow new Error(`\"${def.id}\" is a way of aiming of the engine's: a game's own needs a name of its own`)\n\treturn def\n}\n\n/**\n * How an ability is aimed, as the engine's way it is or is like (`AimKind`): its `target` itself for the engine's, the\n * `like` of a game's own (`Rules.targetings`). `none` for a name nothing defines\n *\n * @beta\n */\nexport function aimKind(registry: { readonly targetings: { has(id: string): boolean; get(id: string): Targeting } }, ability: AbilityDef): AimKind {\n\tconst { target } = ability\n\tif ((AIM_KINDS as readonly string[]).includes(target)) return target as AimKind\n\treturn registry.targetings.has(target) ? registry.targetings.get(target).like : 'none'\n}\n\n/**\n * A game's own way of aiming an ability (`Rules.targetings`), where its `target` names one\n *\n * @beta\n */\nexport function targetingOf(\n\tregistry: { readonly targetings: { has(id: string): boolean; get(id: string): Targeting } },\n\tability: AbilityDef\n): Targeting | undefined {\n\treturn registry.targetings.has(ability.target) ? registry.targetings.get(ability.target) : undefined\n}\n"],"mappings":";;;;;;AAyBA,IAAa,YAAgC;CAAC;CAAQ;CAAQ;CAAS;CAAa;CAAU;AAAS;;;;;;;;;AAkGvG,SAAgB,gBAAgB,KAA2B;CAC1D,IAAK,UAAgC,SAAS,IAAI,EAAE,GACnD,MAAM,IAAI,MAAM,IAAI,IAAI,GAAG,2EAA2E;CACvG,OAAO;AACR;;;;;;;AAQA,SAAgB,QAAQ,UAA6F,SAA8B;CAClJ,MAAM,EAAE,WAAW;CACnB,IAAK,UAAgC,SAAS,MAAM,GAAG,OAAO;CAC9D,OAAO,SAAS,WAAW,IAAI,MAAM,IAAI,SAAS,WAAW,IAAI,MAAM,CAAC,CAAC,OAAO;AACjF;;;;;;AAOA,SAAgB,YACf,UACA,SACwB;CACxB,OAAO,SAAS,WAAW,IAAI,QAAQ,MAAM,IAAI,SAAS,WAAW,IAAI,QAAQ,MAAM,IAAI,KAAA;AAC5F"}
|
package/dist/tech.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type Entity, type PlayerId } from './entity';
|
|
1
|
+
import { type AbilityState, type Entity, type PlayerId } from './entity';
|
|
2
2
|
import type { World } from './world';
|
|
3
3
|
import { type Message } from './messages';
|
|
4
4
|
/**
|
|
@@ -33,17 +33,34 @@ export declare function unlockRefusal(world: World, player: PlayerId, kind: 'uni
|
|
|
33
33
|
* @beta
|
|
34
34
|
*/
|
|
35
35
|
export declare function unlocked(world: World, player: PlayerId, kind: 'unit' | 'upgrade', id: string, requires: string[] | undefined, level?: number): boolean;
|
|
36
|
+
/**
|
|
37
|
+
* How `morph` goes about it where a building's upgrade does not: what a form needs (`takeForm`)
|
|
38
|
+
*
|
|
39
|
+
* @beta
|
|
40
|
+
*/
|
|
41
|
+
export interface MorphOptions {
|
|
42
|
+
/**
|
|
43
|
+
* What it was told goes on in the new type (what it was doing starts over from where it stands), where an upgrade
|
|
44
|
+
* drops it all
|
|
45
|
+
*/
|
|
46
|
+
keepOrders?: boolean;
|
|
47
|
+
/** Its health and mana are the same parts of the most it can have in the new type, where an upgrade keeps what was lost */
|
|
48
|
+
share?: boolean;
|
|
49
|
+
/** What it can cast in the new type, all of it, in place of what the type's abilities and what it learned make */
|
|
50
|
+
abilities?: AbilityState[];
|
|
51
|
+
}
|
|
36
52
|
/**
|
|
37
53
|
* Turns an entity into another type, where it stands: a building upgraded, a unit transformed (a druid into a bear, a
|
|
38
54
|
* 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
55
|
* whether it fights, gathers or carries, its abilities (those of the old type it keeps are kept as they were, at their
|
|
40
56
|
* levels and cooldowns), and what it makes. What it went through stays: health lost, mana, buffs, experience, items.
|
|
41
57
|
* 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)
|
|
58
|
+
* runs: what a pack gives it of its own for its new type (the heroes pack: a hero's level, a shop's wares). `options`
|
|
59
|
+
* keep its orders and the shares of its health and mana, and say its abilities: what a hero's form takes (`takeForm`)
|
|
43
60
|
*
|
|
44
61
|
* @beta
|
|
45
62
|
*/
|
|
46
|
-
export declare function morph(world: World, entity: Entity, into: string): void;
|
|
63
|
+
export declare function morph(world: World, entity: Entity, into: string, options?: MorphOptions): void;
|
|
47
64
|
/** What became another, to those who see it */
|
|
48
65
|
export declare const toldMorphed: import("./replication").ReplicatedEvent;
|
|
49
66
|
/**
|
package/dist/tech.js
ADDED
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
import { upgradesOf } from "./defs.js";
|
|
2
|
+
import { inventorySlots, slotsOf } from "./inventory.js";
|
|
3
|
+
import { statsOf } from "./stats.js";
|
|
4
|
+
import { entityMorphed } from "./engineEvents.js";
|
|
5
|
+
import { replicateEvent } from "./replication.js";
|
|
6
|
+
import { fighting, moving } from "./entity.js";
|
|
7
|
+
import { engineMessage, toMessage } from "./messages.js";
|
|
8
|
+
import { availableTo } from "./shared.js";
|
|
9
|
+
import { agentParamsOf } from "./navigation/agentParams.js";
|
|
10
|
+
import { productionQueue } from "./systems/productionQueue.js";
|
|
11
|
+
import { refusalOf } from "./hooks.js";
|
|
12
|
+
import { dropOnGround } from "./items.js";
|
|
13
|
+
import { clearOrders, resetStance } from "./orders/queue.js";
|
|
14
|
+
import { gathering } from "./orders/harvest.js";
|
|
15
|
+
import { isAvailable } from "./races.js";
|
|
16
|
+
//#region src/tech.ts
|
|
17
|
+
/**
|
|
18
|
+
* Types of the finished buildings a player has, with what those count as
|
|
19
|
+
*
|
|
20
|
+
* @beta
|
|
21
|
+
*/
|
|
22
|
+
function techOf(world, player) {
|
|
23
|
+
const tech = /* @__PURE__ */ new Set();
|
|
24
|
+
for (const entity of world.index.ownedBy(player)) {
|
|
25
|
+
if (!entity.alive || !entity.isBuilding || !entity.operational) continue;
|
|
26
|
+
tech.add(entity.def.id);
|
|
27
|
+
for (const other of entity.def.provides ?? []) tech.add(other);
|
|
28
|
+
}
|
|
29
|
+
return tech;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* What of a list of requirements a player does not have
|
|
33
|
+
*
|
|
34
|
+
* @beta
|
|
35
|
+
*/
|
|
36
|
+
function missing(world, player, requires, tech = techOf(world, player)) {
|
|
37
|
+
return (requires ?? []).filter((id) => !tech.has(id));
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Checks requirements and tells the player what is missing. True when there is nothing in the way
|
|
41
|
+
*
|
|
42
|
+
* @beta
|
|
43
|
+
*/
|
|
44
|
+
function meets(world, player, requires) {
|
|
45
|
+
const lacking = missing(world, player, requires);
|
|
46
|
+
if (lacking.length === 0) return true;
|
|
47
|
+
world.message(player, engineMessage("requires", { units: lacking }));
|
|
48
|
+
return false;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Why a player may not make something as far as what it requires goes, or nothing: the finished buildings it
|
|
52
|
+
* requires, and then the `requirement` hook (see `Requirement`). For a unit or structure type, or a level of research
|
|
53
|
+
*
|
|
54
|
+
* @beta
|
|
55
|
+
*/
|
|
56
|
+
function unlockRefusal(world, player, kind, id, requires, level) {
|
|
57
|
+
const lacking = missing(world, player, requires);
|
|
58
|
+
const refusal = lacking.length ? engineMessage("requires", { units: lacking }) : void 0;
|
|
59
|
+
if (!world.hooks.has("requirement")) return refusal;
|
|
60
|
+
const decided = refusalOf(world.hooks.run("requirement", {
|
|
61
|
+
player,
|
|
62
|
+
kind,
|
|
63
|
+
id,
|
|
64
|
+
level,
|
|
65
|
+
missing: lacking,
|
|
66
|
+
cancelled: !!refusal,
|
|
67
|
+
reason: refusal
|
|
68
|
+
}));
|
|
69
|
+
return decided ? toMessage(decided) : void 0;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Checks that something is the player's to make at all (`isAvailable`: their race, the `available` hook), then what it
|
|
73
|
+
* requires, by `unlockRefusal`, and tells the player what stands in the way. True when nothing does
|
|
74
|
+
*
|
|
75
|
+
* @beta
|
|
76
|
+
*/
|
|
77
|
+
function unlocked(world, player, kind, id, requires, level) {
|
|
78
|
+
if (!isAvailable(world, player, kind, id)) {
|
|
79
|
+
world.message(player, engineMessage("cannotDoThat"));
|
|
80
|
+
return false;
|
|
81
|
+
}
|
|
82
|
+
const refusal = unlockRefusal(world, player, kind, id, requires, level);
|
|
83
|
+
if (refusal) world.message(player, refusal);
|
|
84
|
+
return !refusal;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Turns an entity into another type, where it stands: a building upgraded, a unit transformed (a druid into a bear, a
|
|
88
|
+
* 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),
|
|
89
|
+
* whether it fights, gathers or carries, its abilities (those of the old type it keeps are kept as they were, at their
|
|
90
|
+
* levels and cooldowns), and what it makes. What it went through stays: health lost, mana, buffs, experience, items.
|
|
91
|
+
* The parts of the game it had none of are given it as `spawn` gives them (`Component.onSpawn`), and the `morphed` hook
|
|
92
|
+
* runs: what a pack gives it of its own for its new type (the heroes pack: a hero's level, a shop's wares). `options`
|
|
93
|
+
* keep its orders and the shares of its health and mana, and say its abilities: what a hero's form takes (`takeForm`)
|
|
94
|
+
*
|
|
95
|
+
* @beta
|
|
96
|
+
*/
|
|
97
|
+
function morph(world, entity, into, options = {}) {
|
|
98
|
+
const def = world.registry.unit(into);
|
|
99
|
+
const old = entity.def;
|
|
100
|
+
const from = old.id;
|
|
101
|
+
const hurt = entity.maxHealth - entity.health;
|
|
102
|
+
const health = entity.maxHealth > 0 ? entity.health / entity.maxHealth : 1;
|
|
103
|
+
const mana = entity.maxMana > 0 ? entity.mana / entity.maxMana : 1;
|
|
104
|
+
world.index.remove(entity);
|
|
105
|
+
entity.retype(def);
|
|
106
|
+
world.index.add(entity);
|
|
107
|
+
const stats = statsOf(world, entity);
|
|
108
|
+
entity.maxHealth = stats.health;
|
|
109
|
+
if (options.share) {
|
|
110
|
+
entity.health = health * stats.health;
|
|
111
|
+
entity.maxMana = stats.mana;
|
|
112
|
+
entity.mana = mana * stats.mana;
|
|
113
|
+
} else entity.health = Math.max(stats.health - hurt, 1);
|
|
114
|
+
if ((def.trains?.length || def.researches?.length || upgradesOf(def).length) && !entity.has(productionQueue)) entity.set(productionQueue, {
|
|
115
|
+
queue: [],
|
|
116
|
+
rally: null
|
|
117
|
+
});
|
|
118
|
+
if (def.kind === "unit" && old.kind === "unit") transform(world, entity, old, stats.moveSpeed, options);
|
|
119
|
+
for (const part of world.registry.spawning) if (!entity.has(part)) part.onSpawn(entity, world);
|
|
120
|
+
if (world.hooks.has("morphed")) world.hooks.run("morphed", {
|
|
121
|
+
entity,
|
|
122
|
+
from
|
|
123
|
+
});
|
|
124
|
+
world.events.emit(entityMorphed, {
|
|
125
|
+
entity,
|
|
126
|
+
from
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
/** What changes of a unit that becomes another unit type, beyond its stats */
|
|
130
|
+
function transform(world, entity, old, speed, options) {
|
|
131
|
+
const { def } = entity;
|
|
132
|
+
const m = entity.get(moving);
|
|
133
|
+
const reshaped = old.flying !== def.flying || old.radius !== def.radius || old.naval !== def.naval;
|
|
134
|
+
if (m && (reshaped || !speed)) world.nav.removeAgent(entity.id);
|
|
135
|
+
if (m && speed && reshaped) {
|
|
136
|
+
world.nav.addAgent(entity.id, entity.pos, agentParamsOf(entity, speed));
|
|
137
|
+
delete m.phased;
|
|
138
|
+
}
|
|
139
|
+
if (!speed) entity.remove(moving);
|
|
140
|
+
else if (m) {
|
|
141
|
+
if (!reshaped && m.speed !== speed) world.nav.setSpeed(entity.id, speed);
|
|
142
|
+
m.speed = speed;
|
|
143
|
+
}
|
|
144
|
+
if (def.attacks?.length) {
|
|
145
|
+
if (!entity.has(fighting)) entity.set(fighting, {
|
|
146
|
+
cooldown: 0,
|
|
147
|
+
swing: 0,
|
|
148
|
+
swingTarget: 0,
|
|
149
|
+
autoTarget: 0,
|
|
150
|
+
lastAttacker: 0,
|
|
151
|
+
guard: null,
|
|
152
|
+
passive: false
|
|
153
|
+
});
|
|
154
|
+
} else entity.remove(fighting);
|
|
155
|
+
if (!def.harvester) entity.remove(gathering);
|
|
156
|
+
else if (!entity.has(gathering)) entity.set(gathering, {
|
|
157
|
+
carrying: 0,
|
|
158
|
+
kind: null,
|
|
159
|
+
resource: 0
|
|
160
|
+
});
|
|
161
|
+
if (options.abilities) entity.setAbilities(options.abilities);
|
|
162
|
+
else {
|
|
163
|
+
const kept = new Map(entity.abilities.map((state) => [state.id, state]));
|
|
164
|
+
const learned = /* @__PURE__ */ new Set([
|
|
165
|
+
...old.hero?.learns ?? [],
|
|
166
|
+
...old.hero?.spells ?? [],
|
|
167
|
+
...def.hero?.learns ?? [],
|
|
168
|
+
...def.hero?.spells ?? []
|
|
169
|
+
]);
|
|
170
|
+
entity.setAbilities([...(def.abilities ?? []).map((id) => kept.get(id) ?? {
|
|
171
|
+
id,
|
|
172
|
+
level: 1,
|
|
173
|
+
cooldown: 0,
|
|
174
|
+
autocast: world.registry.ability(id).autocast ?? false
|
|
175
|
+
}), ...entity.abilities.filter((state) => learned.has(state.id) && !(def.abilities ?? []).includes(state.id))]);
|
|
176
|
+
}
|
|
177
|
+
if (def.inventory !== old.inventory) {
|
|
178
|
+
const items = (slotsOf(entity) ?? []).filter((item) => item !== null);
|
|
179
|
+
if (def.inventory) entity.set(inventorySlots, Array.from({ length: def.inventory }, (_, i) => items[i] ?? null));
|
|
180
|
+
else entity.remove(inventorySlots);
|
|
181
|
+
for (const item of items.slice(def.inventory ?? 0)) dropOnGround(world, item, entity.pos);
|
|
182
|
+
}
|
|
183
|
+
if (options.keepOrders) {
|
|
184
|
+
resetStance(world, entity);
|
|
185
|
+
const order = entity.orders[0];
|
|
186
|
+
if (order) order.started = false;
|
|
187
|
+
} else clearOrders(world, entity);
|
|
188
|
+
}
|
|
189
|
+
/** What became another, to those who see it */
|
|
190
|
+
var toldMorphed = replicateEvent(entityMorphed, "morphed", ({ entity, from }, view) => view.knows(entity) ? {
|
|
191
|
+
type: "morphed",
|
|
192
|
+
id: entity.id,
|
|
193
|
+
from
|
|
194
|
+
} : void 0);
|
|
195
|
+
/**
|
|
196
|
+
* What the `requirement` hook decided for a player, where it is not what the requirements say: what their screen could
|
|
197
|
+
* not work out for itself (`PlayerState.own.unlocks`). Nothing where the hook agrees with them all
|
|
198
|
+
*
|
|
199
|
+
* @beta
|
|
200
|
+
*/
|
|
201
|
+
function decidedUnlocks(world, player) {
|
|
202
|
+
const tech = techOf(world, player);
|
|
203
|
+
let decided;
|
|
204
|
+
const compare = (key, kind, id, requires, level) => {
|
|
205
|
+
const lacking = missing(world, player, requires, tech);
|
|
206
|
+
const declared = lacking.length ? "requires" : void 0;
|
|
207
|
+
const refusal = unlockRefusal(world, player, kind, id, requires, level);
|
|
208
|
+
if (refusal?.key !== declared || refusal && declared && refusal.params?.units?.toString() !== lacking.toString()) (decided ??= {})[key] = refusal ?? null;
|
|
209
|
+
};
|
|
210
|
+
for (const def of world.registry.units.all()) compare(def.id, "unit", def.id, def.requires);
|
|
211
|
+
for (const def of world.registry.upgrades.all()) {
|
|
212
|
+
const level = world.player(player).upgrades.get(def.id) ?? 0;
|
|
213
|
+
if (level < (def.maxLevel ?? 1)) compare(`upgrade:${def.id}`, "upgrade", def.id, def.requires?.[level], level + 1);
|
|
214
|
+
}
|
|
215
|
+
return decided;
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* What the `available` hook decided for a player, where it is not what their race says: what their screen could not
|
|
219
|
+
* work out for itself (`PlayerState.own.availability`). Nothing where the hook agrees
|
|
220
|
+
*
|
|
221
|
+
* @beta
|
|
222
|
+
*/
|
|
223
|
+
function decidedAvailability(world, player) {
|
|
224
|
+
const race = world.player(player).race;
|
|
225
|
+
let decided;
|
|
226
|
+
for (const def of world.registry.units.all()) {
|
|
227
|
+
const available = isAvailable(world, player, "unit", def.id);
|
|
228
|
+
if (available !== availableTo(def, race)) (decided ??= {})[def.id] = available;
|
|
229
|
+
}
|
|
230
|
+
for (const def of world.registry.upgrades.all()) {
|
|
231
|
+
const available = isAvailable(world, player, "upgrade", def.id);
|
|
232
|
+
if (available !== availableTo(def, race)) (decided ??= {})[`upgrade:${def.id}`] = available;
|
|
233
|
+
}
|
|
234
|
+
return decided;
|
|
235
|
+
}
|
|
236
|
+
//#endregion
|
|
237
|
+
export { decidedAvailability, decidedUnlocks, meets, missing, morph, techOf, toldMorphed, unlockRefusal, unlocked };
|
|
238
|
+
|
|
239
|
+
//# sourceMappingURL=tech.js.map
|
package/dist/tech.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tech.js","names":[],"sources":["../src/tech.ts"],"sourcesContent":["import { entityMorphed } from '#engine/engineEvents'\nimport { refusalOf } from './hooks'\nimport { type AbilityState, type Entity, type PlayerId, moving, fighting } from './entity'\nimport { productionQueue } from './systems/productionQueue'\nimport { statsOf } from './stats'\nimport { type UnitTypeDef, upgradesOf } from './defs'\nimport { dropOnGround } from './items'\nimport { inventorySlots, slotsOf } from './inventory'\nimport { gathering } from './orders/harvest'\nimport { clearOrders, resetStance } from './orders/queue'\nimport type { World } from './world'\nimport { engineMessage, type Message, toMessage } from './messages'\nimport { isAvailable } from './races'\nimport { replicateEvent } from './replication'\nimport { availableTo } from './shared'\nimport { agentParamsOf } from './navigation/agentParams'\n\n/**\n * Types of the finished buildings a player has, with what those count as\n *\n * @beta\n */\nexport function techOf(world: World, player: PlayerId): Set<string> {\n\tconst tech = new Set<string>()\n\tfor (const entity of world.index.ownedBy(player)) {\n\t\tif (!entity.alive || !entity.isBuilding || !entity.operational) continue\n\t\ttech.add(entity.def.id)\n\t\tfor (const other of entity.def.provides ?? []) tech.add(other)\n\t}\n\treturn tech\n}\n\n/**\n * What of a list of requirements a player does not have\n *\n * @beta\n */\nexport function missing(world: World, player: PlayerId, requires: string[] | undefined, tech = techOf(world, player)): string[] {\n\treturn (requires ?? []).filter((id) => !tech.has(id))\n}\n\n/**\n * Checks requirements and tells the player what is missing. True when there is nothing in the way\n *\n * @beta\n */\nexport function meets(world: World, player: PlayerId, requires: string[] | undefined): boolean {\n\tconst lacking = missing(world, player, requires)\n\tif (lacking.length === 0) return true\n\tworld.message(player, engineMessage('requires', { units: lacking }))\n\treturn false\n}\n\n/**\n * Why a player may not make something as far as what it requires goes, or nothing: the finished buildings it\n * requires, and then the `requirement` hook (see `Requirement`). For a unit or structure type, or a level of research\n *\n * @beta\n */\nexport function unlockRefusal(\n\tworld: World,\n\tplayer: PlayerId,\n\tkind: 'unit' | 'upgrade',\n\tid: string,\n\trequires: string[] | undefined,\n\tlevel?: number\n): Message | undefined {\n\tconst lacking = missing(world, player, requires)\n\tconst refusal = lacking.length ? engineMessage('requires', { units: lacking }) : undefined\n\tif (!world.hooks.has('requirement')) return refusal\n\tconst decided = refusalOf(world.hooks.run('requirement', { player, kind, id, level, missing: lacking, cancelled: !!refusal, reason: refusal }))\n\treturn decided ? toMessage(decided) : undefined\n}\n\n/**\n * Checks that something is the player's to make at all (`isAvailable`: their race, the `available` hook), then what it\n * requires, by `unlockRefusal`, and tells the player what stands in the way. True when nothing does\n *\n * @beta\n */\nexport function unlocked(\n\tworld: World,\n\tplayer: PlayerId,\n\tkind: 'unit' | 'upgrade',\n\tid: string,\n\trequires: string[] | undefined,\n\tlevel?: number\n): boolean {\n\tif (!isAvailable(world, player, kind, id)) {\n\t\tworld.message(player, engineMessage('cannotDoThat'))\n\t\treturn false\n\t}\n\tconst refusal = unlockRefusal(world, player, kind, id, requires, level)\n\tif (refusal) world.message(player, refusal)\n\treturn !refusal\n}\n\n/**\n * How `morph` goes about it where a building's upgrade does not: what a form needs (`takeForm`)\n *\n * @beta\n */\nexport interface MorphOptions {\n\t/**\n\t * What it was told goes on in the new type (what it was doing starts over from where it stands), where an upgrade\n\t * drops it all\n\t */\n\tkeepOrders?: boolean\n\t/** Its health and mana are the same parts of the most it can have in the new type, where an upgrade keeps what was lost */\n\tshare?: boolean\n\t/** What it can cast in the new type, all of it, in place of what the type's abilities and what it learned make */\n\tabilities?: AbilityState[]\n}\n\n/**\n * Turns an entity into another type, where it stands: a building upgraded, a unit transformed (a druid into a bear, a\n * 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),\n * whether it fights, gathers or carries, its abilities (those of the old type it keeps are kept as they were, at their\n * levels and cooldowns), and what it makes. What it went through stays: health lost, mana, buffs, experience, items.\n * The parts of the game it had none of are given it as `spawn` gives them (`Component.onSpawn`), and the `morphed` hook\n * runs: what a pack gives it of its own for its new type (the heroes pack: a hero's level, a shop's wares). `options`\n * keep its orders and the shares of its health and mana, and say its abilities: what a hero's form takes (`takeForm`)\n *\n * @beta\n */\nexport function morph(world: World, entity: Entity, into: string, options: MorphOptions = {}): void {\n\tconst def = world.registry.unit(into)\n\tconst old = entity.def\n\tconst from = old.id\n\tconst hurt = entity.maxHealth - entity.health\n\tconst health = entity.maxHealth > 0 ? entity.health / entity.maxHealth : 1\n\tconst mana = entity.maxMana > 0 ? entity.mana / entity.maxMana : 1\n\t// filed again: what it turns into may sell things, or not\n\tworld.index.remove(entity)\n\tentity.retype(def)\n\tworld.index.add(entity)\n\tconst stats = statsOf(world, entity)\n\tentity.maxHealth = stats.health\n\tif (options.share) {\n\t\tentity.health = health * stats.health\n\t\tentity.maxMana = stats.mana\n\t\tentity.mana = mana * stats.mana\n\t} else entity.health = Math.max(stats.health - hurt, 1)\n\t// a unit that makes things too: what `spawn` gives a structure only\n\tif ((def.trains?.length || def.researches?.length || upgradesOf(def).length) && !entity.has(productionQueue))\n\t\tentity.set(productionQueue, { queue: [], rally: null })\n\tif (def.kind === 'unit' && old.kind === 'unit') transform(world, entity, old, stats.moveSpeed, options)\n\t// what each part of the game gives one of the new type as it is made, where it has none of it yet: a hold, slots, a\n\t// game's own (`Component.onSpawn`); what it has already (a hold with passengers, its slots) stays as it is\n\tfor (const part of world.registry.spawning) if (!entity.has(part)) part.onSpawn!(entity, world)\n\t// what a pack gives it of its own for its new type: a hero's level, a shop's wares (`heroesPack`)\n\tif (world.hooks.has('morphed')) world.hooks.run('morphed', { entity, from })\n\tworld.events.emit(entityMorphed, { entity, from })\n}\n\n/** What changes of a unit that becomes another unit type, beyond its stats */\nfunction transform(world: World, entity: Entity, old: UnitTypeDef, speed: number, options: MorphOptions): void {\n\tconst { def } = entity\n\t// how it moves: on the ground or in the air, how big it is\n\tconst m = entity.get(moving)\n\tconst reshaped = old.flying !== def.flying || old.radius !== def.radius || old.naval !== def.naval\n\tif (m && (reshaped || !speed)) world.nav.removeAgent(entity.id)\n\tif (m && speed && reshaped) {\n\t\tworld.nav.addAgent(entity.id, entity.pos, agentParamsOf(entity, speed))\n\t\t// a new agent walks through nobody: phasing is seen to again on the next tick (`BuffDef.phasing`)\n\t\tdelete m.phased\n\t}\n\tif (!speed) entity.remove(moving)\n\telse if (m) {\n\t\t// an agent kept is told its new speed too\n\t\tif (!reshaped && m.speed !== speed) world.nav.setSpeed(entity.id, speed)\n\t\tm.speed = speed\n\t}\n\t// whether it fights, and gathers\n\tif (def.attacks?.length) {\n\t\tif (!entity.has(fighting))\n\t\t\tentity.set(fighting, { cooldown: 0, swing: 0, swingTarget: 0, autoTarget: 0, lastAttacker: 0, guard: null, passive: false })\n\t} else entity.remove(fighting)\n\tif (!def.harvester) entity.remove(gathering)\n\telse if (!entity.has(gathering)) entity.set(gathering, { carrying: 0, kind: null, resource: 0 })\n\tif (options.abilities) entity.setAbilities(options.abilities)\n\telse {\n\t\t// its abilities: those of the new type, the ones it had already as they were; what a hero learned stays\n\t\tconst kept = new Map(entity.abilities.map((state) => [state.id, state]))\n\t\tconst learned = new Set([...(old.hero?.learns ?? []), ...(old.hero?.spells ?? []), ...(def.hero?.learns ?? []), ...(def.hero?.spells ?? [])])\n\t\tentity.setAbilities([\n\t\t\t...(def.abilities ?? []).map((id) => kept.get(id) ?? { id, level: 1, cooldown: 0, autocast: world.registry.ability(id).autocast ?? false }),\n\t\t\t...entity.abilities.filter((state) => learned.has(state.id) && !(def.abilities ?? []).includes(state.id))\n\t\t])\n\t}\n\t// what it carries: the slots of the new type, what does not fit left on the ground\n\tif (def.inventory !== old.inventory) {\n\t\tconst items = (slotsOf(entity) ?? []).filter((item) => item !== null)\n\t\tif (def.inventory)\n\t\t\tentity.set(\n\t\t\t\tinventorySlots,\n\t\t\t\tArray.from({ length: def.inventory }, (_, i) => items[i] ?? null)\n\t\t\t)\n\t\telse entity.remove(inventorySlots)\n\t\tfor (const item of items.slice(def.inventory ?? 0)) dropOnGround(world, item, entity.pos)\n\t}\n\tif (options.keepOrders) {\n\t\t// what it was doing starts over from where it stands, as what it is now; what was to come after waits its turn\n\t\tresetStance(world, entity)\n\t\tconst order = entity.orders[0]\n\t\tif (order) order.started = false\n\t}\n\t// what it was doing may not be for what it is now\n\telse clearOrders(world, entity)\n}\n\n/** What became another, to those who see it */\nexport const toldMorphed = replicateEvent(entityMorphed, 'morphed', ({ entity, from }, view) =>\n\tview.knows(entity) ? { type: 'morphed', id: entity.id, from } : undefined\n)\n\n/**\n * What the `requirement` hook decided for a player, where it is not what the requirements say: what their screen could\n * not work out for itself (`PlayerState.own.unlocks`). Nothing where the hook agrees with them all\n *\n * @beta\n */\nexport function decidedUnlocks(world: World, player: PlayerId): Record<string, Message | null> | undefined {\n\tconst tech = techOf(world, player)\n\tlet decided: Record<string, Message | null> | undefined\n\tconst compare = (key: string, kind: 'unit' | 'upgrade', id: string, requires: string[] | undefined, level?: number) => {\n\t\tconst lacking = missing(world, player, requires, tech)\n\t\tconst declared = lacking.length ? 'requires' : undefined\n\t\tconst refusal = unlockRefusal(world, player, kind, id, requires, level)\n\t\tif (refusal?.key !== declared || (refusal && declared && refusal.params?.units?.toString() !== lacking.toString()))\n\t\t\t(decided ??= {})[key] = refusal ?? null\n\t}\n\tfor (const def of world.registry.units.all()) compare(def.id, 'unit', def.id, def.requires)\n\tfor (const def of world.registry.upgrades.all()) {\n\t\tconst level = world.player(player).upgrades.get(def.id) ?? 0\n\t\tif (level < (def.maxLevel ?? 1)) compare(`upgrade:${def.id}`, 'upgrade', def.id, def.requires?.[level], level + 1)\n\t}\n\treturn decided\n}\n\n/**\n * What the `available` hook decided for a player, where it is not what their race says: what their screen could not\n * work out for itself (`PlayerState.own.availability`). Nothing where the hook agrees\n *\n * @beta\n */\nexport function decidedAvailability(world: World, player: PlayerId): Record<string, boolean> | undefined {\n\tconst race = world.player(player).race\n\tlet decided: Record<string, boolean> | undefined\n\tfor (const def of world.registry.units.all()) {\n\t\tconst available = isAvailable(world, player, 'unit', def.id)\n\t\tif (available !== availableTo(def, race)) (decided ??= {})[def.id] = available\n\t}\n\tfor (const def of world.registry.upgrades.all()) {\n\t\tconst available = isAvailable(world, player, 'upgrade', def.id)\n\t\tif (available !== availableTo(def, race)) (decided ??= {})[`upgrade:${def.id}`] = available\n\t}\n\treturn decided\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAsBA,SAAgB,OAAO,OAAc,QAA+B;CACnE,MAAM,uBAAO,IAAI,IAAY;CAC7B,KAAK,MAAM,UAAU,MAAM,MAAM,QAAQ,MAAM,GAAG;EACjD,IAAI,CAAC,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6
6
|
*/
|
|
7
7
|
export interface TechNode {
|
|
8
|
+
/** The unit type or upgrade id this node stands for */
|
|
8
9
|
id: string;
|
|
10
|
+
/** Whether the node is a unit, a building or an upgrade */
|
|
9
11
|
kind: 'unit' | 'building' | 'upgrade';
|
|
12
|
+
/** The name shown for the node */
|
|
10
13
|
name: string;
|
|
14
|
+
/** How far the node is from the start of the tree, 0 for what is made from the start */
|
|
11
15
|
tier: number;
|
|
12
16
|
/** The race it is of, where it says */
|
|
13
17
|
race?: string;
|
|
@@ -19,8 +23,11 @@ export interface TechNode {
|
|
|
19
23
|
* @beta
|
|
20
24
|
*/
|
|
21
25
|
export interface TechEdge {
|
|
26
|
+
/** The id of the node that makes `to`, or that `to` requires */
|
|
22
27
|
from: string;
|
|
28
|
+
/** The id of the node that is made, or that requires `from` */
|
|
23
29
|
to: string;
|
|
30
|
+
/** How `from` leads to `to`: it trains, builds, hires, researches or upgrades to it, or `to` requires it */
|
|
24
31
|
kind: 'trains' | 'builds' | 'hires' | 'researches' | 'upgradesTo' | 'requires';
|
|
25
32
|
}
|
|
26
33
|
/**
|
package/dist/techTree.js
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { upgradesOf } from "./defs.js";
|
|
2
|
+
//#region src/techTree.ts
|
|
3
|
+
/**
|
|
4
|
+
* The tech tree of a game's rules: its things that are made or make something (scenery and the map's creeps left
|
|
5
|
+
* out), the edges between them, and each one's tier. Tiers go by what makes what from what nothing makes and from the
|
|
6
|
+
* buildings that make the builders, require nothing and are no other's upgrade (a hall; else, where everything is
|
|
7
|
+
* made of something, the buildings that require nothing, are no upgrade and make something),
|
|
8
|
+
* each thing after what it requires; a loop of requirements stops at the number of things
|
|
9
|
+
*
|
|
10
|
+
* @beta
|
|
11
|
+
*/
|
|
12
|
+
function techTree(registry) {
|
|
13
|
+
const units = registry.units.all();
|
|
14
|
+
const upgrades = registry.upgrades.all();
|
|
15
|
+
const edges = [];
|
|
16
|
+
const known = /* @__PURE__ */ new Set([...units.map((unit) => unit.id), ...upgrades.map((upgrade) => upgrade.id)]);
|
|
17
|
+
const add = (from, to, kind) => {
|
|
18
|
+
if (known.has(from) && known.has(to) && from !== to) edges.push({
|
|
19
|
+
from,
|
|
20
|
+
to,
|
|
21
|
+
kind
|
|
22
|
+
});
|
|
23
|
+
};
|
|
24
|
+
for (const unit of units) {
|
|
25
|
+
for (const id of unit.trains ?? []) add(unit.id, id, "trains");
|
|
26
|
+
for (const id of unit.builds ?? []) add(unit.id, id, "builds");
|
|
27
|
+
for (const id of unit.hires ?? []) add(unit.id, id, "hires");
|
|
28
|
+
for (const id of unit.researches ?? []) add(unit.id, id, "researches");
|
|
29
|
+
for (const id of upgradesOf(unit)) add(unit.id, id, "upgradesTo");
|
|
30
|
+
for (const id of unit.requires ?? []) add(id, unit.id, "requires");
|
|
31
|
+
}
|
|
32
|
+
for (const upgrade of upgrades) for (const id of upgrade.requires?.[0] ?? []) add(id, upgrade.id, "requires");
|
|
33
|
+
const inTree = new Set(edges.flatMap((edge) => [edge.from, edge.to]));
|
|
34
|
+
const makes = edges.filter((edge) => edge.kind !== "requires");
|
|
35
|
+
const made = new Set(makes.map((edge) => edge.to));
|
|
36
|
+
const needs = /* @__PURE__ */ new Map();
|
|
37
|
+
for (const edge of edges) if (edge.kind === "requires") needs.set(edge.to, [...needs.get(edge.to) ?? [], edge.from]);
|
|
38
|
+
const buildings = new Set(units.filter((unit) => unit.kind !== "unit").map((unit) => unit.id));
|
|
39
|
+
const upgraded = new Set(edges.filter((edge) => edge.kind === "upgradesTo").map((edge) => edge.to));
|
|
40
|
+
let start = [...inTree].filter((id) => !made.has(id));
|
|
41
|
+
const builders = new Set(units.filter((unit) => unit.builds?.length).map((unit) => unit.id));
|
|
42
|
+
const first = [...inTree].filter((id) => buildings.has(id) && !needs.has(id) && !upgraded.has(id));
|
|
43
|
+
const halls = first.filter((id) => makes.some((edge) => edge.from === id && builders.has(edge.to)));
|
|
44
|
+
start = [.../* @__PURE__ */ new Set([...start, ...halls])];
|
|
45
|
+
if (!start.length) start = first.filter((id) => makes.some((edge) => edge.from === id));
|
|
46
|
+
if (!start.length) start = [...inTree].filter((id) => !needs.has(id));
|
|
47
|
+
const tier = new Map(start.map((id) => [id, 0]));
|
|
48
|
+
for (let queue = [...start]; queue.length;) {
|
|
49
|
+
const next = [];
|
|
50
|
+
for (const id of queue) for (const edge of makes) if (edge.from === id && !tier.has(edge.to)) {
|
|
51
|
+
tier.set(edge.to, tier.get(id) + 1);
|
|
52
|
+
next.push(edge.to);
|
|
53
|
+
}
|
|
54
|
+
queue = next;
|
|
55
|
+
}
|
|
56
|
+
for (let pass = 0; pass < inTree.size; pass++) {
|
|
57
|
+
let moved = false;
|
|
58
|
+
for (const [id, required] of needs) {
|
|
59
|
+
const after = Math.max(...required.map((other) => (tier.get(other) ?? 0) + 1));
|
|
60
|
+
if (after > (tier.get(id) ?? 0)) {
|
|
61
|
+
tier.set(id, after);
|
|
62
|
+
moved = true;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
if (!moved) break;
|
|
66
|
+
}
|
|
67
|
+
const nodes = [];
|
|
68
|
+
for (const unit of units) if (inTree.has(unit.id)) nodes.push({
|
|
69
|
+
id: unit.id,
|
|
70
|
+
kind: unit.kind === "unit" ? "unit" : "building",
|
|
71
|
+
name: unit.name,
|
|
72
|
+
tier: tier.get(unit.id) ?? 0,
|
|
73
|
+
...unit.race && { race: unit.race }
|
|
74
|
+
});
|
|
75
|
+
for (const upgrade of upgrades) if (inTree.has(upgrade.id)) nodes.push({
|
|
76
|
+
id: upgrade.id,
|
|
77
|
+
kind: "upgrade",
|
|
78
|
+
name: upgrade.name,
|
|
79
|
+
tier: tier.get(upgrade.id) ?? 0,
|
|
80
|
+
...upgrade.race && { race: upgrade.race }
|
|
81
|
+
});
|
|
82
|
+
return {
|
|
83
|
+
nodes,
|
|
84
|
+
edges
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
//#endregion
|
|
88
|
+
export { techTree };
|
|
89
|
+
|
|
90
|
+
//# sourceMappingURL=techTree.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"techTree.js","names":[],"sources":["../src/techTree.ts"],"sourcesContent":["import { upgradesOf } from './defs'\nimport type { Registry } from './registry'\n\n/*\n * The tech tree of a game (master plan OH13): what makes what (a building trains a unit, a worker builds a building, a\n * building researches an upgrade, a type upgrades to another) and what needs what (`requires`), each thing on a tier:\n * how far from the start it is. For the editor's drawing of it, and for a game's own (a help screen)\n */\n\n/**\n * A thing of a tech tree: a unit or building type, or an upgrade, on its tier (0: made from the start)\n *\n * @beta\n */\nexport interface TechNode {\n\t/** The unit type or upgrade id this node stands for */\n\tid: string\n\t/** Whether the node is a unit, a building or an upgrade */\n\tkind: 'unit' | 'building' | 'upgrade'\n\t/** The name shown for the node */\n\tname: string\n\t/** How far the node is from the start of the tree, 0 for what is made from the start */\n\ttier: number\n\t/** The race it is of, where it says */\n\trace?: string\n}\n\n/**\n * How one thing of a tech tree leads to another: `from` makes `to` (trains, builds, hires, researches, upgrades to),\n * or `to` requires `from`\n *\n * @beta\n */\nexport interface TechEdge {\n\t/** The id of the node that makes `to`, or that `to` requires */\n\tfrom: string\n\t/** The id of the node that is made, or that requires `from` */\n\tto: string\n\t/** How `from` leads to `to`: it trains, builds, hires, researches or upgrades to it, or `to` requires it */\n\tkind: 'trains' | 'builds' | 'hires' | 'researches' | 'upgradesTo' | 'requires'\n}\n\n/**\n * The tech tree of a game's rules: its things that are made or make something (scenery and the map's creeps left\n * out), the edges between them, and each one's tier. Tiers go by what makes what from what nothing makes and from the\n * buildings that make the builders, require nothing and are no other's upgrade (a hall; else, where everything is\n * made of something, the buildings that require nothing, are no upgrade and make something),\n * each thing after what it requires; a loop of requirements stops at the number of things\n *\n * @beta\n */\nexport function techTree(registry: Pick<Registry, 'units' | 'upgrades'>): { nodes: TechNode[]; edges: TechEdge[] } {\n\tconst units = registry.units.all()\n\tconst upgrades = registry.upgrades.all()\n\tconst edges: TechEdge[] = []\n\tconst known = new Set([...units.map((unit) => unit.id), ...upgrades.map((upgrade) => upgrade.id)])\n\tconst add = (from: string, to: string, kind: TechEdge['kind']) => {\n\t\tif (known.has(from) && known.has(to) && from !== to) edges.push({ from, to, kind })\n\t}\n\tfor (const unit of units) {\n\t\tfor (const id of unit.trains ?? []) add(unit.id, id, 'trains')\n\t\tfor (const id of unit.builds ?? []) add(unit.id, id, 'builds')\n\t\tfor (const id of unit.hires ?? []) add(unit.id, id, 'hires')\n\t\tfor (const id of unit.researches ?? []) add(unit.id, id, 'researches')\n\t\tfor (const id of upgradesOf(unit)) add(unit.id, id, 'upgradesTo')\n\t\tfor (const id of unit.requires ?? []) add(id, unit.id, 'requires')\n\t}\n\tfor (const upgrade of upgrades) for (const id of upgrade.requires?.[0] ?? []) add(id, upgrade.id, 'requires')\n\n\t// what is in the tree: what makes, is made, or requires or is required\n\tconst inTree = new Set(edges.flatMap((edge) => [edge.from, edge.to]))\n\tconst makes = edges.filter((edge) => edge.kind !== 'requires')\n\tconst made = new Set(makes.map((edge) => edge.to))\n\tconst needs = new Map<string, string[]>()\n\tfor (const edge of edges) if (edge.kind === 'requires') needs.set(edge.to, [...(needs.get(edge.to) ?? []), edge.from])\n\t// the start: what nothing makes; where all is made of something (a hall and its workers), the buildings that require\n\t// nothing and are no other's upgrade (a game starts with a hall), else what requires nothing\n\tconst buildings = new Set(units.filter((unit) => unit.kind !== 'unit').map((unit) => unit.id))\n\tconst upgraded = new Set(edges.filter((edge) => edge.kind === 'upgradesTo').map((edge) => edge.to))\n\tlet start = [...inTree].filter((id) => !made.has(id))\n\t// (of those, the ones that make the builders: a town hall, not a barracks)\n\tconst builders = new Set(units.filter((unit) => unit.builds?.length).map((unit) => unit.id))\n\tconst first = [...inTree].filter((id) => buildings.has(id) && !needs.has(id) && !upgraded.has(id))\n\t// and those halls beside what nothing makes, which may be no player's to make at all (a neutral shipyard that hires)\n\tconst halls = first.filter((id) => makes.some((edge) => edge.from === id && builders.has(edge.to)))\n\tstart = [...new Set([...start, ...halls])]\n\tif (!start.length) start = first.filter((id) => makes.some((edge) => edge.from === id))\n\tif (!start.length) start = [...inTree].filter((id) => !needs.has(id))\n\tconst tier = new Map<string, number>(start.map((id) => [id, 0]))\n\t// out along what makes what, nearest first\n\tfor (let queue = [...start]; queue.length;) {\n\t\tconst next: string[] = []\n\t\tfor (const id of queue)\n\t\t\tfor (const edge of makes)\n\t\t\t\tif (edge.from === id && !tier.has(edge.to)) {\n\t\t\t\t\ttier.set(edge.to, tier.get(id)! + 1)\n\t\t\t\t\tnext.push(edge.to)\n\t\t\t\t}\n\t\tqueue = next\n\t}\n\t// then after what each requires, as long as that moves anything, and no more often than there are things\n\tfor (let pass = 0; pass < inTree.size; pass++) {\n\t\tlet moved = false\n\t\tfor (const [id, required] of needs) {\n\t\t\tconst after = Math.max(...required.map((other) => (tier.get(other) ?? 0) + 1))\n\t\t\tif (after > (tier.get(id) ?? 0)) {\n\t\t\t\ttier.set(id, after)\n\t\t\t\tmoved = true\n\t\t\t}\n\t\t}\n\t\tif (!moved) break\n\t}\n\tconst nodes: TechNode[] = []\n\tfor (const unit of units)\n\t\tif (inTree.has(unit.id))\n\t\t\tnodes.push({\n\t\t\t\tid: unit.id,\n\t\t\t\tkind: unit.kind === 'unit' ? 'unit' : 'building',\n\t\t\t\tname: unit.name,\n\t\t\t\ttier: tier.get(unit.id) ?? 0,\n\t\t\t\t...(unit.race && { race: unit.race })\n\t\t\t})\n\tfor (const upgrade of upgrades)\n\t\tif (inTree.has(upgrade.id))\n\t\t\tnodes.push({\n\t\t\t\tid: upgrade.id,\n\t\t\t\tkind: 'upgrade',\n\t\t\t\tname: upgrade.name,\n\t\t\t\ttier: tier.get(upgrade.id) ?? 0,\n\t\t\t\t...(upgrade.race && { race: upgrade.race })\n\t\t\t})\n\treturn { nodes, edges }\n}\n"],"mappings":";;;;;;;;;;;AAmDA,SAAgB,SAAS,UAA0F;CAClH,MAAM,QAAQ,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