Skip to content

GameState beta ​

Class of @v12-engine/client/common

ts
export declare class GameState

The game as far as this client knows it, rebuilt from the snapshots of its session

Members ​

constructor ​

ts
constructor(
    registry: Registry, 
    playerId: PlayerId, 
    team: number);

Constructs a new instance of the GameState class

apply ​

ts
apply(snapshot: Snapshot): StateChanges;

Takes a snapshot in: adds, updates and removes entities, missiles and players, and gives back what changed

areas ​

ts
areas: readonly AreaState[];

The areas of abilities on the ground the player is told of: zones and delayed blasts (Snapshot.areas)

corpses ​

ts
readonly corpses: Set<number>;

The ids of who left a corpse where the player sees, for as long as it lies there (see the engine's raiseDead)

debug ​

ts
debug: Snapshot['debug'];

The debug tools' switches, where the player may use them: see Snapshot.debug

entities ​

ts
readonly entities: Map<number, EntityView>;

Every entity the player knows, by id

get ​

ts
get(id: number | undefined): EntityView | undefined;

Gives the entity with this id, or undefined for an unknown id or none

hour ​

ts
hour: number | undefined;

Hour of the day, in a game with days and nights

isEnemy ​

ts
isEnemy(entity: EntityView): boolean;

Whether an entity is of an enemy of the player's: as the snapshot says, by teams or as the rules set it

isFriend ​

ts
isFriend(entity: EntityView): boolean;

Whether an entity is the player's own or an ally's

isMine ​

ts
isMine(entity: EntityView): boolean;

Whether the entity is owned by the player at this screen

items ​

ts
items: GroundItemState[];

Items on the ground that are in sight

mayCommand ​

ts
mayCommand(entity: EntityView): boolean;

Whether the player may command an entity: their own, and another's that shares control of it with them (the rules say so in its own state, shared). What selects, what the card is about, what a box takes

me ​

ts
get me(): {
        resources: Record<import("@v12-engine/engine").ResourceId, number>;
        supplyUsed: number;
        supplyCap: number;
        supplies?: Record<string, {
            used: number;
            cap: number;
        }>;
        upkeep: {
            tier: number;
            name: string;
            income: number;
        };
        upgrades: Record<string, number>;
        researching: string[];
        tech: string[];
        heroes: import("@v12-engine/engine").HeroSummary[];
        objectives: import("@v12-engine/engine").ObjectiveState[];
        timers?: import("@v12-engine/engine").ShownTimer[];
        unlocks?: Record<string, import("@v12-engine/engine").Message | null>;
        availability?: Record<string, boolean>;
    };

The player at this screen, with the numbers only they get to see

missiles ​

ts
readonly missiles: Map<number, MissileView>;

Missiles in the air, by id

outcome ​

ts
outcome: Outcome;

How the game stands for this player: playing until the rules end it

player ​

ts
player(id: PlayerId): PlayerState;

Gives the state of a player by id; throws for an id the game has not

playerId ​

ts
readonly playerId: PlayerId;

The player at this screen

players ​

ts
readonly players: Map<number, PlayerState>;

The players of the game as the last snapshot sent them, by id, in the colours the player chose

projectiles ​

ts
readonly projectiles: Map<number, ProjectileView>;

Shots in the air that hit when they arrive, by id

recolor ​

ts
recolor?: (player: PlayerState, index: number) => Rgb | undefined;

The players' colours as the player chose them (client.teamColors): a colour for a player, by their place among those who play, or nothing for the game's. Set it, then takePlayers to have it now

registry ​

ts
readonly registry: Registry;

The registry of the game, for the definitions of its units

report ​

ts
report: Record<string, unknown>;

What the game told the player about itself in the last snapshot, see Rules.report

retype ​

ts
retype(): void;

Every entity shown takes its type as the registry has it now: after the game's definitions changed while it runs (a definition changed, a new version of the game taken)

reveals ​

ts
reveals: RevealState[];

Spots someone sees for a while

score ​

ts
score: ScoreState | undefined;

The score as the last snapshot told it (Snapshot.score): the same object while it was not told again

scoreLine ​

ts
scoreLine: ScoreLineState | undefined;

The score's timeline as the last snapshot told it

takePlayers ​

ts
takePlayers(): void;

The players of the last snapshot, in the colours the player chose

team ​

ts
team: number;

The player's team, as the last snapshot says: the rules may move them to another

tick ​

ts
tick: number;

The tick of the last snapshot

version ​

ts
get version(): number;

How many snapshots have been applied: goes up whenever what the screen knows may have changed

viewer ​

ts
get viewer(): MessageViewer;

Who is reading the game's words (MessageViewer): the player at this screen, by the race they play