GameState beta
Class of @v12-engine/client/common
export declare class GameStateThe game as far as this client knows it, rebuilt from the snapshots of its session
Members
constructor
constructor(
registry: Registry,
playerId: PlayerId,
team: number);Constructs a new instance of the GameState class
apply
apply(snapshot: Snapshot): StateChanges;Takes a snapshot in: adds, updates and removes entities, missiles and players, and gives back what changed
areas
areas: readonly AreaState[];The areas of abilities on the ground the player is told of: zones and delayed blasts (Snapshot.areas)
corpses
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
debug: Snapshot['debug'];The debug tools' switches, where the player may use them: see Snapshot.debug
entities
readonly entities: Map<number, EntityView>;Every entity the player knows, by id
get
get(id: number | undefined): EntityView | undefined;Gives the entity with this id, or undefined for an unknown id or none
hour
hour: number | undefined;Hour of the day, in a game with days and nights
isEnemy
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
isFriend(entity: EntityView): boolean;Whether an entity is the player's own or an ally's
isMine
isMine(entity: EntityView): boolean;Whether the entity is owned by the player at this screen
items
items: GroundItemState[];Items on the ground that are in sight
mayCommand
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
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
readonly missiles: Map<number, MissileView>;Missiles in the air, by id
outcome
outcome: Outcome;How the game stands for this player: playing until the rules end it
player
player(id: PlayerId): PlayerState;Gives the state of a player by id; throws for an id the game has not
playerId
readonly playerId: PlayerId;The player at this screen
players
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
readonly projectiles: Map<number, ProjectileView>;Shots in the air that hit when they arrive, by id
recolor
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
readonly registry: Registry;The registry of the game, for the definitions of its units
report
report: Record<string, unknown>;What the game told the player about itself in the last snapshot, see Rules.report
retype
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
reveals: RevealState[];Spots someone sees for a while
score
score: ScoreState | undefined;The score as the last snapshot told it (Snapshot.score): the same object while it was not told again
scoreLine
scoreLine: ScoreLineState | undefined;The score's timeline as the last snapshot told it
takePlayers
takePlayers(): void;The players of the last snapshot, in the colours the player chose
team
team: number;The player's team, as the last snapshot says: the rules may move them to another
tick
tick: number;The tick of the last snapshot
version
get version(): number;How many snapshots have been applied: goes up whenever what the screen knows may have changed
viewer
get viewer(): MessageViewer;Who is reading the game's words (MessageViewer): the player at this screen, by the race they play