@v12-engine/engine 0.0.0-stage → 0.1.1
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/LICENSE +21 -0
- package/dist/abilities/buffs.d.ts +83 -0
- package/dist/abilities/castTold.d.ts +12 -0
- package/dist/abilities/charges.d.ts +28 -0
- package/dist/abilities/dispel.d.ts +9 -0
- package/dist/abilities/effectFields.d.ts +10 -0
- package/dist/abilities/effects/buff.d.ts +8 -0
- package/dist/abilities/effects/core.d.ts +1 -0
- package/dist/abilities/effects/damage.d.ts +1 -0
- package/dist/abilities/effects/heal.d.ts +2 -0
- package/dist/abilities/effects/missile.d.ts +1 -0
- package/dist/abilities/effects/moves.d.ts +11 -0
- package/dist/abilities/effects/passives.d.ts +15 -0
- package/dist/abilities/effects/sight.d.ts +4 -0
- package/dist/abilities/effects/spawn.d.ts +2 -0
- package/dist/abilities/effects/timed.d.ts +4 -0
- package/dist/abilities/effects/trade.d.ts +1 -0
- package/dist/abilities/effects.d.ts +122 -0
- package/dist/abilities/land.d.ts +21 -0
- package/dist/abilities/scaled.d.ts +21 -0
- package/dist/abilities/text.d.ts +113 -0
- package/dist/ai/area.d.ts +53 -0
- package/dist/ai/brain.d.ts +528 -0
- package/dist/ai/budget.d.ts +67 -0
- package/dist/ai/checks.d.ts +115 -0
- package/dist/ai/computer.d.ts +166 -0
- package/dist/ai/defence.d.ts +108 -0
- package/dist/ai/define.d.ts +21 -0
- package/dist/ai/economy.d.ts +129 -0
- package/dist/ai/geometry.d.ts +35 -0
- package/dist/ai/goals.d.ts +360 -0
- package/dist/ai/index.d.ts +38 -0
- package/dist/ai/knowledge.d.ts +418 -0
- package/dist/ai/lanes.d.ts +232 -0
- package/dist/ai/melee/build.d.ts +61 -0
- package/dist/ai/melee/goals.d.ts +299 -0
- package/dist/ai/melee/heroes.d.ts +27 -0
- package/dist/ai/melee/index.d.ts +14 -0
- package/dist/ai/melee/production.d.ts +8 -0
- package/dist/ai/melee/surrender.d.ts +24 -0
- package/dist/ai/micro.d.ts +278 -0
- package/dist/ai/mission.d.ts +195 -0
- package/dist/ai/missionRules.d.ts +18 -0
- package/dist/ai/module.d.ts +116 -0
- package/dist/ai/options.d.ts +61 -0
- package/dist/ai/plans/build.d.ts +280 -0
- package/dist/ai/plans/placement.d.ts +82 -0
- package/dist/ai/plans/plans.d.ts +105 -0
- package/dist/ai/plans/production.d.ts +210 -0
- package/dist/ai/plans/purse.d.ts +73 -0
- package/dist/ai/plans/tech.d.ts +37 -0
- package/dist/ai/profiles.d.ts +204 -0
- package/dist/ai/reach.d.ts +4 -0
- package/dist/ai/report.d.ts +203 -0
- package/dist/ai/roles.d.ts +133 -0
- package/dist/ai/rules.d.ts +288 -0
- package/dist/ai/scouting.d.ts +98 -0
- package/dist/ai/settings.d.ts +73 -0
- package/dist/ai/squads.d.ts +429 -0
- package/dist/ai/strength.d.ts +167 -0
- package/dist/ai/task.d.ts +118 -0
- package/dist/ai/tasks/attack.d.ts +7 -0
- package/dist/ai/tasks/capture.d.ts +21 -0
- package/dist/ai/tasks/creep.d.ts +16 -0
- package/dist/ai/tasks/defend.d.ts +29 -0
- package/dist/ai/tasks/drop.d.ts +34 -0
- package/dist/ai/tasks/escort.d.ts +16 -0
- package/dist/ai/tasks/gather.d.ts +23 -0
- package/dist/ai/tasks/harass.d.ts +7 -0
- package/dist/ai/tasks/hold.d.ts +20 -0
- package/dist/ai/tasks/index.d.ts +32 -0
- package/dist/ai/tasks/move.d.ts +19 -0
- package/dist/ai/tasks/patrol.d.ts +8 -0
- package/dist/ai/tasks/retreat.d.ts +20 -0
- package/dist/ai/tasks/scout.d.ts +29 -0
- package/dist/ai/tasks/shared.d.ts +74 -0
- package/dist/ai/team.d.ts +155 -0
- package/dist/ai/threat.d.ts +91 -0
- package/dist/ai/view.d.ts +366 -0
- package/dist/ai/waves.d.ts +126 -0
- package/dist/ai.js +6239 -0
- package/dist/ai.js.map +1 -0
- package/dist/aiTesting.d.ts +179 -0
- package/dist/areas.d.ts +149 -0
- package/dist/attacks.d.ts +66 -0
- package/dist/attributes.d.ts +66 -0
- package/dist/brain-BvVdUhX8.js +7659 -0
- package/dist/brain-BvVdUhX8.js.map +1 -0
- package/dist/builds-C6LfgvEU.js +460 -0
- package/dist/builds-C6LfgvEU.js.map +1 -0
- package/dist/bytes.d.ts +6 -0
- package/dist/camps.d.ts +95 -0
- package/dist/capture.d.ts +131 -0
- package/dist/cellLayers.d.ts +75 -0
- package/dist/cinematics.d.ts +194 -0
- package/dist/clock.d.ts +32 -0
- package/dist/commands.d.ts +235 -0
- package/dist/components.d.ts +184 -0
- package/dist/computers.d.ts +108 -0
- package/dist/concealment.d.ts +61 -0
- package/dist/coreComponents-syuh2fPG.js +5149 -0
- package/dist/coreComponents-syuh2fPG.js.map +1 -0
- package/dist/coreComponents.d.ts +1 -0
- package/dist/dashing.d.ts +8 -0
- package/dist/debug.d.ts +36 -0
- package/dist/debug.js +3 -0
- package/dist/debugCommands-CzjrSm66.js +14739 -0
- package/dist/debugCommands-CzjrSm66.js.map +1 -0
- package/dist/debugCommands.d.ts +213 -0
- package/dist/debugging.d.ts +10 -0
- package/dist/definitions.d.ts +43 -0
- package/dist/defs.d.ts +1162 -0
- package/dist/denying.d.ts +81 -0
- package/dist/destructibles.d.ts +27 -0
- package/dist/determinism-BCymQwiE.js +518 -0
- package/dist/determinism-BCymQwiE.js.map +1 -0
- package/dist/determinism.d.ts +121 -0
- package/dist/dialog.d.ts +94 -0
- package/dist/effectRefs.d.ts +16 -0
- package/dist/effects.d.ts +80 -0
- package/dist/endings.d.ts +22 -0
- package/dist/engagement.d.ts +108 -0
- package/dist/engineEvents.d.ts +710 -0
- package/dist/entity.d.ts +409 -0
- package/dist/entityIndex.d.ts +50 -0
- package/dist/errors.d.ts +85 -0
- package/dist/events.d.ts +97 -0
- package/dist/exactMath.d.ts +63 -0
- package/dist/features.d.ts +10 -0
- package/dist/fields.d.ts +114 -0
- package/dist/fixture.d.ts +17 -0
- package/dist/fog.d.ts +110 -0
- package/dist/formation.d.ts +111 -0
- package/dist/friendlyFire.d.ts +26 -0
- package/dist/game-DiJEN-Ks.js +5800 -0
- package/dist/game-DiJEN-Ks.js.map +1 -0
- package/dist/game.d.ts +501 -0
- package/dist/gameData.d.ts +325 -0
- package/dist/gameFiles.d.ts +26 -0
- package/dist/gates.d.ts +28 -0
- package/dist/generate.d.ts +403 -0
- package/dist/generateWorker.d.ts +39 -0
- package/dist/grid.d.ts +53 -0
- package/dist/ground.d.ts +127 -0
- package/dist/groundSpeed.d.ts +22 -0
- package/dist/hero.d.ts +177 -0
- package/dist/home.d.ts +14 -0
- package/dist/hooks.d.ts +780 -0
- package/dist/hotReload.d.ts +76 -0
- package/dist/ids.d.ts +26 -0
- package/dist/index.d.ts +227 -0
- package/dist/index.js +4701 -0
- package/dist/index.js.map +1 -0
- package/dist/inspect-D9dWHmZ0.js +491 -0
- package/dist/inspect-D9dWHmZ0.js.map +1 -0
- package/dist/inspect.d.ts +176 -0
- package/dist/inventory.d.ts +18 -0
- package/dist/items.d.ts +91 -0
- package/dist/lanes.d.ts +213 -0
- package/dist/life.d.ts +53 -0
- package/dist/local-Dkovq42k.js +1379 -0
- package/dist/local-Dkovq42k.js.map +1 -0
- package/dist/log.d.ts +140 -0
- package/dist/manaBurn.d.ts +39 -0
- package/dist/map/file.d.ts +114 -0
- package/dist/map/images.d.ts +18 -0
- package/dist/map/look.d.ts +47 -0
- package/dist/map/pathProfile.d.ts +13 -0
- package/dist/map/resize.d.ts +54 -0
- package/dist/map/schema.d.ts +10 -0
- package/dist/map/terrain.d.ts +32 -0
- package/dist/map/types.d.ts +613 -0
- package/dist/map.d.ts +7 -0
- package/dist/mapCheck/cells.d.ts +19 -0
- package/dist/mapCheck/rule.d.ts +30 -0
- package/dist/mapCheck/rules/names.d.ts +3 -0
- package/dist/mapCheck/rules/objects.d.ts +3 -0
- package/dist/mapCheck/rules/paths.d.ts +3 -0
- package/dist/mapCheck/rules/players.d.ts +3 -0
- package/dist/mapCheck/rules/races.d.ts +3 -0
- package/dist/mapCheck/rules/random.d.ts +3 -0
- package/dist/mapCheck/rules/regions.d.ts +3 -0
- package/dist/mapCheck/rules/targets.d.ts +3 -0
- package/dist/mapCheck/rules/walking.d.ts +3 -0
- package/dist/mapCheck.d.ts +23 -0
- package/dist/mapFields.d.ts +364 -0
- package/dist/mapFile.d.ts +23 -0
- package/dist/mapMeasure.d.ts +95 -0
- package/dist/mapMerge.d.ts +19 -0
- package/dist/mapObjectives.d.ts +82 -0
- package/dist/mapObjects.d.ts +1 -0
- package/dist/math.d.ts +44 -0
- package/dist/messages.d.ts +150 -0
- package/dist/missionRules-C-bGxm0Q.js +523 -0
- package/dist/missionRules-C-bGxm0Q.js.map +1 -0
- package/dist/missionRules.d.ts +179 -0
- package/dist/mods.d.ts +146 -0
- package/dist/names.d.ts +93 -0
- package/dist/navigation/agentParams.d.ts +4 -0
- package/dist/navigation/air.d.ts +89 -0
- package/dist/navigation/builds.d.ts +140 -0
- package/dist/navigation/groundAreas.d.ts +23 -0
- package/dist/navigation/navigation.d.ts +127 -0
- package/dist/navigation/recast.d.ts +214 -0
- package/dist/navigation/sidePaths.d.ts +69 -0
- package/dist/navigation/sized.d.ts +1 -0
- package/dist/navigation-worker.js +11 -0
- package/dist/navigation-worker.js.map +1 -0
- package/dist/nearest.d.ts +8 -0
- package/dist/noise.d.ts +12 -0
- package/dist/objectives.d.ts +93 -0
- package/dist/orders/basic.d.ts +96 -0
- package/dist/orders/build.d.ts +91 -0
- package/dist/orders/cast.d.ts +105 -0
- package/dist/orders/facts.d.ts +14 -0
- package/dist/orders/harvest.d.ts +94 -0
- package/dist/orders/idle.d.ts +7 -0
- package/dist/orders/items.d.ts +14 -0
- package/dist/orders/queue.d.ts +24 -0
- package/dist/pack.schema.json +6621 -0
- package/dist/packs/director/index.d.ts +81 -0
- package/dist/packs/heroes/campaign.d.ts +137 -0
- package/dist/packs/heroes/carry.d.ts +59 -0
- package/dist/packs/heroes/commands.d.ts +6 -0
- package/dist/packs/heroes/hire.d.ts +9 -0
- package/dist/packs/heroes/index.d.ts +12 -0
- package/dist/packs/heroes/making.d.ts +16 -0
- package/dist/packs/heroes/respawn.d.ts +42 -0
- package/dist/packs/moba/index.d.ts +34 -0
- package/dist/packs/pack.d.ts +84 -0
- package/dist/packs-g5thvmGn.js +3199 -0
- package/dist/packs-g5thvmGn.js.map +1 -0
- package/dist/packs.d.ts +84 -0
- package/dist/paths.d.ts +51 -0
- package/dist/plain.d.ts +17 -0
- package/dist/player.d.ts +117 -0
- package/dist/portals.d.ts +66 -0
- package/dist/prefabs.d.ts +139 -0
- package/dist/presetBuildings.d.ts +52 -0
- package/dist/presetGround.d.ts +22 -0
- package/dist/profiles-B3NS9jwk.js +335 -0
- package/dist/profiles-B3NS9jwk.js.map +1 -0
- package/dist/races.d.ts +136 -0
- package/dist/randomGroups.d.ts +2 -0
- package/dist/registry.d.ts +464 -0
- package/dist/remains.d.ts +119 -0
- package/dist/replication.d.ts +103 -0
- package/dist/rng.d.ts +17 -0
- package/dist/rules.d.ts +395 -0
- package/dist/rulesCheck.d.ts +37 -0
- package/dist/runes.d.ts +41 -0
- package/dist/save.d.ts +277 -0
- package/dist/scenario.d.ts +56 -0
- package/dist/scheduler.d.ts +67 -0
- package/dist/score.d.ts +306 -0
- package/dist/sequences.d.ts +132 -0
- package/dist/server/doorman.d.ts +21 -0
- package/dist/server/gameServer.d.ts +346 -0
- package/dist/server/index.d.ts +24 -0
- package/dist/server/lobby.d.ts +1 -0
- package/dist/server/log.d.ts +13 -0
- package/dist/server/match.d.ts +24 -0
- package/dist/server/mode.d.ts +168 -0
- package/dist/server/navigation-worker.d.ts +1 -0
- package/dist/server/navigation.d.ts +11 -0
- package/dist/server/ops.d.ts +78 -0
- package/dist/server/packs.d.ts +15 -0
- package/dist/server/ratings.d.ts +62 -0
- package/dist/server/relay.d.ts +34 -0
- package/dist/server/rooms.d.ts +162 -0
- package/dist/server/seat.d.ts +2 -0
- package/dist/server/seatSettings.d.ts +15 -0
- package/dist/server/secret.d.ts +5 -0
- package/dist/server/start.d.ts +54 -0
- package/dist/server/websocket.d.ts +74 -0
- package/dist/server.js +2861 -0
- package/dist/server.js.map +1 -0
- package/dist/session/can.d.ts +20 -0
- package/dist/session/commandReplay.d.ts +92 -0
- package/dist/session/debug.d.ts +65 -0
- package/dist/session/delay.d.ts +15 -0
- package/dist/session/delta.d.ts +98 -0
- package/dist/session/entityState.d.ts +1 -0
- package/dist/session/local.d.ts +214 -0
- package/dist/session/memory.d.ts +27 -0
- package/dist/session/protocol.d.ts +1155 -0
- package/dist/session/remote.d.ts +530 -0
- package/dist/session/replay.d.ts +114 -0
- package/dist/session/seed.d.ts +7 -0
- package/dist/session/share.d.ts +78 -0
- package/dist/session/socket.d.ts +8 -0
- package/dist/session/wire.d.ts +153 -0
- package/dist/session/worker.d.ts +227 -0
- package/dist/shared.d.ts +171 -0
- package/dist/sides.d.ts +75 -0
- package/dist/sight.d.ts +27 -0
- package/dist/simulate-oXBiw1Ff.js +167 -0
- package/dist/simulate-oXBiw1Ff.js.map +1 -0
- package/dist/simulate-worker.d.ts +1 -0
- package/dist/simulate-worker.js +28 -0
- package/dist/simulate-worker.js.map +1 -0
- package/dist/simulate.d.ts +154 -0
- package/dist/smart.d.ts +9 -0
- package/dist/spatial.d.ts +62 -0
- package/dist/spawning.d.ts +33 -0
- package/dist/stances.d.ts +76 -0
- package/dist/start.d.ts +71 -0
- package/dist/stats.d.ts +122 -0
- package/dist/summons.d.ts +63 -0
- package/dist/systems/abilities.d.ts +3 -0
- package/dist/systems/combat.d.ts +71 -0
- package/dist/systems/combatTold.d.ts +14 -0
- package/dist/systems/construction.d.ts +34 -0
- package/dist/systems/economy.d.ts +21 -0
- package/dist/systems/fog.d.ts +19 -0
- package/dist/systems/life.d.ts +3 -0
- package/dist/systems/movement.d.ts +105 -0
- package/dist/systems/orders.d.ts +7 -0
- package/dist/systems/production.d.ts +49 -0
- package/dist/systems/productionQueue.d.ts +40 -0
- package/dist/systems/victory.d.ts +14 -0
- package/dist/talk.d.ts +65 -0
- package/dist/tech.d.ts +62 -0
- package/dist/techTree.d.ts +38 -0
- package/dist/terrain.d.ts +173 -0
- package/dist/terrainSave.d.ts +29 -0
- package/dist/testing.d.ts +58 -0
- package/dist/testing.js +822 -0
- package/dist/testing.js.map +1 -0
- package/dist/tiles.d.ts +34 -0
- package/dist/timers.d.ts +146 -0
- package/dist/tomes.d.ts +48 -0
- package/dist/trade.d.ts +28 -0
- package/dist/transport.d.ts +76 -0
- package/dist/tunables.d.ts +45 -0
- package/dist/upkeep.d.ts +16 -0
- package/dist/veterancy.d.ts +80 -0
- package/dist/walls.d.ts +86 -0
- package/dist/world.d.ts +1118 -0
- package/package.json +80 -5
- package/README.md +0 -3
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What a player is told of a world, written with what it tells of (design review E7): an event of the world becomes an
|
|
3
|
+
* event on a player's screen by the rule beside the code that emits it (`replicateEvent`), and a part of the snapshot is
|
|
4
|
+
* captured by the feature it is of (`SnapshotPart`). A seat (`LocalSession`) runs what its game has of them
|
|
5
|
+
* (`Registry.replications`, `Registry.snapshotParts`: the engine's, then the packs'), for what its player may know
|
|
6
|
+
* (`SessionView`)
|
|
7
|
+
*/
|
|
8
|
+
import type { Entity, PlayerId } from './entity';
|
|
9
|
+
import type { EventKey } from './events';
|
|
10
|
+
import type { SessionEvent, SessionEvents, Snapshot } from './session/protocol';
|
|
11
|
+
import type { World } from './world';
|
|
12
|
+
import { type TeamMemory } from './session/memory';
|
|
13
|
+
/**
|
|
14
|
+
* A seat's side of a world: whose it is, and what they may know of it now. What the rules that tell a player of the
|
|
15
|
+
* world ask (`replicateEvent`, `SnapshotPart`, an event of a game's own's `replicate`), and what a seat keeps for them
|
|
16
|
+
* (`keep`)
|
|
17
|
+
*
|
|
18
|
+
* @beta
|
|
19
|
+
*/
|
|
20
|
+
export declare class SessionView {
|
|
21
|
+
readonly world: World;
|
|
22
|
+
/** The seat's player: from whose side it sees, an observer's too */
|
|
23
|
+
readonly player: PlayerId;
|
|
24
|
+
/** Who only watches, and sees everything (`LocalSession.observer`) */
|
|
25
|
+
readonly observer: boolean;
|
|
26
|
+
/** Whether the seat is a computer player's, which is told only what a brain reads (`LocalSession.forComputer`) */
|
|
27
|
+
readonly forComputer: boolean;
|
|
28
|
+
/** How many effects of the rules are kept for their stop to be told (`LocalSession` options' `mostEffects`) */
|
|
29
|
+
readonly mostEffects: number;
|
|
30
|
+
/** What the seat was told since its last snapshot, for the next one */
|
|
31
|
+
events: SessionEvent[];
|
|
32
|
+
private readonly kept;
|
|
33
|
+
constructor(world: World,
|
|
34
|
+
/** The seat's player: from whose side it sees, an observer's too */
|
|
35
|
+
player: PlayerId, options?: {
|
|
36
|
+
observer?: boolean;
|
|
37
|
+
forComputer?: boolean;
|
|
38
|
+
mostEffects?: number;
|
|
39
|
+
});
|
|
40
|
+
/** The player's team: theirs now, as the rules may move them to another (`setTeam`) */
|
|
41
|
+
get team(): number;
|
|
42
|
+
/** Whether an owner is the player or an ally of theirs: an observer's is everyone */
|
|
43
|
+
readonly isAlly: (owner: PlayerId) => boolean;
|
|
44
|
+
/** Whether the player's team sees a spot of the map right now: an observer sees all of it */
|
|
45
|
+
readonly sees: (x: number, z: number) => boolean;
|
|
46
|
+
/** Whether the player's team can see the entity right now: its side's always */
|
|
47
|
+
readonly knows: (entity: Entity) => boolean;
|
|
48
|
+
/** An observer's own memory: it sees everything, which is no team's to remember */
|
|
49
|
+
private readonly ownMemory;
|
|
50
|
+
/**
|
|
51
|
+
* What the player's team remembers of what it saw (`teamMemory`: the structures out of sight as last seen, the camps
|
|
52
|
+
* seen empty), or an observer's own. Looked up again each time: the player may have moved to another team since
|
|
53
|
+
*/
|
|
54
|
+
get memory(): TeamMemory;
|
|
55
|
+
/** What the seat keeps under a key for what tells it things (the effects it was shown, the score last told): made the first time */
|
|
56
|
+
keep<S>(key: object, make: () => S): S;
|
|
57
|
+
/** Takes what the seat was told since the last snapshot */
|
|
58
|
+
takeEvents(): SessionEvent[];
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* The event on a screen of a kind
|
|
62
|
+
*
|
|
63
|
+
* @beta
|
|
64
|
+
*/
|
|
65
|
+
export type SessionEventOf<K extends keyof SessionEvents> = SessionEvents[K];
|
|
66
|
+
/**
|
|
67
|
+
* How an event of the world is told to a player (`replicateEvent`): what the seat hears it as, and what it says of it
|
|
68
|
+
* to the player, if anything
|
|
69
|
+
*
|
|
70
|
+
* @beta
|
|
71
|
+
*/
|
|
72
|
+
export interface ReplicatedEvent {
|
|
73
|
+
/** The kind of event on the screen: a computer's seat hears only the kinds a brain reads (`COMPUTER_EVENTS`) */
|
|
74
|
+
readonly as: SessionEvent['type'];
|
|
75
|
+
/** The world's event it tells of: one of the engine's (`engineEvents`) or a game's own (`defineEvent`) */
|
|
76
|
+
readonly event: EventKey<unknown>;
|
|
77
|
+
/** What the player is told of it: nothing for what they may not know */
|
|
78
|
+
tell(payload: unknown, view: SessionView): SessionEvent | undefined;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* How an event of the world is told to a player, written beside what emits it: `replicateEvent(healed, 'heal', (heal,
|
|
82
|
+
* view) => view.knows(heal.target) ? { type: 'heal', ... } : undefined)`. Listed by the engine for its own, by a pack in
|
|
83
|
+
* `GamePack.replications`
|
|
84
|
+
*
|
|
85
|
+
* @beta
|
|
86
|
+
*/
|
|
87
|
+
export declare function replicateEvent<T, A extends keyof SessionEvents>(event: EventKey<T>, as: A, tell: (payload: T, view: SessionView) => SessionEventOf<A> | undefined): ReplicatedEvent;
|
|
88
|
+
/**
|
|
89
|
+
* A part of the snapshot a player is sent, captured by the feature it is of: the projectiles, the items on the
|
|
90
|
+
* ground, the score. Before the entities (`head`) or after the players; left out of the snapshot where it gives
|
|
91
|
+
* nothing (`undefined`). Listed by the engine for its own, by a pack in `GamePack.snapshotParts` (a key of its own
|
|
92
|
+
* added to `Snapshot` by declaration merging)
|
|
93
|
+
*
|
|
94
|
+
* @beta
|
|
95
|
+
*/
|
|
96
|
+
export interface SnapshotPart<K extends keyof Snapshot = keyof Snapshot> {
|
|
97
|
+
readonly key: K;
|
|
98
|
+
/** Before the entities and the players, where the tick's own facts are (the hour, the outcome) */
|
|
99
|
+
readonly head?: boolean;
|
|
100
|
+
capture(view: SessionView): Snapshot[K] | undefined;
|
|
101
|
+
}
|
|
102
|
+
/** What the seat was told since its last snapshot (`Snapshot.events`) */
|
|
103
|
+
export declare const eventsPart: SnapshotPart<keyof Snapshot>;
|
package/dist/rng.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Small seeded PRNG (mulberry32). The simulation never touches Math.random so runs are reproducible.
|
|
3
|
+
*
|
|
4
|
+
* @beta
|
|
5
|
+
*/
|
|
6
|
+
export declare class Rng {
|
|
7
|
+
private state;
|
|
8
|
+
constructor(seed: number);
|
|
9
|
+
/** Float in [0, 1) */
|
|
10
|
+
next(): number;
|
|
11
|
+
/** Where it is in its sequence, for a save. `restore` with it carries on with the very same numbers */
|
|
12
|
+
save(): number;
|
|
13
|
+
restore(state: number): void;
|
|
14
|
+
range(min: number, max: number): number;
|
|
15
|
+
/** Integer in [min, max] */
|
|
16
|
+
int(min: number, max: number): number;
|
|
17
|
+
}
|
package/dist/rules.d.ts
ADDED
|
@@ -0,0 +1,395 @@
|
|
|
1
|
+
import type { DamageType, Stats, UnitTypeDef } from './defs';
|
|
2
|
+
import type { Registry } from './registry';
|
|
3
|
+
import type { Entity, PlayerId } from './entity';
|
|
4
|
+
import { type Upkeep } from './upkeep';
|
|
5
|
+
import type { World } from './world';
|
|
6
|
+
import type { OrderInit } from './registry';
|
|
7
|
+
import type { GameModule } from './game';
|
|
8
|
+
import type { ScoreRules } from './score';
|
|
9
|
+
import { type HeroRules } from './hero';
|
|
10
|
+
/**
|
|
11
|
+
* A rule of `HudSharing`: one value for every unit, or a function deciding it for each (only heroes', only a boss's)
|
|
12
|
+
*
|
|
13
|
+
* @beta
|
|
14
|
+
*/
|
|
15
|
+
export type HudShareRule<T> = T | ((world: World, entity: Entity) => T);
|
|
16
|
+
/**
|
|
17
|
+
* What of a unit the players who see it are told beyond what they always are (`GameRules.hud`), each for the plates
|
|
18
|
+
* over it to show. What is not shared never reaches a player, so no screen can show it. A game's own data goes in a
|
|
19
|
+
* component with `replicate` (the client's `hudData` reads it)
|
|
20
|
+
*
|
|
21
|
+
* @beta
|
|
22
|
+
*/
|
|
23
|
+
export interface HudSharing {
|
|
24
|
+
/**
|
|
25
|
+
* The seconds left of its buffs (`EntityState.buffTimes`): to everyone who sees it (`true`), to its owner and their
|
|
26
|
+
* allies (`'allies'`), or to no one (`false`, when left out)
|
|
27
|
+
*/
|
|
28
|
+
shareBuffTimes?: HudShareRule<boolean | 'allies'>;
|
|
29
|
+
/**
|
|
30
|
+
* Its abilities (`EntityState.abilities`) to everyone who sees it, its side's or not: those it has learned and
|
|
31
|
+
* their levels (`'icons'`), with how much of their cooldowns is left too (`'cooldowns'`), or none (`'none'`, when
|
|
32
|
+
* left out: its side has them in `own` all the same)
|
|
33
|
+
*/
|
|
34
|
+
shareAbilities?: HudShareRule<'none' | 'icons' | 'cooldowns'>;
|
|
35
|
+
/** A hero's experience (`HeroSent.xp`) to everyone who sees it. Its side's alone when left out */
|
|
36
|
+
shareXp?: HudShareRule<boolean>;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* A unit in a queue, not made yet, as the supply it will take is asked of it (`GameRules.supply.of`)
|
|
40
|
+
*
|
|
41
|
+
* @beta
|
|
42
|
+
*/
|
|
43
|
+
export interface QueuedUnit {
|
|
44
|
+
readonly def: UnitTypeDef;
|
|
45
|
+
readonly owner: PlayerId;
|
|
46
|
+
readonly queued: true;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* How the fog of war keeps what was seen (`GameRules.fog`)
|
|
50
|
+
*
|
|
51
|
+
* @beta
|
|
52
|
+
*/
|
|
53
|
+
export interface FogRules {
|
|
54
|
+
/** Part of its sight a unit has at night, for types that do not say (`UnitTypeDef.sightNight`) */
|
|
55
|
+
nightSight: number;
|
|
56
|
+
/**
|
|
57
|
+
* What is kept of what was seen once: `remembered`, ground drawn dim and buildings as they were last seen (when left
|
|
58
|
+
* out); `nothing`, out of sight is as never seen (ground black again, buildings forgotten; building there is still
|
|
59
|
+
* allowed)
|
|
60
|
+
*/
|
|
61
|
+
explored?: 'remembered' | 'nothing';
|
|
62
|
+
/**
|
|
63
|
+
* The whole map explored from the start, the fog over it all the same (as classic RTS melee maps are): the ground drawn
|
|
64
|
+
* dim, and what stands on it and belongs to no player (trees, mines, rocks, neutral buildings: shops, taverns, the
|
|
65
|
+
* creeps' own) seen from the first moment, as it stood then; units, and players' buildings, only once in sight. A map
|
|
66
|
+
* says otherwise (`MapDef.explored`). No when left out
|
|
67
|
+
*/
|
|
68
|
+
startExplored?: boolean;
|
|
69
|
+
/** How ground never seen is drawn: `black` (when left out), or `dim` as explored ground is */
|
|
70
|
+
mask?: 'black' | 'dim';
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* The numbers and formulas of a kind of game that are not about any one unit: the supply cap, what selling gives
|
|
74
|
+
* back, how a hit is mitigated. In groups, each about one thing: supply, production, the economy, combat, movement,
|
|
75
|
+
* the fog, talk, the camps, heroes, what the HUD is told, the score. A game module changes the ones it wants
|
|
76
|
+
* (`GameModule.rules`: any of a group, the rest of it the engine's) and a pack the ones it brings (`GamePack.rules`).
|
|
77
|
+
*
|
|
78
|
+
* Read them from `world.rules` in the simulation, and from `session.registry.rules` on a player's screen.
|
|
79
|
+
*
|
|
80
|
+
* @beta
|
|
81
|
+
*/
|
|
82
|
+
export interface GameRules {
|
|
83
|
+
/** What armies cost in supply, and how much a player may have (`SupplyRules`) */
|
|
84
|
+
supply: SupplyRules;
|
|
85
|
+
/** What buildings make and how they go up (`ProductionRules`) */
|
|
86
|
+
production: ProductionRules;
|
|
87
|
+
/** What is paid back, paid for and given away (`EconomyRules`) */
|
|
88
|
+
economy: EconomyRules;
|
|
89
|
+
/** How a hit lands and how much of it is felt, and who fights whom (`CombatRules`) */
|
|
90
|
+
combat: CombatRules;
|
|
91
|
+
/** How units find their way among each other (`MovementRules`) */
|
|
92
|
+
movement: MovementRules;
|
|
93
|
+
/** What is seen and kept of what was (`FogRules`) */
|
|
94
|
+
fog: FogRules;
|
|
95
|
+
/** Pings, chat and pauses (`TalkRules`) */
|
|
96
|
+
talk: TalkRules;
|
|
97
|
+
/**
|
|
98
|
+
* Creeps' camps (`camps.ts`): how far creeps chase away from their camp (`leash`), whether they sleep at home at night
|
|
99
|
+
* until attacked (`sleep`), and the seconds after a camp is cleared that it comes back, for every camp (`respawn`, see
|
|
100
|
+
* `Camp.respawn`; never when left out). What makes creeps keep to them, sleep and come back is the heroes pack's
|
|
101
|
+
* (`withHeroes`)
|
|
102
|
+
*/
|
|
103
|
+
camps: CampRules;
|
|
104
|
+
/**
|
|
105
|
+
* Heroes' numbers (`HeroRules`): how many a player may have, the experience a level takes, what bringing one back
|
|
106
|
+
* costs. The heroes pack's to change (`withHeroes(rules)`); the classic RTS numbers when left out
|
|
107
|
+
*/
|
|
108
|
+
heroes: HeroRules;
|
|
109
|
+
/**
|
|
110
|
+
* What of a unit the players who see it are told beyond what they always are (its health, mana, level, buffs and
|
|
111
|
+
* their stacks), for the plates over it to show (indicators-plan U3): the seconds left of its buffs, its abilities,
|
|
112
|
+
* a hero's experience. Nothing more than that when left out
|
|
113
|
+
*
|
|
114
|
+
* @beta
|
|
115
|
+
*/
|
|
116
|
+
hud: HudSharing;
|
|
117
|
+
/**
|
|
118
|
+
* What the game counts of its players for its score (a classic RTS score screen): kills, losses, damage, healing,
|
|
119
|
+
* resources, its own (`ScoreRules`, `presetScore()`, `defineStat`). Counted by the rules as the game goes, kept in
|
|
120
|
+
* saves, told to the players as it says. Nothing is counted when left out
|
|
121
|
+
*
|
|
122
|
+
* @beta
|
|
123
|
+
*/
|
|
124
|
+
score?: ScoreRules;
|
|
125
|
+
/**
|
|
126
|
+
* Whether a player may command an entity: its owner, and whoever the owner shares control with
|
|
127
|
+
* (`world.sides.shareControl`, a force's `sharedControl`), when left out. What every command is checked against, and
|
|
128
|
+
* what decides whose units a player is told the own state of (orders, the queue, the bag)
|
|
129
|
+
*/
|
|
130
|
+
mayCommand(world: World, player: PlayerId, entity: Entity): boolean;
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Supply (`GameRules.supply`)
|
|
134
|
+
*
|
|
135
|
+
* @beta
|
|
136
|
+
*/
|
|
137
|
+
export interface SupplyRules {
|
|
138
|
+
/** Supply no player can go past, however much they build to provide it */
|
|
139
|
+
max: number;
|
|
140
|
+
/**
|
|
141
|
+
* Pools of supply besides the one there always is (`supply`, food), by name, each with what it is called and its
|
|
142
|
+
* most: a cap on commanders, on vehicles. A unit takes of one with `supplies`, a building provides with
|
|
143
|
+
* `suppliesProvided`. None when left out
|
|
144
|
+
*/
|
|
145
|
+
pools?: Record<string, {
|
|
146
|
+
name: string;
|
|
147
|
+
max: number;
|
|
148
|
+
}>;
|
|
149
|
+
/**
|
|
150
|
+
* Supply a unit takes: summons taking none, an aura that lowers it. Its type's `supply`, when left out. Asked of the
|
|
151
|
+
* units there are, and of those in a queue, which are not yet (`QueuedUnit`: their type and owner)
|
|
152
|
+
*/
|
|
153
|
+
of(world: World, unit: Entity | QueuedUnit): number;
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Production and construction (`GameRules.production`)
|
|
157
|
+
*
|
|
158
|
+
* @beta
|
|
159
|
+
*/
|
|
160
|
+
export interface ProductionRules {
|
|
161
|
+
/** Things a building can have waiting to be made */
|
|
162
|
+
queue: number;
|
|
163
|
+
/** Part of what a structure cost that comes back when it is called off while being built */
|
|
164
|
+
cancelRefund: number;
|
|
165
|
+
/** Part of its health a structure starts being built with */
|
|
166
|
+
constructionHealth: number;
|
|
167
|
+
/** How fast a structure goes up with so many builders at it, as a part of its build time a second: the first builder all of it, every other half, when left out */
|
|
168
|
+
buildRate(world: World, structure: Entity, builders: number): number;
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Selling, repairing, giving and upkeep (`GameRules.economy`)
|
|
172
|
+
*
|
|
173
|
+
* @beta
|
|
174
|
+
*/
|
|
175
|
+
export interface EconomyRules {
|
|
176
|
+
/** Part of an item's price a shop pays for it */
|
|
177
|
+
sellPrice: number;
|
|
178
|
+
/** Part of what a building cost that mending all of its health costs */
|
|
179
|
+
repairCost: number;
|
|
180
|
+
/** The part of what a player gives an ally that is lost on the way, 0..1 (see `give`). Nothing when left out */
|
|
181
|
+
tradeTax: number;
|
|
182
|
+
/** What a player's army costs them in income. The game's upkeep tiers by supply used, when left out */
|
|
183
|
+
upkeep(world: World, player: PlayerId): Upkeep;
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* Fighting (`GameRules.combat`)
|
|
187
|
+
*
|
|
188
|
+
* @beta
|
|
189
|
+
*/
|
|
190
|
+
export interface CombatRules {
|
|
191
|
+
/**
|
|
192
|
+
* Whether a basic attack of `attacker` strikes critically, and what it multiplies the damage by then: a number for a
|
|
193
|
+
* critical strike, nothing for none. Asked as the attack goes off, before whether it misses. None when left out (a
|
|
194
|
+
* game's crits: `withMobaStats`, or its own)
|
|
195
|
+
*/
|
|
196
|
+
critical(world: World, attacker: Entity, stats: Readonly<Stats>): number | undefined;
|
|
197
|
+
/**
|
|
198
|
+
* What is left of damage once the defences of the target had their say, as a part of it. `source` is the stats
|
|
199
|
+
* of whoever deals it, when someone does. Armor and magic resist, with penetration, when left out
|
|
200
|
+
*/
|
|
201
|
+
mitigation(type: DamageType, target: Readonly<Stats>, source?: Readonly<Stats>): number;
|
|
202
|
+
/**
|
|
203
|
+
* Keeps stats within what the game allows, once everything that changes them was added up. Changes them in place.
|
|
204
|
+
* The default keeps attack speed within its limits (below)
|
|
205
|
+
*/
|
|
206
|
+
clampStats(stats: Stats, rules: Readonly<GameRules>): void;
|
|
207
|
+
/** Seconds an ability takes to be ready again, for a unit with these stats. Its cooldown as it is, when left out */
|
|
208
|
+
cooldown(seconds: number, stats: Readonly<Stats>): number;
|
|
209
|
+
/**
|
|
210
|
+
* How much of a slow a unit with these stats takes: `slow` is what slows it, added up, below 0 (-0.3 for 30% slower).
|
|
211
|
+
* All of it, when left out
|
|
212
|
+
*/
|
|
213
|
+
slowTaken(stats: Readonly<Stats>, slow: number): number;
|
|
214
|
+
/** What the heals and shields `source` gives are multiplied by. 1, when left out */
|
|
215
|
+
healPower(world: World, source: Entity): number;
|
|
216
|
+
/** Nobody attacks slower or faster than this, whatever they carry: [lowest, highest] attack speed */
|
|
217
|
+
attackSpeedLimits: [number, number];
|
|
218
|
+
/** Seconds a corpse lies where a unit of flesh died, for spells to use (see `raiseDead`). None at all for 0 */
|
|
219
|
+
corpseTime: number;
|
|
220
|
+
/** The chance, 0..1, that an attack of `attacker` at `target` goes wide. A quarter up a cliff, when left out */
|
|
221
|
+
missChance(world: World, attacker: Entity, target: Entity): number;
|
|
222
|
+
/**
|
|
223
|
+
* What part of an attack that hits an area an entity standing there gets, 0..1: 0 spares it. `source` is who fired
|
|
224
|
+
* it, `distance` how far from the middle the entity is. Everyone there but whoever fired it, all of it in the inner
|
|
225
|
+
* half and half outside, when left out
|
|
226
|
+
*/
|
|
227
|
+
splash(world: World, source: Entity | undefined, other: Entity, distance: number, radius: number): number;
|
|
228
|
+
/** How far a unit looks for enemies by itself, and chases them. The farthest `acquisitionRange` of its attacks, when left out */
|
|
229
|
+
acquisitionRange(world: World, entity: Entity): number;
|
|
230
|
+
/**
|
|
231
|
+
* Which of its attacks (`UnitTypeDef.attacks`, by place) an attacker uses against a target, or -1 for none: it cannot
|
|
232
|
+
* attack it. The first whose `targets` reach the target where it is, when left out (`defaultPickAttack`): a siege
|
|
233
|
+
* weapon for what is on the ground, a second for the air. Asked for every target looked at: keep it cheap
|
|
234
|
+
*/
|
|
235
|
+
pickAttack(world: World, attacker: Entity, target: Entity): number;
|
|
236
|
+
/**
|
|
237
|
+
* What a hit is multiplied by for the attack's type against the target's armour type, as classic RTS games have it
|
|
238
|
+
* (pierce against light, siege against fortified), before armour and shields: none when left out. Attacks name
|
|
239
|
+
* their type (`AttackDef.attackType`), abilities as they deal damage (`DamageOptions.attackType`), unit types their
|
|
240
|
+
* armour (`UnitTypeDef.armourType`); a type the table has not got is refused as the game is made
|
|
241
|
+
*/
|
|
242
|
+
damageTable?: DamageTable;
|
|
243
|
+
/**
|
|
244
|
+
* The layer an attacker fights from, around a target: room is counted apart for each (see `engageRoom`). The air
|
|
245
|
+
* for what flies, the water for boats, the ground for the rest, when left out; any name of the game's own besides
|
|
246
|
+
*/
|
|
247
|
+
engageLayer(world: World, attacker: Entity): string;
|
|
248
|
+
/**
|
|
249
|
+
* How many attackers like this one (of its layer, reaching as far) may fight a target at once. A full target is
|
|
250
|
+
* picked last, and the melee spread around it on as many spots. As many as stand side by side around it, out where
|
|
251
|
+
* they reach, when left out: few for swords around a footman, all of them for long guns
|
|
252
|
+
*/
|
|
253
|
+
engageRoom(world: World, target: Entity, attacker: Entity): number;
|
|
254
|
+
/**
|
|
255
|
+
* Seconds a unit that picked a target by itself closes in on it without getting closer before it lets it go and
|
|
256
|
+
* fights something else (blocked by its own in a pass, say). A target it was told to attack it never lets go. One,
|
|
257
|
+
* when left out; Infinity never
|
|
258
|
+
*/
|
|
259
|
+
giveUpChase(world: World, attacker: Entity, target: Entity): number;
|
|
260
|
+
}
|
|
261
|
+
/**
|
|
262
|
+
* How units move among each other (`GameRules.movement`)
|
|
263
|
+
*
|
|
264
|
+
* @beta
|
|
265
|
+
*/
|
|
266
|
+
export interface MovementRules {
|
|
267
|
+
/**
|
|
268
|
+
* Whether an ally standing in the way of a unit on its way steps aside when asked (see `makeWay`). Those standing
|
|
269
|
+
* about with nothing to do, or waiting by a fight for a spot in it, when left out: not those fighting, walking or
|
|
270
|
+
* with orders of their own
|
|
271
|
+
*/
|
|
272
|
+
makesWay(world: World, mover: Entity, other: Entity): boolean;
|
|
273
|
+
/**
|
|
274
|
+
* How far ahead, in ground units, a unit on its way looks for others standing in it, to go round them
|
|
275
|
+
* (`goesAround`) or, where it cannot, ask them to step aside (`makesWay`) before it reaches them. 0 looks no
|
|
276
|
+
* further than its nose: it then goes round nothing, and asks only once it is held up. 3 when left out
|
|
277
|
+
*/
|
|
278
|
+
lookAhead(world: World, mover: Entity): number;
|
|
279
|
+
/**
|
|
280
|
+
* Whether a unit goes round the units standing in its way (`around`), where the way round is `longer` ground units
|
|
281
|
+
* more than the `straight` way to the next corner of its path, rather than through them, which slows it until they
|
|
282
|
+
* step aside or it has pushed past. Yes for up to a unit and a half more, and a quarter of the straight way, when
|
|
283
|
+
* left out. Where the way round is found is the `detour` hook's
|
|
284
|
+
*/
|
|
285
|
+
goesAround(world: World, mover: Entity, around: readonly Entity[], longer: number, straight: number): boolean;
|
|
286
|
+
/**
|
|
287
|
+
* Whether a group sent somewhere with a right-click moves at the pace of its slowest (`OrderParams.together`), so
|
|
288
|
+
* that it arrives together: no when left out, each at its own speed. Attack-moves are each at their own always
|
|
289
|
+
*/
|
|
290
|
+
together?: boolean;
|
|
291
|
+
/**
|
|
292
|
+
* The formation units ordered to a point together take, by id (`FormationDef`), where the order names none
|
|
293
|
+
* (`OrderInit.formation`): `rows` when left out, which keeps a tight group's shape and lines a scattered one up
|
|
294
|
+
*/
|
|
295
|
+
formation(world: World, units: readonly Entity[], init: OrderInit): string;
|
|
296
|
+
/**
|
|
297
|
+
* How fast a unit goes where it is, from its `moveSpeed`: slower in shallow water, faster on roads. Asked every
|
|
298
|
+
* tick for every unit that moves: keep it cheap. Its speed as it is, when left out
|
|
299
|
+
*/
|
|
300
|
+
moveSpeed(world: World, entity: Entity, speed: number): number;
|
|
301
|
+
}
|
|
302
|
+
/**
|
|
303
|
+
* Pings, chat and pauses (`GameRules.talk`)
|
|
304
|
+
*
|
|
305
|
+
* @beta
|
|
306
|
+
*/
|
|
307
|
+
export interface TalkRules {
|
|
308
|
+
/**
|
|
309
|
+
* Pings (see `ping`): how many a player may send `within` so many seconds, the kinds there are (a hero arena game's
|
|
310
|
+
* when left out; a game adds its own), and what each kind asks of a computer ally (indicators-plan P4): a request on
|
|
311
|
+
* its team's board (`help`, which computers answer by sending fighters; `attack`, `defend` and `rally`, put on the
|
|
312
|
+
* board for the brains that read them), or nothing. A kind not named is heard and not acted on. `kinds` may be
|
|
313
|
+
* worked out from the registry as the game plays (`(registry) => …`): from a file of the game's (`registry.file`),
|
|
314
|
+
* one the editor writes, so a kind added there is let go at once (see `pingKinds`)
|
|
315
|
+
*/
|
|
316
|
+
pings: {
|
|
317
|
+
most: number;
|
|
318
|
+
within: number;
|
|
319
|
+
kinds: readonly string[] | ((registry: Registry) => readonly string[]);
|
|
320
|
+
meanings: Readonly<Record<string, 'help' | 'attack' | 'defend' | 'rally' | 'ignore'>>;
|
|
321
|
+
};
|
|
322
|
+
/** Lines of chat: how many a player may send `within` so many seconds, and how long one may be */
|
|
323
|
+
lines: {
|
|
324
|
+
most: number;
|
|
325
|
+
within: number;
|
|
326
|
+
length: number;
|
|
327
|
+
};
|
|
328
|
+
/** Pauses in a game on a server (see `askPause`): how many each player may ask for (none at 0), and how many seconds one lasts at most */
|
|
329
|
+
pauses: {
|
|
330
|
+
each: number;
|
|
331
|
+
seconds: number;
|
|
332
|
+
};
|
|
333
|
+
}
|
|
334
|
+
/**
|
|
335
|
+
* A damage table: what a hit of each attack type is multiplied by against each armour type (`GameRules.combat.damageTable`).
|
|
336
|
+
* `table[attack][armour]`, the rows the attacks in their order, the columns the armours in theirs
|
|
337
|
+
*
|
|
338
|
+
* @beta
|
|
339
|
+
*/
|
|
340
|
+
export interface DamageTable {
|
|
341
|
+
attacks: readonly string[];
|
|
342
|
+
armours: readonly string[];
|
|
343
|
+
table: readonly (readonly number[])[];
|
|
344
|
+
}
|
|
345
|
+
/**
|
|
346
|
+
* What a hit is multiplied by, by a damage table: 1 for no table, no attack type, no armour type, or one the table
|
|
347
|
+
* has not got
|
|
348
|
+
*
|
|
349
|
+
* @beta
|
|
350
|
+
*/
|
|
351
|
+
export declare function damageMultiplier(table: DamageTable | undefined, attackType: string | undefined, armourType: string | undefined): number;
|
|
352
|
+
/**
|
|
353
|
+
* Refuses a damage table that is not one, and a unit type whose attack or armour names a type the table has not got:
|
|
354
|
+
* as the game is made, so that a misspelling fails then and not in a fight. A game without a table is checked for
|
|
355
|
+
* nothing
|
|
356
|
+
*
|
|
357
|
+
* @beta
|
|
358
|
+
*/
|
|
359
|
+
export declare function checkDamageTable(game: GameModule): void;
|
|
360
|
+
/**
|
|
361
|
+
* The engine's rules: those of a classic RTS melee game
|
|
362
|
+
*
|
|
363
|
+
* @beta
|
|
364
|
+
*/
|
|
365
|
+
export declare const defaultRules: Readonly<GameRules>;
|
|
366
|
+
/**
|
|
367
|
+
* Creeps' camps' rules (`GameRules.camps`)
|
|
368
|
+
*
|
|
369
|
+
* @beta
|
|
370
|
+
*/
|
|
371
|
+
export interface CampRules {
|
|
372
|
+
/** How far creeps chase away from their camp */
|
|
373
|
+
leash: number;
|
|
374
|
+
/** Whether creeps sleep at home at night, until attacked */
|
|
375
|
+
sleep: boolean;
|
|
376
|
+
/** Seconds after a camp is cleared that it comes back, for every camp (see `Camp.respawn`). Never when left out */
|
|
377
|
+
respawn?: number;
|
|
378
|
+
}
|
|
379
|
+
/** What is said of a group of the rules: any of it, a group in it in part as well. A function, a list and a table whole */
|
|
380
|
+
export type RulesPart<T> = T extends (...args: never[]) => unknown ? T : T extends readonly unknown[] ? T : T extends object ? {
|
|
381
|
+
[K in keyof T]?: RulesPart<T[K]>;
|
|
382
|
+
} : T;
|
|
383
|
+
/**
|
|
384
|
+
* What a game says of its rules (`GameModule.rules`), or a pack (`GamePack.rules`): any of them, a group in part
|
|
385
|
+
* (`{ supply: { max: 200 } }`), the engine's for the rest. The damage table, the score and the HUD's sharing are
|
|
386
|
+
* given whole
|
|
387
|
+
*
|
|
388
|
+
* @beta
|
|
389
|
+
*/
|
|
390
|
+
export type RulesInit = {
|
|
391
|
+
[K in Exclude<keyof GameRules, 'score' | 'hud'>]?: RulesPart<GameRules[K]>;
|
|
392
|
+
} & {
|
|
393
|
+
score?: ScoreRules;
|
|
394
|
+
hud?: HudSharing;
|
|
395
|
+
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { type DataKind } from './gameData';
|
|
2
|
+
import type { GameModule } from './game';
|
|
3
|
+
/**
|
|
4
|
+
* What of a game's rules does not fit together (`checkRules`): an id that names nothing (an ability's buff, a unit's
|
|
5
|
+
* `trains`, an upgrade's `requires`, a shop's items), an effect of a type nobody handles, requirements that wait on
|
|
6
|
+
* each other, and, as warnings, what nothing makes, abilities nothing has, and numbers that do not do what they are
|
|
7
|
+
* there for (an `arc` or a `bounce` not of a missile, or of nothing, `charges` of none). Ids are text to the compiler, so a slip
|
|
8
|
+
* in one shows only when the game runs into it ("Unknown unit type") or never (a button that is not there)
|
|
9
|
+
*
|
|
10
|
+
* @beta
|
|
11
|
+
*/
|
|
12
|
+
export interface RulesProblem {
|
|
13
|
+
/** `error`: the game will throw or misbehave when it gets there; `warning`: likely a slip, possibly meant */
|
|
14
|
+
level: 'error' | 'warning';
|
|
15
|
+
/** Where in the rules: `units.footman.trains`, `abilities.holy-light.effects[0].buff` */
|
|
16
|
+
where: string;
|
|
17
|
+
/** The id that is wrong, or the definition the warning is about */
|
|
18
|
+
id: string;
|
|
19
|
+
message: string;
|
|
20
|
+
/**
|
|
21
|
+
* The definition it is in and the field, as the editor's Data panel names them (`{ kind: 'abilities', id:
|
|
22
|
+
* 'holy-light', path: 'effects.0.buff' }`), where it is in one
|
|
23
|
+
*/
|
|
24
|
+
at?: {
|
|
25
|
+
kind: DataKind;
|
|
26
|
+
id: string;
|
|
27
|
+
path: string;
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Checks a game's rules against themselves (`RulesProblem`): run by `defineGame` with the view's checks, and in a
|
|
32
|
+
* game's tests (`expect(checkRules(rules).filter((p) => p.level === 'error')).toEqual([])`). Nothing is thrown
|
|
33
|
+
*
|
|
34
|
+
* @beta
|
|
35
|
+
*/
|
|
36
|
+
export declare function checkRules(rules: GameModule): RulesProblem[];
|
|
37
|
+
export { editDistance } from './nearest';
|
package/dist/runes.d.ts
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { ItemDef } from './defs';
|
|
2
|
+
import type { Entity } from './entity';
|
|
3
|
+
import { type GroundItem } from './items';
|
|
4
|
+
import type { GamePack } from './packs/pack';
|
|
5
|
+
import type { World } from './world';
|
|
6
|
+
/**
|
|
7
|
+
* The runes pack's id
|
|
8
|
+
*
|
|
9
|
+
* @beta
|
|
10
|
+
*/
|
|
11
|
+
export declare const RUNES = "core.runes";
|
|
12
|
+
/**
|
|
13
|
+
* What the runes pack is made with (`withRunes`)
|
|
14
|
+
*
|
|
15
|
+
* @beta
|
|
16
|
+
*/
|
|
17
|
+
export interface RunesOptions {
|
|
18
|
+
/** Whether an item is used as it is picked up, in code: its `powerUp` when left out */
|
|
19
|
+
powerUp?: (item: ItemDef) => boolean;
|
|
20
|
+
/** Who picks one up by walking over it: any unit of a player's, not hidden, when left out */
|
|
21
|
+
takes?: (world: World, entity: Entity, item: GroundItem) => boolean;
|
|
22
|
+
/** How many ticks apart the ground is looked over for who walked onto a rune: 3 when left out */
|
|
23
|
+
every?: number;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Uses an item on the ground as a rune is used: whoever picked it casts its ability (where it stands, no mana), and it
|
|
27
|
+
* is gone from the ground, told as an item picked (`itemPicked`). What the runes pack does as a unit walks over one;
|
|
28
|
+
* false for an item not on the ground
|
|
29
|
+
*
|
|
30
|
+
* @beta
|
|
31
|
+
*/
|
|
32
|
+
export declare function usePowerUp(world: World, entity: Entity, groundId: number): boolean;
|
|
33
|
+
/**
|
|
34
|
+
* Runes, as in classic RTS games: an item that is a power-up (`ItemDef.powerUp`, `RunesOptions.powerUp` in code) is used as
|
|
35
|
+
* it is picked up, by a unit that walks over it (`RunesOptions.takes`) or is told to pick it up, and never carried:
|
|
36
|
+
* whoever picked it casts its ability where it stands. A rune of healing is an item whose ability heals around; a tome
|
|
37
|
+
* one whose ability has the tomes pack's `tome` effect. `usePowerUp` does it in code
|
|
38
|
+
*
|
|
39
|
+
* @beta
|
|
40
|
+
*/
|
|
41
|
+
export declare function withRunes(options?: RunesOptions): GamePack;
|