@v12-engine/engine 0.1.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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
package/dist/shared.js
ADDED
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
import { at, supplyOf, supplyPoolsOf } from "./defs.js";
|
|
2
|
+
import { currencyOf, shortOf } from "./player.js";
|
|
3
|
+
import { engineMessage } from "./messages.js";
|
|
4
|
+
//#region src/shared.ts
|
|
5
|
+
/**
|
|
6
|
+
* Rules the simulation and a player's screen both need, written once. Each works on plain facts that a world
|
|
7
|
+
* entity and a client's view of one can both give, so the screen greys out a button for the very reason the
|
|
8
|
+
* simulation would refuse it, and a game's own rules (items 9 to 11) reach both alike.
|
|
9
|
+
*
|
|
10
|
+
* The simulation has the last word all the same: the screen may know less than it does (a buff it is not told
|
|
11
|
+
* of, a step it has not seen yet), and only uses these to say something sooner.
|
|
12
|
+
*/
|
|
13
|
+
/**
|
|
14
|
+
* Why an ability may not be used on a target, or undefined when it may
|
|
15
|
+
*
|
|
16
|
+
* @beta
|
|
17
|
+
*/
|
|
18
|
+
function targetRefusal(ability, target) {
|
|
19
|
+
const rules = ability.targets ?? {};
|
|
20
|
+
if (target.targetableBy && !target.targetableBy.includes(ability.id)) return engineMessage("cannotTargetThat");
|
|
21
|
+
if (target.untargetable && target.relation !== "self") return engineMessage("cannotTargetThat");
|
|
22
|
+
if (!(rules.kinds ?? ["unit"]).includes(target.kind)) return engineMessage("cannotTargetThat");
|
|
23
|
+
if (rules.layers && !rules.layers.includes(target.layer)) return engineMessage(target.layer === "air" ? "cannotTargetAir" : "mustTargetAir");
|
|
24
|
+
if (rules.heroes && !target.hero) return engineMessage("mustTargetHero");
|
|
25
|
+
if (rules.heroes === false && target.hero) return engineMessage("cannotTargetHero");
|
|
26
|
+
if (rules.tags && !rules.tags.some((tag) => target.tags?.includes(tag))) return engineMessage("cannotTargetThat");
|
|
27
|
+
if (target.spellImmune && target.relation !== "self" && ability.piercesImmunity !== true) return engineMessage("targetSpellImmune");
|
|
28
|
+
switch (target.relation) {
|
|
29
|
+
case "self": return rules.self ?? rules.allies ?? false ? void 0 : engineMessage("cannotTargetSelf");
|
|
30
|
+
case "ally": return rules.allies ? void 0 : engineMessage("cannotTargetFriends");
|
|
31
|
+
case "enemy":
|
|
32
|
+
case "neutral": return rules.enemies && !target.invulnerable ? void 0 : engineMessage("cannotTargetThat");
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* How far away the target of an ability may be: what it says, and for some as far as the caster's attacks reach on top
|
|
37
|
+
*
|
|
38
|
+
* @beta
|
|
39
|
+
*/
|
|
40
|
+
var abilityReach = (ability, level, attackRange) => at(ability.range, level) + (ability.attackRange ? attackRange : 0);
|
|
41
|
+
/**
|
|
42
|
+
* How many uses an ability with charges has left (`AbilityDef.charges`), at its level: what its state says, or all it
|
|
43
|
+
* holds when that says nothing. Undefined for an ability without charges
|
|
44
|
+
*
|
|
45
|
+
* @beta
|
|
46
|
+
*/
|
|
47
|
+
function chargesLeft(ability, state) {
|
|
48
|
+
if (!ability.charges) return void 0;
|
|
49
|
+
return state.charges ?? Math.max(Math.round(at(ability.charges.count, Math.max(state.level, 1))), 1);
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Why an ability cannot be used right now, or undefined when it can
|
|
53
|
+
*
|
|
54
|
+
* @beta
|
|
55
|
+
*/
|
|
56
|
+
function abilityRefusal(ability, facts) {
|
|
57
|
+
if (facts.decided !== void 0) return facts.decided ?? void 0;
|
|
58
|
+
if (facts.level < 1) return engineMessage("cannotDoThat");
|
|
59
|
+
if (facts.cooldown > 0 || facts.charges === 0) return engineMessage("notReady");
|
|
60
|
+
if (facts.grounded) return engineMessage("grounded");
|
|
61
|
+
if (facts.item) return void 0;
|
|
62
|
+
const mana = facts.noManaCosts ? 0 : at(ability.manaCost, facts.level);
|
|
63
|
+
const inHealth = facts.healthPerMana ? mana * facts.healthPerMana : 0;
|
|
64
|
+
if (!inHealth && mana > facts.mana) return engineMessage("notEnoughMana");
|
|
65
|
+
const health = inHealth + (ability.healthCost === void 0 ? 0 : at(ability.healthCost, facts.level) * facts.maxHealth);
|
|
66
|
+
if ((ability.healthCost !== void 0 || inHealth > 0) && facts.health <= health) return engineMessage("notEnoughHealth");
|
|
67
|
+
if (!facts.spell && facts.silenced) return engineMessage("silenced");
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Whether a worker gathers a kind of resource at all (`harvester.ids`): the game's `canHarvest` hook may refuse it a
|
|
71
|
+
* resource all the same (`canHarvest`)
|
|
72
|
+
*
|
|
73
|
+
* @beta
|
|
74
|
+
*/
|
|
75
|
+
var gathers = (def, kind) => !!def.harvester && (!def.harvester.ids || def.harvester.ids.includes(kind));
|
|
76
|
+
/**
|
|
77
|
+
* Whether something of a race (`UnitTypeDef.race`, `UpgradeDef.race`) is a player's to make as their race goes: what is
|
|
78
|
+
* of no race is everyone's, and a player of none (the neutral players, the creeps, any in a game without races) may
|
|
79
|
+
* make anything. The `available` hook has the last word (`isAvailable`)
|
|
80
|
+
*
|
|
81
|
+
* @beta
|
|
82
|
+
*/
|
|
83
|
+
var availableTo = (def, race) => def.race === void 0 || race === void 0 || def.race === race;
|
|
84
|
+
/**
|
|
85
|
+
* Whether a player may make something at all, as the simulation decided (`availability`, by `key`) or else as their
|
|
86
|
+
* race goes: what is not is left off their buttons
|
|
87
|
+
*
|
|
88
|
+
* @beta
|
|
89
|
+
*/
|
|
90
|
+
function availableToPlayer(def, player, key) {
|
|
91
|
+
return player.availability?.[key] ?? availableTo(def, player.race);
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Why something may not be made as far as what it requires goes: as the simulation decided (`unlocks`), or by the finished buildings it requires
|
|
95
|
+
*
|
|
96
|
+
* @beta
|
|
97
|
+
*/
|
|
98
|
+
function requirementRefusal(requires, player, key) {
|
|
99
|
+
const decided = player.unlocks?.[key];
|
|
100
|
+
if (decided !== void 0) return decided ?? void 0;
|
|
101
|
+
const lacking = missingTech(requires, player.tech);
|
|
102
|
+
return lacking.length ? engineMessage("requires", { units: lacking }) : void 0;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* The requirements a player does not meet, by unit type
|
|
106
|
+
*
|
|
107
|
+
* @internal
|
|
108
|
+
*/
|
|
109
|
+
function missingTech(requires, tech) {
|
|
110
|
+
if (!requires?.length) return NOTHING_MISSING;
|
|
111
|
+
let lacking;
|
|
112
|
+
for (const id of requires) if (!("has" in tech ? tech.has(id) : tech.includes(id))) (lacking ??= []).push(id);
|
|
113
|
+
return lacking ?? NOTHING_MISSING;
|
|
114
|
+
}
|
|
115
|
+
/** What `missingTech` gives when nothing is missing: the same one every time, and frozen, so nobody adds to it */
|
|
116
|
+
var NOTHING_MISSING = Object.freeze([]);
|
|
117
|
+
/**
|
|
118
|
+
* What stands in the way of a cost, or undefined when the player can pay it
|
|
119
|
+
*
|
|
120
|
+
* @beta
|
|
121
|
+
*/
|
|
122
|
+
function costRefusal(resources, cost) {
|
|
123
|
+
const short = shortOf(resources, cost);
|
|
124
|
+
return short ? engineMessage("notEnough", { resource: short }) : void 0;
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Why a player cannot have a unit made, or undefined when they can, as far as they and the unit type go: whether
|
|
128
|
+
* the building has room, and what a game's hooks say (they can change the cost), is for the simulation. In the order the
|
|
129
|
+
* player is told
|
|
130
|
+
*
|
|
131
|
+
* @beta
|
|
132
|
+
*/
|
|
133
|
+
function trainRefusal(registry, def, player, options) {
|
|
134
|
+
const locked = options?.tech === false ? void 0 : requirementRefusal(def.requires, player, def.id);
|
|
135
|
+
if (locked) return locked;
|
|
136
|
+
const { settings: rules } = registry;
|
|
137
|
+
if (def.hero) {
|
|
138
|
+
if (player.heroes.includes(def.id)) return engineMessage("alreadyHaveHero");
|
|
139
|
+
if (player.heroes.length >= registry.settings.heroes.maxHeroes) return engineMessage("tooManyHeroes");
|
|
140
|
+
}
|
|
141
|
+
const supply = supplyOf(def);
|
|
142
|
+
if (supply > 0 && player.supplyUsed + supply > player.supplyCap) return engineMessage(player.supplyCap >= rules.supply.max ? "supplyLimit" : "supplyBlocked");
|
|
143
|
+
const pools = supplyPoolsOf(def);
|
|
144
|
+
for (const name in pools) {
|
|
145
|
+
const taken = pools[name];
|
|
146
|
+
const pool = player.supplies?.[name];
|
|
147
|
+
const most = rules.supply.pools?.[name]?.max;
|
|
148
|
+
if (taken > 0 && pool && pool.used + taken > pool.cap) return engineMessage(most !== void 0 && pool.cap >= most ? "supplyLimit" : "supplyBlocked", { pool: name });
|
|
149
|
+
}
|
|
150
|
+
return options?.cost === false ? void 0 : costRefusal(player.resources, def.cost);
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* What a shop pays for an item: a part of its price (the item's `sellRate`, or the game's `sellPrice`), and of what is
|
|
154
|
+
* left of it for what runs out (a stack counts each of it)
|
|
155
|
+
*
|
|
156
|
+
* @beta
|
|
157
|
+
*/
|
|
158
|
+
function sellValue(registry, item, charges) {
|
|
159
|
+
const def = registry.item(item);
|
|
160
|
+
const part = def.charges ? charges / def.charges : 1;
|
|
161
|
+
return Math.round(currencyOf(registry, def.cost) * (def.sellRate ?? registry.settings.economy.sellPrice) * part);
|
|
162
|
+
}
|
|
163
|
+
//#endregion
|
|
164
|
+
export { abilityReach, abilityRefusal, availableTo, availableToPlayer, chargesLeft, costRefusal, gathers, missingTech, requirementRefusal, sellValue, targetRefusal, trainRefusal };
|
|
165
|
+
|
|
166
|
+
//# sourceMappingURL=shared.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shared.js","names":[],"sources":["../src/shared.ts"],"sourcesContent":["/**\n * Rules the simulation and a player's screen both need, written once. Each works on plain facts that a world\n * entity and a client's view of one can both give, so the screen greys out a button for the very reason the\n * simulation would refuse it, and a game's own rules (items 9 to 11) reach both alike.\n *\n * The simulation has the last word all the same: the screen may know less than it does (a buff it is not told\n * of, a step it has not seen yet), and only uses these to say something sooner.\n */\nimport { type AbilityDef, at, type Cost, type EntityKind, type Layer, supplyOf, supplyPoolsOf, type UnitTypeDef } from './defs'\nimport { currencyOf } from './player'\nimport { engineMessage, type Message } from './messages'\nimport { type Purse, shortOf } from './player'\nimport type { Registry } from './registry'\n\n// ---- targets\n\n/**\n * Who a target is to the one using an ability on it\n *\n * @beta\n */\nexport type Relation = 'self' | 'ally' | 'enemy' | 'neutral'\n\n/**\n * What there is to know about a target, for whether an ability may be used on it\n *\n * @beta\n */\nexport interface TargetFacts {\n\t/** The target's entity kind, such as unit or structure */\n\tkind: EntityKind\n\t/** The layer the target is on (ground, air, water), which an ability's `targets` may name */\n\tlayer: Layer\n\t/** Whether the target is a hero */\n\thero: boolean\n\t/** Whether the target cannot be hurt: its type (`UnitTypeDef.invulnerable`) or a buff on it (`BuffDef.invulnerable`) */\n\tinvulnerable: boolean\n\t/** The abilities that alone may target it (`UnitTypeDef.targetableBy`) */\n\ttargetableBy?: readonly string[]\n\t/** A buff puts it out of everyone else's reach (`BuffDef.untargetable`): nothing but its own abilities is cast on it @beta */\n\tuntargetable?: boolean\n\t/** The tags of its type (`UnitTypeDef.tags`), for an ability that targets only some (`targets.tags`) @beta */\n\ttags?: readonly string[]\n\t/** What the target is to the caster: self, ally, enemy or neutral */\n\trelation: Relation\n\t/** Immune to spells (see `UnitTypeDef.spellImmune`): no ability touches it but its own, and those that get through */\n\tspellImmune?: boolean\n}\n\n/**\n * Why an ability may not be used on a target, or undefined when it may\n *\n * @beta\n */\nexport function targetRefusal(ability: AbilityDef, target: TargetFacts): Message | undefined {\n\tconst rules = ability.targets ?? {}\n\tif (target.targetableBy && !target.targetableBy.includes(ability.id)) return engineMessage('cannotTargetThat')\n\tif (target.untargetable && target.relation !== 'self') return engineMessage('cannotTargetThat')\n\tif (!(rules.kinds ?? ['unit']).includes(target.kind)) return engineMessage('cannotTargetThat')\n\tif (rules.layers && !rules.layers.includes(target.layer)) return engineMessage(target.layer === 'air' ? 'cannotTargetAir' : 'mustTargetAir')\n\tif (rules.heroes && !target.hero) return engineMessage('mustTargetHero')\n\tif (rules.heroes === false && target.hero) return engineMessage('cannotTargetHero')\n\tif (rules.tags && !rules.tags.some((tag) => target.tags?.includes(tag))) return engineMessage('cannotTargetThat')\n\t// one that gets through in code: the simulation knows it, and says so in its facts of the target\n\tif (target.spellImmune && target.relation !== 'self' && ability.piercesImmunity !== true) return engineMessage('targetSpellImmune')\n\tswitch (target.relation) {\n\t\tcase 'self':\n\t\t\treturn (rules.self ?? rules.allies ?? false) ? undefined : engineMessage('cannotTargetSelf')\n\t\tcase 'ally':\n\t\t\treturn rules.allies ? undefined : engineMessage('cannotTargetFriends')\n\t\t// neutral things are fair game for whatever can hit enemies\n\t\tcase 'enemy':\n\t\tcase 'neutral':\n\t\t\treturn rules.enemies && !target.invulnerable ? undefined : engineMessage('cannotTargetThat')\n\t}\n}\n\n/**\n * How far away the target of an ability may be: what it says, and for some as far as the caster's attacks reach on top\n *\n * @beta\n */\nexport const abilityReach = (ability: AbilityDef, level: number, attackRange: number): number =>\n\tat(ability.range, level) + (ability.attackRange ? attackRange : 0)\n\n// ---- abilities\n\n/**\n * What there is to know about an ability and its user, for whether it can be used right now\n *\n * @beta\n */\nexport interface ReadyFacts {\n\t/** 0 for one not learned yet */\n\tlevel: number\n\t/** Seconds until it can be used again */\n\tcooldown: number\n\t/** Uses left, of an ability with charges (`chargesLeft`): none, and it is not ready */\n\tcharges?: number\n\t/** The caster's mana now, to meet the ability's mana cost */\n\tmana: number\n\t/** The caster's health now, for abilities that cost health */\n\thealth: number\n\t/** The caster's largest health, which a health cost may not take below */\n\tmaxHealth: number\n\t/** It comes from something carried: items ask for no mana, and silence does not stop them */\n\titem?: boolean\n\t/** One of the spells the hero brought along rather than learned: silence does not stop those either */\n\tspell?: boolean\n\t/** Whether the caster is silenced, which stops its spells but not items or brought-along spells */\n\tsilenced?: boolean\n\t/** A buff keeps it from rushing or jumping of its own (`BuffDef.grounded`), and the ability would (a `dash`, a `blink`) */\n\tgrounded?: boolean\n\t/** The debug switch that makes abilities cost nothing */\n\tnoManaCosts?: boolean\n\t/**\n\t * Health it pays for each point of mana an ability costs, in place of the mana (`BuffDef.paysWithHealth`): none, or\n\t * left out, for one that pays with mana\n\t */\n\thealthPerMana?: number\n\t/** What the simulation's `canCast` hook decided instead, when it told the screen: a reason, or null for none */\n\tdecided?: Message | null\n}\n\n/**\n * How many uses an ability with charges has left (`AbilityDef.charges`), at its level: what its state says, or all it\n * holds when that says nothing. Undefined for an ability without charges\n *\n * @beta\n */\nexport function chargesLeft(ability: AbilityDef, state: { level: number; charges?: number }): number | undefined {\n\tif (!ability.charges) return undefined\n\treturn state.charges ?? Math.max(Math.round(at(ability.charges.count, Math.max(state.level, 1))), 1)\n}\n\n/**\n * Why an ability cannot be used right now, or undefined when it can\n *\n * @beta\n */\nexport function abilityRefusal(ability: AbilityDef, facts: ReadyFacts): Message | undefined {\n\tif (facts.decided !== undefined) return facts.decided ?? undefined\n\tif (facts.level < 1) return engineMessage('cannotDoThat')\n\tif (facts.cooldown > 0 || facts.charges === 0) return engineMessage('notReady')\n\tif (facts.grounded) return engineMessage('grounded')\n\tif (facts.item) return undefined\n\tconst mana = facts.noManaCosts ? 0 : at(ability.manaCost, facts.level)\n\t// one that pays with health (`BuffDef.paysWithHealth`) pays the mana in health too, and needs more than it all left\n\tconst inHealth = facts.healthPerMana ? mana * facts.healthPerMana : 0\n\tif (!inHealth && mana > facts.mana) return engineMessage('notEnoughMana')\n\tconst health = inHealth + (ability.healthCost === undefined ? 0 : at(ability.healthCost, facts.level) * facts.maxHealth)\n\tif ((ability.healthCost !== undefined || inHealth > 0) && facts.health <= health) return engineMessage('notEnoughHealth')\n\tif (!facts.spell && facts.silenced) return engineMessage('silenced')\n\treturn undefined\n}\n\n// ---- making things\n\n/**\n * What there is to know about a player, for whether they can make something\n *\n * @beta\n */\nexport interface PlayerFacts {\n\t/** What the player has of each resource, to meet a cost */\n\tresources: Readonly<Purse>\n\t/** Supply the player's units and queued units take up now */\n\tsupplyUsed: number\n\t/** The most supply the player may use */\n\tsupplyCap: number\n\t/** The game's other pools of supply, by name (`RuleSettings.supply.pools`): left out in a game with none */\n\tsupplies?: Readonly<Record<string, { used: number; cap: number }>>\n\t/** Unit types they have, finished, which is what requirements ask for */\n\ttech: ReadonlySet<string> | readonly string[]\n\t/** Types of the heroes they have, fallen ones and ones being made included */\n\theroes: readonly string[]\n\t/**\n\t * What the simulation's `requirement` hook decided, where it differs from what the requirements say: by unit or\n\t * structure type, and `upgrade:<id>` for the next level of research. A reason, or null for \"may, for all that\"\n\t */\n\tunlocks?: Record<string, Message | null>\n\t/** The race they play (`raceOf`): left out in a game without races */\n\trace?: string\n\t/**\n\t * What the simulation's `available` hook decided, where it differs from what their race says (`availableTo`): by\n\t * unit or structure type, and `upgrade:<id>`\n\t */\n\tavailability?: Record<string, boolean>\n}\n\n/**\n * Whether a worker gathers a kind of resource at all (`harvester.ids`): the game's `canHarvest` hook may refuse it a\n * resource all the same (`canHarvest`)\n *\n * @beta\n */\nexport const gathers = (def: Pick<UnitTypeDef, 'harvester'>, kind: string): boolean =>\n\t!!def.harvester && (!def.harvester.ids || def.harvester.ids.includes(kind))\n\n/**\n * Whether something of a race (`UnitTypeDef.race`, `UpgradeDef.race`) is a player's to make as their race goes: what is\n * of no race is everyone's, and a player of none (the neutral players, the creeps, any in a game without races) may\n * make anything. The `available` hook has the last word (`isAvailable`)\n *\n * @beta\n */\nexport const availableTo = (def: { readonly race?: string }, race: string | undefined): boolean =>\n\tdef.race === undefined || race === undefined || def.race === race\n\n/**\n * Whether a player may make something at all, as the simulation decided (`availability`, by `key`) or else as their\n * race goes: what is not is left off their buttons\n *\n * @beta\n */\nexport function availableToPlayer(def: { readonly race?: string }, player: Pick<PlayerFacts, 'race' | 'availability'>, key: string): boolean {\n\treturn player.availability?.[key] ?? availableTo(def, player.race)\n}\n\n/**\n * Why something may not be made as far as what it requires goes: as the simulation decided (`unlocks`), or by the finished buildings it requires\n *\n * @beta\n */\nexport function requirementRefusal(\n\trequires: readonly string[] | undefined,\n\tplayer: Pick<PlayerFacts, 'tech' | 'unlocks'>,\n\tkey: string\n): Message | undefined {\n\tconst decided = player.unlocks?.[key]\n\tif (decided !== undefined) return decided ?? undefined\n\tconst lacking = missingTech(requires, player.tech)\n\treturn lacking.length ? engineMessage('requires', { units: lacking }) : undefined\n}\n\n/**\n * The requirements a player does not meet, by unit type\n *\n * @internal\n */\nexport function missingTech(requires: readonly string[] | undefined, tech: PlayerFacts['tech']): string[] {\n\t// asked about every button of a card, ten times a second, and nearly always nothing is missing: nothing is made then\n\tif (!requires?.length) return NOTHING_MISSING\n\tlet lacking: string[] | undefined\n\tfor (const id of requires) if (!('has' in tech ? tech.has(id) : tech.includes(id))) (lacking ??= []).push(id)\n\treturn lacking ?? NOTHING_MISSING\n}\n\n/** What `missingTech` gives when nothing is missing: the same one every time, and frozen, so nobody adds to it */\nconst NOTHING_MISSING = Object.freeze([]) as unknown as string[]\n\n/**\n * What stands in the way of a cost, or undefined when the player can pay it\n *\n * @beta\n */\nexport function costRefusal(resources: Readonly<Purse>, cost: Cost | undefined): Message | undefined {\n\tconst short = shortOf(resources, cost)\n\treturn short ? engineMessage('notEnough', { resource: short }) : undefined\n}\n\n/**\n * Why a player cannot have a unit made, or undefined when they can, as far as they and the unit type go: whether\n * the building has room, and what a game's hooks say (they can change the cost), is for the simulation. In the order the\n * player is told\n *\n * @beta\n */\nexport function trainRefusal(\n\tregistry: Registry,\n\tdef: UnitTypeDef,\n\tplayer: PlayerFacts,\n\toptions?: { cost?: boolean; tech?: boolean }\n): Message | undefined {\n\tconst locked = options?.tech === false ? undefined : requirementRefusal(def.requires, player, def.id)\n\tif (locked) return locked\n\tconst { settings: rules } = registry\n\tif (def.hero) {\n\t\tif (player.heroes.includes(def.id)) return engineMessage('alreadyHaveHero')\n\t\tif (player.heroes.length >= registry.settings.heroes.maxHeroes) return engineMessage('tooManyHeroes')\n\t}\n\tconst supply = supplyOf(def)\n\tif (supply > 0 && player.supplyUsed + supply > player.supplyCap) {\n\t\treturn engineMessage(player.supplyCap >= rules.supply.max ? 'supplyLimit' : 'supplyBlocked')\n\t}\n\t// and of each of the game's other pools it takes of\n\tconst pools = supplyPoolsOf(def)\n\tfor (const name in pools) {\n\t\tconst taken = pools[name]\n\t\tconst pool = player.supplies?.[name]\n\t\tconst most = rules.supply.pools?.[name]?.max\n\t\tif (taken > 0 && pool && pool.used + taken > pool.cap)\n\t\t\treturn engineMessage(most !== undefined && pool.cap >= most ? 'supplyLimit' : 'supplyBlocked', { pool: name })\n\t}\n\t// the simulation checks the cost itself, once the game's hooks have had their say about it\n\treturn options?.cost === false ? undefined : costRefusal(player.resources, def.cost)\n}\n\n// ---- items and attacks\n\n/**\n * What a shop pays for an item: a part of its price (the item's `sellRate`, or the game's `sellPrice`), and of what is\n * left of it for what runs out (a stack counts each of it)\n *\n * @beta\n */\nexport function sellValue(registry: Registry, item: string, charges: number): number {\n\tconst def = registry.item(item)\n\tconst part = def.charges ? charges / def.charges : 1\n\treturn Math.round(currencyOf(registry, def.cost) * (def.sellRate ?? registry.settings.economy.sellPrice) * part)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAsDA,SAAgB,cAAc,SAAqB,QAA0C;CAC5F,MAAM,QAAQ,QAAQ,WAAW,CAAC;CAClC,IAAI,OAAO,gBAAgB,CAAC,OAAO,aAAa,SAAS,QAAQ,EAAE,GAAG,OAAO,cAAc,kBAAkB;CAC7G,IAAI,OAAO,gBAAgB,OAAO,aAAa,QAAQ,OAAO,cAAc,kBAAkB;CAC9F,IAAI,EAAE,MAAM,SAAS,CAAC,MAAM,EAAA,CAAG,SAAS,OAAO,IAA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AA,IAAY,YAAY,OAAO,WAAW,IAAI,IAAI;AACpF;;;;;;;AAUA,SAAgB,UAAU,UAAoB,MAAc,SAAyB;CACpF,MAAM,MAAM,SAAS,KAAK,IAAI;CAC9B,MAAM,OAAO,IAAI,UAAU,UAAU,IAAI,UAAU;CACnD,OAAO,KAAK,MAAM,WAAW,UAAU,IAAI,IAAI,KAAK,IAAI,YAAY,SAAS,SAAS,QAAQ,aAAa,IAAI;AAChH"}
|
package/dist/sides.d.ts
CHANGED
|
@@ -27,7 +27,13 @@ export declare class Sides {
|
|
|
27
27
|
constructor(world: World);
|
|
28
28
|
/** Whether everyone on a team is out */
|
|
29
29
|
teamDefeated(team: number): boolean;
|
|
30
|
-
/**
|
|
30
|
+
/**
|
|
31
|
+
* Whether two players fight each other: their teams, or what they were set to be (`setRelation`). What every attack,
|
|
32
|
+
* cleave, area, zone, aura and missile of a player's asks of whom it may hurt. The creeps' player (`PlayerInit.creeps`,
|
|
33
|
+
* a team of its own) is everyone's enemy, so a camp is struck by all of it; the neutral player (a shop, a critter, a
|
|
34
|
+
* mine) is no one's, and is left alone. A player set apart from the creeps (`setRelation(player, creeps, 'neutral')`)
|
|
35
|
+
* reaches them with none of it
|
|
36
|
+
*/
|
|
31
37
|
enemies(a: PlayerId, b: PlayerId): boolean;
|
|
32
38
|
/**
|
|
33
39
|
* What two players are to each other from now on, whatever their teams: `ally`, `enemy`, or `neutral` (neither).
|
|
@@ -52,7 +58,7 @@ export declare class Sides {
|
|
|
52
58
|
/**
|
|
53
59
|
* Lets a player command another's units, from now on, or no longer: shared control, as allies in a melee game give
|
|
54
60
|
* each other (a map's force with `sharedControl` gives it to every player of the force). Kept in the world. Who may
|
|
55
|
-
* command what is `mayCommand`, which the rules may widen or narrow (`
|
|
61
|
+
* command what is `mayCommand`, which the rules may widen or narrow (`RuleSettings.mayCommand`)
|
|
56
62
|
*/
|
|
57
63
|
shareControl(owner: PlayerId, withPlayer: PlayerId, shared?: boolean): void;
|
|
58
64
|
/** The players who may command this one's units, besides the owner (`shareControl`) */
|
|
@@ -67,7 +73,7 @@ export declare class Sides {
|
|
|
67
73
|
}): void;
|
|
68
74
|
/**
|
|
69
75
|
* Whether a player may command an entity: its owner, whoever the owner shares control with, and whatever else the
|
|
70
|
-
* rules say (`
|
|
76
|
+
* rules say (`RuleSettings.mayCommand`). What every command of the player's is checked against
|
|
71
77
|
*/
|
|
72
78
|
mayCommand(player: PlayerId, entity: Entity): boolean;
|
|
73
79
|
/** Whether two players are on one side: one player, a team, or what they were set to be (`setRelation`) */
|
package/dist/sides.js
ADDED
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import { defineComponent } from "./components.js";
|
|
2
|
+
import { teamChanged } from "./engineEvents.js";
|
|
3
|
+
//#region src/sides.ts
|
|
4
|
+
/**
|
|
5
|
+
* Who is on whose side in a world (`world.sides`): teams, what two players were set to be to each other, which teams see
|
|
6
|
+
* what others see, who may command whose units. What every target, every command and every player's fog asks
|
|
7
|
+
*/
|
|
8
|
+
/** Pairs of players set apart from their teams, by `a * RELATION_KEY + b` with a < b */
|
|
9
|
+
var RELATION_KEY = 65536;
|
|
10
|
+
var relations = defineComponent({
|
|
11
|
+
id: "core.relations",
|
|
12
|
+
default: () => ({ pairs: {} })
|
|
13
|
+
});
|
|
14
|
+
/** Teams that see what others see: by the team that sees, those it shares with */
|
|
15
|
+
var vision = defineComponent({
|
|
16
|
+
id: "core.vision",
|
|
17
|
+
default: () => ({ teams: {} })
|
|
18
|
+
});
|
|
19
|
+
/** Who may command whose units besides their owner (`shareControl`): by the owner, the players given control. Kept in the world */
|
|
20
|
+
var control = defineComponent({
|
|
21
|
+
id: "core.control",
|
|
22
|
+
default: () => ({ players: {} })
|
|
23
|
+
});
|
|
24
|
+
var NONE = [];
|
|
25
|
+
/**
|
|
26
|
+
* Who is on whose side: kept in the world's state, so a save has it
|
|
27
|
+
*
|
|
28
|
+
* @beta
|
|
29
|
+
*/
|
|
30
|
+
var Sides = class {
|
|
31
|
+
world;
|
|
32
|
+
constructor(world) {
|
|
33
|
+
this.world = world;
|
|
34
|
+
}
|
|
35
|
+
/** Whether everyone on a team is out */
|
|
36
|
+
teamDefeated(team) {
|
|
37
|
+
for (const player of this.world.players.values()) if (player.team === team && !player.neutral && !player.defeated) return false;
|
|
38
|
+
return true;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Whether two players fight each other: their teams, or what they were set to be (`setRelation`). What every attack,
|
|
42
|
+
* cleave, area, zone, aura and missile of a player's asks of whom it may hurt. The creeps' player (`PlayerInit.creeps`,
|
|
43
|
+
* a team of its own) is everyone's enemy, so a camp is struck by all of it; the neutral player (a shop, a critter, a
|
|
44
|
+
* mine) is no one's, and is left alone. A player set apart from the creeps (`setRelation(player, creeps, 'neutral')`)
|
|
45
|
+
* reaches them with none of it
|
|
46
|
+
*/
|
|
47
|
+
enemies(a, b) {
|
|
48
|
+
if (a === b) return false;
|
|
49
|
+
const set = this.relationOf(a, b);
|
|
50
|
+
if (set) return set === "enemy";
|
|
51
|
+
const pa = this.world.player(a);
|
|
52
|
+
const pb = this.world.player(b);
|
|
53
|
+
return !pa.neutral && !pb.neutral && pa.team !== pb.team;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* What two players are to each other from now on, whatever their teams: `ally`, `enemy`, or `neutral` (neither).
|
|
57
|
+
* Null goes back to what their teams say. Creeps that turn friendly to one player; a ceasefire. Kept in the world:
|
|
58
|
+
* a save has it. Sight stays the teams' (see `shareVision`)
|
|
59
|
+
*/
|
|
60
|
+
setRelation(a, b, relation) {
|
|
61
|
+
if (a === b) return;
|
|
62
|
+
const key = a < b ? a * RELATION_KEY + b : b * RELATION_KEY + a;
|
|
63
|
+
const { pairs } = this.world.state(relations);
|
|
64
|
+
if (relation) pairs[key] = relation;
|
|
65
|
+
else delete pairs[key];
|
|
66
|
+
}
|
|
67
|
+
/** What two players were set to be to each other (`setRelation`), if anything */
|
|
68
|
+
relationOf(a, b) {
|
|
69
|
+
const set = this.world.states.values[relations.id];
|
|
70
|
+
if (!set) return void 0;
|
|
71
|
+
return set.pairs[a < b ? a * RELATION_KEY + b : b * RELATION_KEY + a];
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Moves a player to another team, one there is or a new one: whom they fight and see with follows. What their units
|
|
75
|
+
* were doing goes on; what they fought that is now a friend, they stop fighting on their own
|
|
76
|
+
*/
|
|
77
|
+
setTeam(player, team) {
|
|
78
|
+
const moved = this.world.player(player);
|
|
79
|
+
if (moved.team === team) return;
|
|
80
|
+
const from = moved.team;
|
|
81
|
+
this.world.fog.addTeam(team);
|
|
82
|
+
moved.team = team;
|
|
83
|
+
this.world.events.emit(teamChanged, {
|
|
84
|
+
player,
|
|
85
|
+
from,
|
|
86
|
+
to: team
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Lets one team see what another sees, from now on, or no longer: shared vision without an alliance. Kept in the
|
|
91
|
+
* world. A team sees what its own units see as ever
|
|
92
|
+
*/
|
|
93
|
+
shareVision(from, to, shared = true) {
|
|
94
|
+
const { teams } = this.world.state(vision);
|
|
95
|
+
const list = teams[from] ??= [];
|
|
96
|
+
const index = list.indexOf(to);
|
|
97
|
+
if (shared && index < 0 && from !== to) list.push(to);
|
|
98
|
+
if (!shared && index >= 0) list.splice(index, 1);
|
|
99
|
+
this.world.fog.addTeam(to);
|
|
100
|
+
}
|
|
101
|
+
/** The teams that see what this one sees, besides itself */
|
|
102
|
+
visionOf(team) {
|
|
103
|
+
return this.world.states.values[vision.id]?.teams[team] ?? NONE;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Lets a player command another's units, from now on, or no longer: shared control, as allies in a melee game give
|
|
107
|
+
* each other (a map's force with `sharedControl` gives it to every player of the force). Kept in the world. Who may
|
|
108
|
+
* command what is `mayCommand`, which the rules may widen or narrow (`RuleSettings.mayCommand`)
|
|
109
|
+
*/
|
|
110
|
+
shareControl(owner, withPlayer, shared = true) {
|
|
111
|
+
const { players } = this.world.state(control);
|
|
112
|
+
const list = players[owner] ??= [];
|
|
113
|
+
const index = list.indexOf(withPlayer);
|
|
114
|
+
if (shared && index < 0 && owner !== withPlayer) list.push(withPlayer);
|
|
115
|
+
if (!shared && index >= 0) list.splice(index, 1);
|
|
116
|
+
}
|
|
117
|
+
/** The players who may command this one's units, besides the owner (`shareControl`) */
|
|
118
|
+
controlOf(owner) {
|
|
119
|
+
return this.world.states.values[control.id]?.players[owner] ?? NONE;
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Shares what a player has with another, from now on, or no longer: their units' control (`shareControl`) and
|
|
123
|
+
* what their team sees (`shareVision`, team to team)
|
|
124
|
+
*/
|
|
125
|
+
share(player, withPlayer, what) {
|
|
126
|
+
if (what.control !== void 0) this.shareControl(player, withPlayer, what.control);
|
|
127
|
+
if (what.vision !== void 0) this.shareVision(this.world.player(player).team, this.world.player(withPlayer).team, what.vision);
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Whether a player may command an entity: its owner, whoever the owner shares control with, and whatever else the
|
|
131
|
+
* rules say (`RuleSettings.mayCommand`). What every command of the player's is checked against
|
|
132
|
+
*/
|
|
133
|
+
mayCommand(player, entity) {
|
|
134
|
+
return this.world.settings.mayCommand(this.world, player, entity);
|
|
135
|
+
}
|
|
136
|
+
/** Whether two players are on one side: one player, a team, or what they were set to be (`setRelation`) */
|
|
137
|
+
allies(a, b) {
|
|
138
|
+
if (a === b) return true;
|
|
139
|
+
const set = this.relationOf(a, b);
|
|
140
|
+
if (set) return set === "ally";
|
|
141
|
+
const pa = this.world.player(a);
|
|
142
|
+
const pb = this.world.player(b);
|
|
143
|
+
return !pa.neutral && !pb.neutral && pa.team === pb.team;
|
|
144
|
+
}
|
|
145
|
+
};
|
|
146
|
+
//#endregion
|
|
147
|
+
export { Sides, control, relations, vision };
|
|
148
|
+
|
|
149
|
+
//# sourceMappingURL=sides.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sides.js","names":[],"sources":["../src/sides.ts"],"sourcesContent":["/**\n * Who is on whose side in a world (`world.sides`): teams, what two players were set to be to each other, which teams see\n * what others see, who may command whose units. What every target, every command and every player's fog asks\n */\nimport { teamChanged } from '#engine/engineEvents'\nimport { defineComponent } from './components'\nimport type { Entity, PlayerId } from './entity'\nimport type { PlayerRelation, World } from './world'\n\n/** Pairs of players set apart from their teams, by `a * RELATION_KEY + b` with a < b */\nconst RELATION_KEY = 65536\nexport const relations = defineComponent<{ pairs: Record<number, PlayerRelation> }>({ id: 'core.relations', default: () => ({ pairs: {} }) })\n/** Teams that see what others see: by the team that sees, those it shares with */\nexport const vision = defineComponent<{ teams: Record<number, number[]> }>({ id: 'core.vision', default: () => ({ teams: {} }) })\n/** Who may command whose units besides their owner (`shareControl`): by the owner, the players given control. Kept in the world */\nexport const control = defineComponent<{ players: Record<number, number[]> }>({ id: 'core.control', default: () => ({ players: {} }) })\nconst NONE: readonly number[] = []\n\n/**\n * Who is on whose side: kept in the world's state, so a save has it\n *\n * @beta\n */\nexport class Sides {\n\tconstructor(private readonly world: World) {}\n\n\t/** Whether everyone on a team is out */\n\tteamDefeated(team: number): boolean {\n\t\tfor (const player of this.world.players.values()) if (player.team === team && !player.neutral && !player.defeated) return false\n\t\treturn true\n\t}\n\n\t/**\n\t * Whether two players fight each other: their teams, or what they were set to be (`setRelation`). What every attack,\n\t * cleave, area, zone, aura and missile of a player's asks of whom it may hurt. The creeps' player (`PlayerInit.creeps`,\n\t * a team of its own) is everyone's enemy, so a camp is struck by all of it; the neutral player (a shop, a critter, a\n\t * mine) is no one's, and is left alone. A player set apart from the creeps (`setRelation(player, creeps, 'neutral')`)\n\t * reaches them with none of it\n\t */\n\tenemies(a: PlayerId, b: PlayerId): boolean {\n\t\tif (a === b) return false\n\t\tconst set = this.relationOf(a, b)\n\t\tif (set) return set === 'enemy'\n\t\tconst pa = this.world.player(a)\n\t\tconst pb = this.world.player(b)\n\t\treturn !pa.neutral && !pb.neutral && pa.team !== pb.team\n\t}\n\n\t/**\n\t * What two players are to each other from now on, whatever their teams: `ally`, `enemy`, or `neutral` (neither).\n\t * Null goes back to what their teams say. Creeps that turn friendly to one player; a ceasefire. Kept in the world:\n\t * a save has it. Sight stays the teams' (see `shareVision`)\n\t */\n\tsetRelation(a: PlayerId, b: PlayerId, relation: PlayerRelation | null): void {\n\t\tif (a === b) return\n\t\tconst key = a < b ? a * RELATION_KEY + b : b * RELATION_KEY + a\n\t\tconst { pairs } = this.world.state(relations)\n\t\tif (relation) pairs[key] = relation\n\t\telse delete pairs[key]\n\t}\n\n\t/** What two players were set to be to each other (`setRelation`), if anything */\n\trelationOf(a: PlayerId, b: PlayerId): PlayerRelation | undefined {\n\t\t// read without making the state: a game that sets none pays nothing for it\n\t\tconst set = this.world.states.values[relations.id] as { pairs: Record<number, PlayerRelation> } | undefined\n\t\tif (!set) return undefined\n\t\treturn set.pairs[a < b ? a * RELATION_KEY + b : b * RELATION_KEY + a]\n\t}\n\n\t/**\n\t * Moves a player to another team, one there is or a new one: whom they fight and see with follows. What their units\n\t * were doing goes on; what they fought that is now a friend, they stop fighting on their own\n\t */\n\tsetTeam(player: PlayerId, team: number): void {\n\t\tconst moved = this.world.player(player)\n\t\tif (moved.team === team) return\n\t\tconst from = moved.team\n\t\tthis.world.fog.addTeam(team)\n\t\tmoved.team = team\n\t\tthis.world.events.emit(teamChanged, { player, from, to: team })\n\t}\n\n\t/**\n\t * Lets one team see what another sees, from now on, or no longer: shared vision without an alliance. Kept in the\n\t * world. A team sees what its own units see as ever\n\t */\n\tshareVision(from: number, to: number, shared = true): void {\n\t\tconst { teams } = this.world.state(vision)\n\t\tconst list = (teams[from] ??= [])\n\t\tconst index = list.indexOf(to)\n\t\tif (shared && index < 0 && from !== to) list.push(to)\n\t\tif (!shared && index >= 0) list.splice(index, 1)\n\t\tthis.world.fog.addTeam(to)\n\t}\n\n\t/** The teams that see what this one sees, besides itself */\n\tvisionOf(team: number): readonly number[] {\n\t\tconst set = this.world.states.values[vision.id] as { teams: Record<number, number[]> } | undefined\n\t\treturn set?.teams[team] ?? NONE\n\t}\n\n\t/**\n\t * Lets a player command another's units, from now on, or no longer: shared control, as allies in a melee game give\n\t * each other (a map's force with `sharedControl` gives it to every player of the force). Kept in the world. Who may\n\t * command what is `mayCommand`, which the rules may widen or narrow (`RuleSettings.mayCommand`)\n\t */\n\tshareControl(owner: PlayerId, withPlayer: PlayerId, shared = true): void {\n\t\tconst { players } = this.world.state(control)\n\t\tconst list = (players[owner] ??= [])\n\t\tconst index = list.indexOf(withPlayer)\n\t\tif (shared && index < 0 && owner !== withPlayer) list.push(withPlayer)\n\t\tif (!shared && index >= 0) list.splice(index, 1)\n\t}\n\n\t/** The players who may command this one's units, besides the owner (`shareControl`) */\n\tcontrolOf(owner: PlayerId): readonly PlayerId[] {\n\t\tconst set = this.world.states.values[control.id] as { players: Record<number, number[]> } | undefined\n\t\treturn set?.players[owner] ?? NONE\n\t}\n\n\t/**\n\t * Shares what a player has with another, from now on, or no longer: their units' control (`shareControl`) and\n\t * what their team sees (`shareVision`, team to team)\n\t */\n\tshare(player: PlayerId, withPlayer: PlayerId, what: { control?: boolean; vision?: boolean }): void {\n\t\tif (what.control !== undefined) this.shareControl(player, withPlayer, what.control)\n\t\tif (what.vision !== undefined) this.shareVision(this.world.player(player).team, this.world.player(withPlayer).team, what.vision)\n\t}\n\n\t/**\n\t * Whether a player may command an entity: its owner, whoever the owner shares control with, and whatever else the\n\t * rules say (`RuleSettings.mayCommand`). What every command of the player's is checked against\n\t */\n\tmayCommand(player: PlayerId, entity: Entity): boolean {\n\t\treturn this.world.settings.mayCommand(this.world, player, entity)\n\t}\n\n\t/** Whether two players are on one side: one player, a team, or what they were set to be (`setRelation`) */\n\tallies(a: PlayerId, b: PlayerId): boolean {\n\t\tif (a === b) return true\n\t\tconst set = this.relationOf(a, b)\n\t\tif (set) return set === 'ally'\n\t\tconst pa = this.world.player(a)\n\t\tconst pb = this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YAAsB,MAAqD;EAClG,IAAI,KAAK,YAAY,KAAA,GAAW,KAAK,aAAa,QAAQ,YAAY,KAAK,OAAO;EAClF,IAAI,KAAK,WAAW,KAAA,GAAW,KAAK,YAAY,KAAK,MAAM,OAAO,MAAM,CAAC,CAAC,MAAM,KAAK,MAAM,OAAO,UAAU,CAAC,CAAC,MAAM,KAAK,MAAM;CAChI;;;;;CAMA,WAAW,QAAkB,QAAyB;EACrD,OAAO,KAAK,MAAM,SAAS,WAAW,KAAK,OAAO,QAAQ,MAAM;CACjE;;CAGA,OAAO,GAAa,GAAsB;EACzC,IAAI,MAAM,GAAG,OAAO;EACpB,MAAM,MAAM,KAAK,WAAW,GAAG,CAAC;EAChC,IAAI,KAAK,OAAO,QAAQ;EACxB,MAAM,KAAK,KAAK,MAAM,OAAO,CAAC;EAC9B,MAAM,KAAK,KAAK,MAAM,OAAO,CAAC;EAC9B,OAAO,CAAC,GAAG,WAAW,CAAC,GAAG,WAAW,GAAG,SAAS,GAAG;CACrD;AACD"}
|
package/dist/sight.js
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { detection } from "./entity.js";
|
|
2
|
+
import { BuffFlag, buffFlags } from "./abilities/buffs.js";
|
|
3
|
+
import "./fog.js";
|
|
4
|
+
//#region src/sight.ts
|
|
5
|
+
/**
|
|
6
|
+
* What each team of a world sees of its entities (`world.sight`): by the fog, what is invisible and who detects it, and
|
|
7
|
+
* what the game makes of it (the `visible` hook: units in a bush)
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* What each team sees of a world's entities
|
|
11
|
+
*
|
|
12
|
+
* @beta
|
|
13
|
+
*/
|
|
14
|
+
var Sight = class {
|
|
15
|
+
world;
|
|
16
|
+
/**
|
|
17
|
+
* What is handed to the `visible` handlers, again and again, so that asking allocates nothing: the world's own, a
|
|
18
|
+
* handler that asks again getting an object of its own
|
|
19
|
+
*/
|
|
20
|
+
asking = {
|
|
21
|
+
entity: void 0,
|
|
22
|
+
team: 0,
|
|
23
|
+
visible: false
|
|
24
|
+
};
|
|
25
|
+
constructor(world) {
|
|
26
|
+
this.world = world;
|
|
27
|
+
}
|
|
28
|
+
/** Whether a team currently sees the entity */
|
|
29
|
+
sees(entity, team) {
|
|
30
|
+
if (entity.hidden) return false;
|
|
31
|
+
const owner = this.world.player(entity.owner);
|
|
32
|
+
if (!owner.neutral && owner.team === team) return true;
|
|
33
|
+
const seen = this.inSight(entity, team);
|
|
34
|
+
if (!this.world.hooks.has("visible")) return seen;
|
|
35
|
+
const shared = this.asking.entity === void 0;
|
|
36
|
+
const asking = shared ? this.asking : {
|
|
37
|
+
entity,
|
|
38
|
+
team,
|
|
39
|
+
visible: seen
|
|
40
|
+
};
|
|
41
|
+
asking.entity = entity;
|
|
42
|
+
asking.team = team;
|
|
43
|
+
asking.visible = seen;
|
|
44
|
+
const visible = this.world.hooks.run("visible", asking).visible;
|
|
45
|
+
if (shared) this.asking.entity = void 0;
|
|
46
|
+
return visible;
|
|
47
|
+
}
|
|
48
|
+
/** Whether an entity is invisible right now: by its type (`invisible`), or a buff that says so */
|
|
49
|
+
isInvisible(entity) {
|
|
50
|
+
if (entity.unseen) return true;
|
|
51
|
+
if (!entity.buffs.length || !(buffFlags(this.world, entity) & BuffFlag.invisible)) return false;
|
|
52
|
+
for (const instance of entity.buffs) {
|
|
53
|
+
const flag = this.world.registry.buff(instance.id).invisible;
|
|
54
|
+
if (typeof flag === "function" ? flag(this.world, entity, instance) : flag) return true;
|
|
55
|
+
}
|
|
56
|
+
return false;
|
|
57
|
+
}
|
|
58
|
+
/** Whether a team sees an entity of someone else's, by the fog and what is invisible */
|
|
59
|
+
inSight(entity, team) {
|
|
60
|
+
if (this.isInvisible(entity) && !entity.get(detection)?.has(team)) return false;
|
|
61
|
+
const { fog } = this.world;
|
|
62
|
+
const { x, z } = entity.pos;
|
|
63
|
+
if (entity.def.footprint) {
|
|
64
|
+
const hw = entity.halfWidth;
|
|
65
|
+
const hd = entity.halfDepth;
|
|
66
|
+
const left = Math.floor(x - hw + .5);
|
|
67
|
+
const right = Math.floor(x + hw - .5);
|
|
68
|
+
const front = Math.floor(z - hd + .5);
|
|
69
|
+
const back = Math.floor(z + hd - .5);
|
|
70
|
+
return fog.stateAt(team, Math.floor(x), Math.floor(z)) === 2 || fog.stateAt(team, left, front) === 2 || fog.stateAt(team, right, front) === 2 || fog.stateAt(team, left, back) === 2 || fog.stateAt(team, right, back) === 2;
|
|
71
|
+
}
|
|
72
|
+
return fog.stateAt(team, Math.floor(x), Math.floor(z)) === 2;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Whether a team has ever laid eyes on the entity. Kept up to date for structures only, see the fog system.
|
|
76
|
+
* A team that sees the whole map (out of the game, or a debug switch) has seen everything there is
|
|
77
|
+
*/
|
|
78
|
+
hasSeen(entity, team) {
|
|
79
|
+
return this.world.fog.isRevealed(team) || (entity.seenBy & this.world.fog.teamBit(team)) !== 0;
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
//#endregion
|
|
83
|
+
export { Sight };
|
|
84
|
+
|
|
85
|
+
//# sourceMappingURL=sight.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sight.js","names":[],"sources":["../src/sight.ts"],"sourcesContent":["/**\n * What each team of a world sees of its entities (`world.sight`): by the fog, what is invisible and who detects it, and\n * what the game makes of it (the `visible` hook: units in a bush)\n */\nimport { BuffFlag, buffFlags } from './abilities/buffs'\nimport { detection } from './entity'\nimport type { Entity } from './entity'\nimport { FOG_VISIBLE } from './fog'\nimport type { World } from './world'\n\n/**\n * What each team sees of a world's entities\n *\n * @beta\n */\nexport class Sight {\n\t/**\n\t * What is handed to the `visible` handlers, again and again, so that asking allocates nothing: the world's own, a\n\t * handler that asks again getting an object of its own\n\t */\n\tprivate readonly asking: { entity: Entity; team: number; visible: boolean } = { entity: undefined!, team: 0, visible: false }\n\n\tconstructor(private readonly world: World) {}\n\n\t/** Whether a team currently sees the entity */\n\tsees(entity: Entity, team: number): boolean {\n\t\tif (entity.hidden) return false\n\t\tconst owner = this.world.player(entity.owner)\n\t\tif (!owner.neutral && owner.team === team) return true\n\t\tconst seen = this.inSight(entity, team)\n\t\t// what the game makes of it: units in brush, a tower that sees everything near it. Asked for every entity, team\n\t\t// and snapshot: the one object handed out again and again, so that asking allocates nothing\n\t\tif (!this.world.hooks.has('visible')) return seen\n\t\t// a handler that asks again, as it decides (a game's `seenBy`): an object of its own then\n\t\tconst shared = this.asking.entity === undefined\n\t\tconst asking = shared ? this.asking : { entity, team, visible: seen }\n\t\tasking.entity = entity\n\t\tasking.team = team\n\t\tasking.visible = seen\n\t\tconst visible = this.world.hooks.run('visible', asking).visible\n\t\tif (shared) this.asking.entity = undefined!\n\t\treturn visible\n\t}\n\n\t/** Whether an entity is invisible right now: by its type (`invisible`), or a buff that says so */\n\tisInvisible(entity: Entity): boolean {\n\t\tif (entity.unseen) return true\n\t\tif (!entity.buffs.length || !(buffFlags(this.world, entity) & BuffFlag.invisible)) return false\n\t\tfor (const instance of entity.buffs) {\n\t\t\tconst flag = this.world.registry.buff(instance.id).invisible\n\t\t\tif (typeof flag === 'function' ? flag(this.world, entity, instance) : flag) return true\n\t\t}\n\t\treturn false\n\t}\n\n\t/** Whether a team sees an entity of someone else's, by the fog and what is invisible */\n\tprivate inSight(entity: Entity, team: number): boolean {\n\t\tif (this.isInvisible(entity) && !entity.get(detection)?.has(team)) return false\n\t\t// by whole cells, as the fog has them: a whole number is handed on as it is, where a fraction would be boxed for\n\t\t// each ask (every structure in every lit circle, every fog update)\n\t\tconst { fog } = this.world\n\t\tconst { x, z } = entity.pos\n\t\tif (entity.def.footprint) {\n\t\t\t// structures are visible as soon as any part of them is\n\t\t\tconst hw = entity.halfWidth\n\t\t\tconst hd = entity.halfDepth\n\t\t\tconst left = Math.floor(x - hw + 0.5)\n\t\t\tconst right = Math.floor(x + hw - 0.5)\n\t\t\tconst front = Math.floor(z - hd + 0.5)\n\t\t\tconst back = Math.floor(z + hd - 0.5)\n\t\t\treturn (\n\t\t\t\tfog.stateAt(team, Math.floor(x), Math.floor(z)) === FOG_VISIBLE ||\n\t\t\t\tfog.stateAt(team, left, front) === FOG_VISIBLE ||\n\t\t\t\tfog.stateAt(team, right, front) === FOG_VISIBLE ||\n\t\t\t\tfog.stateAt(team, left, back) === FOG_VISIBLE ||\n\t\t\t\tfog.stateAt(team, right, back) === FOG_VISIBLE\n\t\t\t)\n\t\t}\n\t\treturn fog.stateAt(team, Math.floor(x), Math.floor(z)) === FOG_VISIBLE\n\t}\n\n\t/**\n\t * Whether a team has ever laid eyes on the entity. Kept up to date for structures only, see the fog system.\n\t * A team that sees the whole map (out of the game, or a debug switch) has seen everything there is\n\t */\n\thasSeen(entity: Entity, team: number): boolean {\n\t\treturn this.world.fog.isRevealed(team) || (entity.seenBy & this.world.fog.teamBit(team)) !== 0\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;AAeA,IAAa,QAAb,MAAmB;CAOW;;;;;CAF7B,SAA8E;EAAE,QAAQ,KAAA;EAAY,MAAM;EAAG,SAAS;CAAM;CAE5H,YAAY,OAA+B;EAAd,KAAA,QAAA;CAAe;;CAG5C,KAAK,QAAgB,MAAuB;EAC3C,IAAI,OAAO,QAAQ,OAAO;EAC1B,MAAM,QAAQ,KAAK,MAAM,OAAO,OAAO,KAAK;EAC5C,IAAI,CAAC,MAAM,WAAW,MAAM,SAAS,MAAM,OAAO;EAClD,MAAM,OAAO,KAAK,QAAQ,QAAQ,IAAI;EAGtC,IAAI,CAAC,KAAK,MAAM,MAAM,IAAI,SAAS,GAAG,OAAO;EAE7C,MAAM,SAAS,KAAK,OAAO,WAAW,KAAA;EACtC,MAAM,SAAS,SAAS,KAAK,SAAS;GAAE;GAAQ;GAAM,SAAS;EAAK;EACpE,OAAO,SAAS;EAChB,OAAO,OAAO;EACd,OAAO,UAAU;EACjB,MAAM,UAAU,KAAK,MAAM,MAAM,IAAI,WAAW,MAAM,CAAC,CAAC;EACxD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;;;;CAMA,QAAQ,QAAgB,MAAuB;EAC9C,OAAO,KAAK,MAAM,IAAI,WAAW,IAAI,MAAM,OAAO,SAAS,KAAK,MAAM,IAAI,QAAQ,IAAI,OAAO;CAC9F;AACD"}
|
package/dist/simulate-worker.js
CHANGED
package/dist/simulate.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { AiOptions } from './ai/options';
|
|
2
2
|
import type { BrainDef } from './ai/brain';
|
|
3
3
|
import type { PlayerId } from './entity';
|
|
4
|
-
import { type
|
|
4
|
+
import { type Rules } from './game';
|
|
5
5
|
import { type GameMap } from './map';
|
|
6
6
|
import type { World } from './world';
|
|
7
7
|
/**
|
|
@@ -13,10 +13,12 @@ export type Counted = number | string | boolean | null;
|
|
|
13
13
|
/**
|
|
14
14
|
* A game to play many times (`simulate`): the rules, the map, who the computer plays and how, and what to count
|
|
15
15
|
*
|
|
16
|
-
* @
|
|
16
|
+
* @public
|
|
17
17
|
*/
|
|
18
18
|
export interface Simulation {
|
|
19
|
-
game
|
|
19
|
+
/** The game module's rules each simulated game is played with */
|
|
20
|
+
rules: Rules;
|
|
21
|
+
/** The map each simulated game is made from */
|
|
20
22
|
map: GameMap;
|
|
21
23
|
/**
|
|
22
24
|
* The players the computer plays: every player of the map with a start, the creeps apart, when left out. One left
|
|
@@ -24,7 +26,7 @@ export interface Simulation {
|
|
|
24
26
|
*/
|
|
25
27
|
computers?: PlayerId[];
|
|
26
28
|
/**
|
|
27
|
-
* The brain each player is played by, or its id (one the game lists in `
|
|
29
|
+
* The brain each player is played by, or its id (one the game lists in `Rules.brains`, or the engine's
|
|
28
30
|
* `core.melee`): two brains against each other, for a balance run. A player not named here is played by the first
|
|
29
31
|
* brain the game lists
|
|
30
32
|
*/
|
|
@@ -36,7 +38,7 @@ export interface Simulation {
|
|
|
36
38
|
/** How the computer plays a player, over what it is given (`enemyBases`: where the others start) */
|
|
37
39
|
ai?: (player: PlayerId, world: World) => Partial<AiOptions>;
|
|
38
40
|
/** What the game does once a world is made, before the first tick: units of its own, a rule turned on */
|
|
39
|
-
|
|
41
|
+
onStart?: (world: World) => void;
|
|
40
42
|
/** Seconds of the game at most: twenty minutes when left out */
|
|
41
43
|
seconds?: number;
|
|
42
44
|
/** Whether the game is over before that: once there is a winner, when left out */
|
|
@@ -76,11 +78,13 @@ export interface ComputerMeasures {
|
|
|
76
78
|
* @beta
|
|
77
79
|
*/
|
|
78
80
|
export interface SimulatedGame {
|
|
81
|
+
/** The seed the game was played with */
|
|
79
82
|
seed: number;
|
|
80
83
|
/** The winning team, or null for none in the time given */
|
|
81
84
|
winner: number | null;
|
|
82
85
|
/** Seconds of the game it lasted, and ticks */
|
|
83
86
|
seconds: number;
|
|
87
|
+
/** How many ticks the game lasted */
|
|
84
88
|
ticks: number;
|
|
85
89
|
/** Why it stopped on an error of its rules, where it did (`World.failure`) */
|
|
86
90
|
failed?: string;
|
|
@@ -94,7 +98,6 @@ export interface SimulatedGame {
|
|
|
94
98
|
/** A simulation, as a module that a worker imports gives it: as it is written, for its type *
|
|
95
99
|
* @beta
|
|
96
100
|
*/
|
|
97
|
-
export declare const defineSimulation: (simulation: Simulation) => Simulation;
|
|
98
101
|
/** Plays one game of a simulation from a seed, in this thread *
|
|
99
102
|
* @beta
|
|
100
103
|
*/
|
|
@@ -107,6 +110,7 @@ export declare function playGame(simulation: Simulation, seed: number): Promise<
|
|
|
107
110
|
export interface BrainResults {
|
|
108
111
|
/** Seats it played */
|
|
109
112
|
games: number;
|
|
113
|
+
/** Seats whose team won */
|
|
110
114
|
wins: number;
|
|
111
115
|
/** Seats whose team another team beat */
|
|
112
116
|
losses: number;
|
|
@@ -146,9 +150,9 @@ export interface SimulateOptions {
|
|
|
146
150
|
/**
|
|
147
151
|
* Plays games of a simulation, one from each seed, and gives what each ended in, in the order of the seeds. Given as
|
|
148
152
|
* it is, they are played in this thread. Given as the address of a file (a module whose `default`, or `simulation`, is
|
|
149
|
-
* one: `
|
|
153
|
+
* one: a `Simulation`), each worker thread imports it and plays its share: in Node, from the built packages (a
|
|
150
154
|
* worker loads JavaScript, not the TypeScript of this repository)
|
|
151
155
|
*
|
|
152
|
-
* @
|
|
156
|
+
* @public
|
|
153
157
|
*/
|
|
154
158
|
export declare function simulate(simulation: Simulation | string | URL, options: SimulateOptions): Promise<SimulatedGame[]>;
|