@v12-engine/engine 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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
package/dist/score.d.ts
ADDED
|
@@ -0,0 +1,306 @@
|
|
|
1
|
+
import { type Component } from './components';
|
|
2
|
+
import type { PlayerId } from './entity';
|
|
3
|
+
import type { EventKey } from './events';
|
|
4
|
+
import type { GameModule } from './game';
|
|
5
|
+
import type { System } from './registry';
|
|
6
|
+
import type { World } from './world';
|
|
7
|
+
/**
|
|
8
|
+
* How a stat takes what it is told: `sum` adds it up (the default), `count` adds one each time whatever the amount,
|
|
9
|
+
* `max` keeps the most it was told, `min` the least, `last` what it was told last (a gauge: the army now)
|
|
10
|
+
*
|
|
11
|
+
* @beta
|
|
12
|
+
*/
|
|
13
|
+
export type ScoreKind = 'sum' | 'count' | 'max' | 'min' | 'last';
|
|
14
|
+
/**
|
|
15
|
+
* How a stat's number reads on a screen: a whole `number` (the default), a `decimal` one, a `percent` (0..1), or
|
|
16
|
+
* `time` (seconds, as 3:05). A screen's own (`GameView.hud.score.format`) goes over it
|
|
17
|
+
*
|
|
18
|
+
* @beta
|
|
19
|
+
*/
|
|
20
|
+
export type ScoreFormat = 'number' | 'decimal' | 'percent' | 'time';
|
|
21
|
+
/**
|
|
22
|
+
* What a stat is told of an event, for a player: how much (`amount`, 1 when left out) and what of (`type`: a unit
|
|
23
|
+
* type, an ability, anything the stat is split by, `ScoreStatDef.byType`)
|
|
24
|
+
*
|
|
25
|
+
* @beta
|
|
26
|
+
*/
|
|
27
|
+
export interface ScoreCount {
|
|
28
|
+
/** Whose number it is */
|
|
29
|
+
player: PlayerId;
|
|
30
|
+
/** How much: 1 when left out */
|
|
31
|
+
amount?: number;
|
|
32
|
+
/** What it was counted of, for a stat kept `byType`: a unit type, an ability */
|
|
33
|
+
type?: string;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* What a stat's source makes of an event: nothing to count (`undefined`), one player (one more for them), what one
|
|
37
|
+
* player is counted, or several of those
|
|
38
|
+
*
|
|
39
|
+
* @beta
|
|
40
|
+
*/
|
|
41
|
+
export type ScoreCounted = PlayerId | ScoreCount | readonly ScoreCount[] | undefined | void;
|
|
42
|
+
/**
|
|
43
|
+
* Where a stat's numbers come from: an event of the world's (`'entityDied'`) or of the game's own (`defineEvent`), and
|
|
44
|
+
* what it counts of each (`scoreOn`)
|
|
45
|
+
*
|
|
46
|
+
* @beta
|
|
47
|
+
*/
|
|
48
|
+
export interface ScoreSource {
|
|
49
|
+
/** The event: one of the engine's (`entityDied`) or of the game's own (`defineEvent`) */
|
|
50
|
+
event: EventKey<any>;
|
|
51
|
+
/** What it counts of each: nothing, a player, or what a player is counted */
|
|
52
|
+
count(payload: any, world: World): ScoreCounted;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* A number the score keeps for each player (`GameRules.score`, `defineStat`): what it is called, how it adds up, where
|
|
56
|
+
* it comes from, and how it is shown. One with no source is counted by the game's code alone (`world.score.add`)
|
|
57
|
+
*
|
|
58
|
+
* @beta
|
|
59
|
+
*/
|
|
60
|
+
export interface ScoreStatDef {
|
|
61
|
+
/** Its own, among the game's stats: `world.score.add(player, id, …)` names it */
|
|
62
|
+
id: string;
|
|
63
|
+
/** What it is called on a screen: its id when left out */
|
|
64
|
+
label?: string;
|
|
65
|
+
/** What the screen says it is, in a tip */
|
|
66
|
+
description?: string;
|
|
67
|
+
/** The tab of the score screen it is in: `units`, `heroes`, `resources`, `combat`, or the game's own. `other` when left out */
|
|
68
|
+
category?: string;
|
|
69
|
+
/** How it adds up: `sum` when left out, `last` for one that only samples */
|
|
70
|
+
kind?: ScoreKind;
|
|
71
|
+
/** The events it is counted from */
|
|
72
|
+
from?: ScoreSource | readonly ScoreSource[];
|
|
73
|
+
/**
|
|
74
|
+
* A gauge: what it is for a player now (their supply used, their gold), read once a second and at each point of the
|
|
75
|
+
* timeline, and taken as `kind` says (`last` when left out). Nothing taken for `undefined`
|
|
76
|
+
*/
|
|
77
|
+
sample?(world: World, player: PlayerId): number | undefined;
|
|
78
|
+
/** Kept by what it was counted of too (`ScoreCount.type`): units killed by unit type, abilities cast by ability */
|
|
79
|
+
byType?: boolean;
|
|
80
|
+
/** On the timeline: sampled every `ScoreRules.every` seconds, for a screen's graph */
|
|
81
|
+
timeline?: boolean;
|
|
82
|
+
/** How its number is written: `number` (when left out), `decimal`, `percent` (0 to 1), `time` (seconds) */
|
|
83
|
+
format?: ScoreFormat;
|
|
84
|
+
/** Counted, and not on the score screen: for the game's own use (an achievement, a mission's goal) */
|
|
85
|
+
hidden?: boolean;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Who of the players is told a player's numbers: that player alone (`own`), their side (`allies`), `everyone`, or
|
|
89
|
+
* `none`; or a function of the world, who is told (`undefined` for an observer) and whose numbers they are
|
|
90
|
+
*
|
|
91
|
+
* @beta
|
|
92
|
+
*/
|
|
93
|
+
export type ScoreAudience = 'own' | 'allies' | 'everyone' | 'none' | ((world: World, viewer: PlayerId | undefined, player: PlayerId) => boolean);
|
|
94
|
+
/**
|
|
95
|
+
* What a game counts of its players (`GameRules.score`): the stats, how often the timeline is sampled, and who is told
|
|
96
|
+
* what while the game goes on and after it ended. `presetScore()` makes one of the engine's stats
|
|
97
|
+
*
|
|
98
|
+
* @beta
|
|
99
|
+
*/
|
|
100
|
+
export interface ScoreRules {
|
|
101
|
+
/** The stats, or what makes them of the game (the engine's set makes one of each resource) */
|
|
102
|
+
stats: readonly ScoreStatDef[] | ((game: GameModule) => readonly ScoreStatDef[]);
|
|
103
|
+
/** Seconds between two points of the timeline: 10 when left out, 0 for no timeline */
|
|
104
|
+
every?: number;
|
|
105
|
+
/**
|
|
106
|
+
* Points the timeline keeps at most: past it, every other point goes and they are twice as far apart, so a long
|
|
107
|
+
* game keeps its whole story in as much room. 360 when left out
|
|
108
|
+
*/
|
|
109
|
+
maxPoints?: number;
|
|
110
|
+
/** Who is told a player's numbers while the game goes on: their side (`allies`) when left out. An observer is told everyone's */
|
|
111
|
+
live?: ScoreAudience;
|
|
112
|
+
/** Who is told them once the game is decided: `everyone` when left out */
|
|
113
|
+
end?: ScoreAudience;
|
|
114
|
+
/** Seconds between two tellings of the numbers to the screens while the game goes on: 1 when left out */
|
|
115
|
+
refresh?: number;
|
|
116
|
+
/** Whose numbers are kept: every player but the neutral ones and the creeps when left out */
|
|
117
|
+
counts?(world: World, player: PlayerId): boolean;
|
|
118
|
+
/** The tabs of the score screen, in order, with their names: those of the stats, in the order met, when left out */
|
|
119
|
+
categories?: readonly {
|
|
120
|
+
id: string;
|
|
121
|
+
label: string;
|
|
122
|
+
}[];
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* The score's rules, its stats made: what the registry keeps (`registry.score`)
|
|
126
|
+
*
|
|
127
|
+
* @beta
|
|
128
|
+
*/
|
|
129
|
+
export interface ResolvedScore {
|
|
130
|
+
/** The rules as the game gave them */
|
|
131
|
+
readonly rules: ScoreRules;
|
|
132
|
+
/** Every stat, made */
|
|
133
|
+
readonly stats: readonly ScoreStatDef[];
|
|
134
|
+
/** Every stat by its id */
|
|
135
|
+
readonly byId: ReadonlyMap<string, ScoreStatDef>;
|
|
136
|
+
/** The tabs of the score screen, in order */
|
|
137
|
+
readonly categories: readonly {
|
|
138
|
+
id: string;
|
|
139
|
+
label: string;
|
|
140
|
+
}[];
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* What the score keeps in the world (`world.state(scoreData)`), plain data for a save: by stat, by player, the number;
|
|
144
|
+
* by stat, player and type, the numbers of a stat kept `byType`; the ticks of the timeline's points, and by stat and
|
|
145
|
+
* player, the number at each
|
|
146
|
+
*
|
|
147
|
+
* @beta
|
|
148
|
+
*/
|
|
149
|
+
export interface ScoreData {
|
|
150
|
+
/** By stat, by player: the number */
|
|
151
|
+
values: Record<string, Record<number, number>>;
|
|
152
|
+
/** By stat, player and type: the numbers of a stat kept `byType` */
|
|
153
|
+
types: Record<string, Record<number, Record<string, number>>>;
|
|
154
|
+
/** Ticks between two points of the timeline, as it is now (doubled each time it was thinned) */
|
|
155
|
+
every: number;
|
|
156
|
+
/** The ticks of the timeline's points */
|
|
157
|
+
ticks: number[];
|
|
158
|
+
/** By stat and player: the number at each point of the timeline */
|
|
159
|
+
line: Record<string, Record<number, number[]>>;
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* The world's component the score is kept in (`core.score`, on the world's own entity): what a save keeps of it
|
|
163
|
+
*
|
|
164
|
+
* @beta
|
|
165
|
+
*/
|
|
166
|
+
export declare const scoreData: Component<ScoreData>;
|
|
167
|
+
/**
|
|
168
|
+
* What a player is told of the score (`Snapshot.score`): the numbers of the players they may see, as they stood at
|
|
169
|
+
* `tick`. Rounded to hundredths
|
|
170
|
+
*
|
|
171
|
+
* @beta
|
|
172
|
+
*/
|
|
173
|
+
export interface ScoreState {
|
|
174
|
+
/** The tick the numbers stood at */
|
|
175
|
+
tick: number;
|
|
176
|
+
/** The game is decided: these are the numbers it ended with, told as `ScoreRules.end` says */
|
|
177
|
+
final: boolean;
|
|
178
|
+
/** Whose numbers are in it */
|
|
179
|
+
players: PlayerId[];
|
|
180
|
+
/** By stat, by player */
|
|
181
|
+
values: Record<string, Record<number, number>>;
|
|
182
|
+
/** By stat, by player, by type: of the stats kept `byType` */
|
|
183
|
+
types?: Record<string, Record<number, Record<string, number>>>;
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* The timeline a player is told (`Snapshot.scoreLine`): the ticks of its points, and by stat and player the number at
|
|
187
|
+
* each, for the players they may see
|
|
188
|
+
*
|
|
189
|
+
* @beta
|
|
190
|
+
*/
|
|
191
|
+
export interface ScoreLineState {
|
|
192
|
+
/** Seconds between two points */
|
|
193
|
+
every: number;
|
|
194
|
+
/** The ticks of its points */
|
|
195
|
+
ticks: number[];
|
|
196
|
+
/** By stat and player: the number at each point */
|
|
197
|
+
values: Record<string, Record<number, number[]>>;
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* A source of a stat, typed by its event, the engine's or the game's own: `scoreOn(entityDied, ({ entity, killer }) =>
|
|
201
|
+
* killer && { player: killer.owner })`
|
|
202
|
+
*
|
|
203
|
+
* @beta
|
|
204
|
+
*/
|
|
205
|
+
export declare function scoreOn<T>(event: EventKey<T>, count: (payload: T, world: World) => ScoreCounted): ScoreSource;
|
|
206
|
+
/**
|
|
207
|
+
* A stat of the game's own, for `GameRules.score`: `defineStat('towersLost', { label: 'Towers lost', category: 'units',
|
|
208
|
+
* from: scoreOn(entityDied, ({ entity }) => entity.def.tags?.includes('tower') ? entity.owner : undefined) })`.
|
|
209
|
+
* One with no source is counted in code (`world.score.add(player, 'towersLost')`)
|
|
210
|
+
*
|
|
211
|
+
* @beta
|
|
212
|
+
*/
|
|
213
|
+
export declare function defineStat(id: string, def?: Omit<ScoreStatDef, 'id'>): ScoreStatDef;
|
|
214
|
+
/** The score's rules with their stats made of the game, checked: an id twice, or a timeline of no length, throws */
|
|
215
|
+
export declare function resolveScore(rules: ScoreRules | undefined | null, game: GameModule): ResolvedScore | null;
|
|
216
|
+
/**
|
|
217
|
+
* The score of a world (`world.score`): counts what its stats are told of the world's events, takes the gauges and
|
|
218
|
+
* the timeline's points, and is what the game's code counts with, and reads, in the rules. What it keeps is the
|
|
219
|
+
* world's state (`scoreData`); nothing of it is kept here but what is made again from the game
|
|
220
|
+
*
|
|
221
|
+
* @beta
|
|
222
|
+
*/
|
|
223
|
+
export declare class Score {
|
|
224
|
+
private readonly world;
|
|
225
|
+
/** Goes up with every change of a number: what a session tells the screens again by */
|
|
226
|
+
version: number;
|
|
227
|
+
/** Goes up with every point of the timeline */
|
|
228
|
+
lineVersion: number;
|
|
229
|
+
private offs;
|
|
230
|
+
constructor(world: World);
|
|
231
|
+
/** The game's score, as its rules say: none for a game that counts nothing */
|
|
232
|
+
get rules(): ResolvedScore | null;
|
|
233
|
+
/** Whether the game counts anything */
|
|
234
|
+
get on(): boolean;
|
|
235
|
+
/** The stats, in order */
|
|
236
|
+
stats(): readonly ScoreStatDef[];
|
|
237
|
+
/** Hears the events the stats are counted from: again when the game takes a new version (`reloadGame`) */
|
|
238
|
+
listen(): void;
|
|
239
|
+
private take;
|
|
240
|
+
/** Whether a player's numbers are kept: as the rules say, every player but the neutral ones and the creeps when they do not */
|
|
241
|
+
counts(player: PlayerId): boolean;
|
|
242
|
+
/** Who `counts`, by player id, where the rules leave it to the engine (whether a player is neutral never changes) */
|
|
243
|
+
private counted;
|
|
244
|
+
/** The players whose numbers are kept, by id */
|
|
245
|
+
players(): PlayerId[];
|
|
246
|
+
private put;
|
|
247
|
+
private stat;
|
|
248
|
+
/** Counts something for a player, as the stat's kind takes it (adds it up for a sum): one when no amount is given */
|
|
249
|
+
add(player: PlayerId, id: string, amount?: number, type?: string): void;
|
|
250
|
+
/** Sets a player's number, whatever the stat's kind */
|
|
251
|
+
set(player: PlayerId, id: string, value: number, type?: string): void;
|
|
252
|
+
/** A player's number of a stat: 0 for one never counted */
|
|
253
|
+
get(player: PlayerId, id: string): number;
|
|
254
|
+
/** A player's numbers of a stat kept by type, by type */
|
|
255
|
+
byType(player: PlayerId, id: string): Readonly<Record<string, number>>;
|
|
256
|
+
/** A team's number of a stat: its players' added up, or the most or the least of them for `max` and `min` */
|
|
257
|
+
team(team: number, id: string): number;
|
|
258
|
+
/** The timeline of a player's number of a stat on it: its points, at `ticks` */
|
|
259
|
+
timeline(player: PlayerId, id: string): {
|
|
260
|
+
ticks: readonly number[];
|
|
261
|
+
values: readonly number[];
|
|
262
|
+
};
|
|
263
|
+
/** Reads the gauges, and on a point of the timeline (or `point`) takes a point. Run once a second by the score's system */
|
|
264
|
+
sample(point?: boolean): void;
|
|
265
|
+
/** Whether `viewer` (`undefined` for an observer) is told `player`'s numbers now */
|
|
266
|
+
tells(viewer: PlayerId | undefined, player: PlayerId, final: boolean): boolean;
|
|
267
|
+
/** What `viewer` is told of the numbers (`Snapshot.score`): nothing for a game that counts none, or a viewer told of no one */
|
|
268
|
+
stateFor(viewer: PlayerId | undefined, final: boolean): ScoreState | undefined;
|
|
269
|
+
/** What `viewer` is told of the timeline (`Snapshot.scoreLine`): nothing without one */
|
|
270
|
+
lineFor(viewer: PlayerId | undefined, final: boolean): ScoreLineState | undefined;
|
|
271
|
+
}
|
|
272
|
+
/** The score's system: the gauges once a second, a point of the timeline when one is due. Only in a game that counts */
|
|
273
|
+
export declare function scoreSystem(world: World): System;
|
|
274
|
+
/**
|
|
275
|
+
* The stats `presetScore` has, by id, those of each resource made of the game (`gathered.gold`, `spent.gold`...)
|
|
276
|
+
*
|
|
277
|
+
* @beta
|
|
278
|
+
*/
|
|
279
|
+
export declare function engineStats(game: GameModule): ScoreStatDef[];
|
|
280
|
+
/**
|
|
281
|
+
* What `presetScore` is given: which of the engine's stats (`only`, or all but `without`), stats of the game's own
|
|
282
|
+
* after them, and the score's other rules
|
|
283
|
+
*
|
|
284
|
+
* @beta
|
|
285
|
+
*/
|
|
286
|
+
export interface PresetScoreOptions extends Omit<ScoreRules, 'stats'> {
|
|
287
|
+
/** Only these of the engine's stats, by id (`gathered` for every `gathered.<resource>`) */
|
|
288
|
+
only?: readonly string[];
|
|
289
|
+
/** The engine's stats but these, by id or as `only` */
|
|
290
|
+
without?: readonly string[];
|
|
291
|
+
/** Stats of the game's own, after the engine's */
|
|
292
|
+
stats?: readonly ScoreStatDef[];
|
|
293
|
+
}
|
|
294
|
+
/**
|
|
295
|
+
* The engine's score, for `GameRules.score`: a classic RTS score screen. Units produced, killed and lost, buildings
|
|
296
|
+
* built, razed and lost, the army and the largest, heroes killed and lost, the highest hero level, experience, creeps
|
|
297
|
+
* killed, items obtained, abilities cast, damage dealt and taken, healing, and of each resource what was gathered,
|
|
298
|
+
* spent and lost to upkeep, the bounty and what went between allies
|
|
299
|
+
*
|
|
300
|
+
* @beta
|
|
301
|
+
*/
|
|
302
|
+
export declare function presetScore(options?: PresetScoreOptions): ScoreRules;
|
|
303
|
+
/** The score the player is told (`Snapshot.score`) */
|
|
304
|
+
export declare const scorePart: import("./replication").SnapshotPart<keyof import(".").Snapshot>;
|
|
305
|
+
/** The score's line over time the player is told (`Snapshot.scoreLine`) */
|
|
306
|
+
export declare const scoreLinePart: import("./replication").SnapshotPart<keyof import(".").Snapshot>;
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import { type EventKey, type ListenerDef } from './events';
|
|
2
|
+
import type { System } from './registry';
|
|
3
|
+
import { type TimerDef } from './timers';
|
|
4
|
+
import type { World } from './world';
|
|
5
|
+
/** An event a step can wait for: one of the engine's by name, or a game's own */
|
|
6
|
+
type AnyEvent = EventKey<any>;
|
|
7
|
+
/** Doing something: runs, and the sequence goes on to the next step at once. `run` is the id of the sequence running it */
|
|
8
|
+
type Act<D> = (world: World, data: D, run: number) => void;
|
|
9
|
+
/** Waiting a number of seconds */
|
|
10
|
+
interface Wait {
|
|
11
|
+
kind: 'wait';
|
|
12
|
+
seconds: number;
|
|
13
|
+
}
|
|
14
|
+
/** Waiting for an event, and for what it says to pass a test when there is one */
|
|
15
|
+
interface WaitFor<D> {
|
|
16
|
+
kind: 'waitFor';
|
|
17
|
+
event: AnyEvent;
|
|
18
|
+
/**
|
|
19
|
+
* `run` is the id of the sequence waiting, as an `Act` has it. Not called `test`, as `WaitUntil`'s is: a step's type
|
|
20
|
+
* would be inferred from the other's then (`waitFor` in a sequence of data had its data typed `never`)
|
|
21
|
+
*/
|
|
22
|
+
passes?: (world: World, payload: any, data: D, run: number) => boolean;
|
|
23
|
+
}
|
|
24
|
+
/** Waiting until something holds. Asked every tick, so keep it cheap */
|
|
25
|
+
interface WaitUntil<D> {
|
|
26
|
+
kind: 'waitUntil';
|
|
27
|
+
/** `run` is the id of the sequence waiting, as an `Act` has it */
|
|
28
|
+
test: (world: World, data: D, run: number) => boolean;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* One step of a sequence
|
|
32
|
+
*
|
|
33
|
+
* @beta
|
|
34
|
+
*/
|
|
35
|
+
export type Step<D> = Act<D> | Wait | WaitFor<D> | WaitUntil<D>;
|
|
36
|
+
/**
|
|
37
|
+
* Waits `seconds` before the next step
|
|
38
|
+
*
|
|
39
|
+
* @beta
|
|
40
|
+
*/
|
|
41
|
+
export declare const wait: (seconds: number) => Wait;
|
|
42
|
+
/**
|
|
43
|
+
* Waits for an event, the engine's (`'constructionFinished'`) or a game's own, and for `test` to pass on what it
|
|
44
|
+
* says when there is one. Heard at the end of the tick, like listeners hear events
|
|
45
|
+
*
|
|
46
|
+
* @beta
|
|
47
|
+
*/
|
|
48
|
+
export declare function waitFor<T, D = any>(event: EventKey<T>, test?: (world: World, payload: T, data: D, run: number) => boolean): WaitFor<D>;
|
|
49
|
+
/**
|
|
50
|
+
* Waits until `test` holds: asked at the end of every tick
|
|
51
|
+
*
|
|
52
|
+
* @beta
|
|
53
|
+
*/
|
|
54
|
+
export declare const waitUntil: <D = any>(test: (world: World, data: D, run: number) => boolean) => WaitUntil<D>;
|
|
55
|
+
/**
|
|
56
|
+
* What a mission or a cutscene is mostly made of: do this, wait two seconds, then that, then wait until the gate
|
|
57
|
+
* holds five invaders. Made with `defineSequence` and given in `GameModule.sequences`, so that a save finds the steps
|
|
58
|
+
* by id: what is kept in the world of a running sequence is which one, which step, and its data, never a function.
|
|
59
|
+
* That is why it is not an `async` function: one of those cannot be saved halfway through
|
|
60
|
+
*
|
|
61
|
+
* @beta
|
|
62
|
+
*/
|
|
63
|
+
export interface SequenceDef<D = any> {
|
|
64
|
+
/** Shared by every game, like other ids: give it a prefix of the game's (`'td.briefing'`) */
|
|
65
|
+
readonly id: string;
|
|
66
|
+
readonly steps: readonly Step<D>[];
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Typed help: `defineSequence<{ hero: number }>('td.briefing', [(world) => ..., wait(3), waitFor(constructionFinished)])`.
|
|
70
|
+
* A helper that is several steps (`talk`, `cinematic(id, { wait })`) may be given as its list, spread or not
|
|
71
|
+
*
|
|
72
|
+
* @beta
|
|
73
|
+
*/
|
|
74
|
+
export declare function defineSequence<D = undefined>(id: string, steps: (Step<D> | readonly Step<D>[])[]): SequenceDef<D>;
|
|
75
|
+
/** A sequence as it runs in the world. Plain data: it goes into a save */
|
|
76
|
+
interface Running {
|
|
77
|
+
id: number;
|
|
78
|
+
sequence: string;
|
|
79
|
+
/** The step it is at: the one it waits on, while it waits */
|
|
80
|
+
step: number;
|
|
81
|
+
data: unknown;
|
|
82
|
+
/** The timer it waits for, on a `wait` step */
|
|
83
|
+
timer?: number;
|
|
84
|
+
}
|
|
85
|
+
export declare const running: import("./components").Component<{
|
|
86
|
+
next: number;
|
|
87
|
+
list: Running[];
|
|
88
|
+
}, {
|
|
89
|
+
next: number;
|
|
90
|
+
list: Running[];
|
|
91
|
+
}>;
|
|
92
|
+
/** The sequences running in the state of a save, by the id of their definition: what a game must still have to load it */
|
|
93
|
+
export declare const runningSequences: (state: Record<string, unknown>) => string[];
|
|
94
|
+
/** The engine's timers, which every world has next to its game's */
|
|
95
|
+
export declare const coreTimers: TimerDef[];
|
|
96
|
+
/**
|
|
97
|
+
* The sequences of a world
|
|
98
|
+
*
|
|
99
|
+
* @beta
|
|
100
|
+
*/
|
|
101
|
+
export declare class Sequences {
|
|
102
|
+
private readonly world;
|
|
103
|
+
private readonly defs;
|
|
104
|
+
constructor(world: World, defs: readonly SequenceDef[]);
|
|
105
|
+
/**
|
|
106
|
+
* Listeners for the events the sequences of a game wait for, one for each event: the world subscribes them with
|
|
107
|
+
* the game's own
|
|
108
|
+
*/
|
|
109
|
+
static listenersFor(defs: readonly SequenceDef[]): ListenerDef[];
|
|
110
|
+
/** Starts a sequence: its first steps run at once, up to the first that waits. Returns its id, for `stop` */
|
|
111
|
+
start<D>(sequence: SequenceDef<D>, ...data: D extends undefined ? [] : [D]): number;
|
|
112
|
+
/** Stops a sequence where it is. Whether it was running */
|
|
113
|
+
stop(id: number): boolean;
|
|
114
|
+
/** Whether a sequence is still running */
|
|
115
|
+
running(id: number): boolean;
|
|
116
|
+
/** Cuts the `wait` a sequence is on short, and takes it on at once: a line of dialog skipped. Whether it was waiting */
|
|
117
|
+
hurry(id: number): boolean;
|
|
118
|
+
/** Takes a sequence whose `wait` is over on. For the engine's timer */
|
|
119
|
+
resume(id: number): void;
|
|
120
|
+
/** An event that sequences may wait for went off. For the engine's listeners */
|
|
121
|
+
heard(event: string, payload: unknown): void;
|
|
122
|
+
/** Asks the sequences waiting until something holds whether it does. The `sequences` system does, every tick */
|
|
123
|
+
update(): void;
|
|
124
|
+
/** Runs the steps from where the sequence is, up to the next one that waits, or the end */
|
|
125
|
+
private advance;
|
|
126
|
+
private stepOf;
|
|
127
|
+
private defOf;
|
|
128
|
+
private state;
|
|
129
|
+
}
|
|
130
|
+
/** Asks the sequences that wait until something holds, at the end of every tick */
|
|
131
|
+
export declare const sequenceSystem: System;
|
|
132
|
+
export {};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Where one who joins a server's game goes (`Doorman`): their seat again, a free seat, a seat the game decides
|
|
3
|
+
* (`GameServerOptions.seat`), watching, or away with why (design review E12). It decides and says so; the server seats,
|
|
4
|
+
* tells and closes
|
|
5
|
+
*/
|
|
6
|
+
import { type Logger } from '#engine/log';
|
|
7
|
+
import type { ServerSeat } from '#engine/game';
|
|
8
|
+
import type { GameServerOptions } from './gameServer';
|
|
9
|
+
/** A join, its fields checked */
|
|
10
|
+
export type Join = Extract<LobbyPlayerMessage, {
|
|
11
|
+
type: 'join';
|
|
12
|
+
}>;
|
|
13
|
+
/** What the doorman reads of the server it keeps the door of */
|
|
14
|
+
export interface DoorContext {
|
|
15
|
+
readonly phase: 'lobby' | 'game' | 'ended';
|
|
16
|
+
readonly seats: readonly Seat[];
|
|
17
|
+
readonly draining: boolean;
|
|
18
|
+
readonly options: Pick<GameServerOptions, 'seat' | 'watch'>;
|
|
19
|
+
readonly logger: Logger;
|
|
20
|
+
publicSeat(seat: Seat): ServerSeat;
|
|
21
|
+
}
|