Score beta
Class of @v12-engine/engine
export declare class ScoreThe score of a world (world.score): counts what its stats are told of the world's events, takes the gauges and the timeline's points, and is what the game's code counts with, and reads, in the rules. What it keeps is the world's state (scoreData); nothing of it is kept here but what is made again from the game
Members
constructor
constructor(world: World);Constructs a new instance of the Score class
add
add(player: PlayerId, id: string, amount?: number, type?: string): void;Counts something for a player, as the stat's kind takes it (adds it up for a sum): one when no amount is given
byType
byType(player: PlayerId, id: string): Readonly<Record<string, number>>;A player's numbers of a stat kept by type, by type
counts
counts(player: PlayerId): boolean;Whether a player's numbers are kept: as the rules say, every player but the neutral ones and the creeps when they do not
get
get(player: PlayerId, id: string): number;A player's number of a stat: 0 for one never counted
lineFor
lineFor(viewer: PlayerId | undefined, final: boolean): ScoreLineState | undefined;What viewer is told of the timeline (Snapshot.scoreLine): nothing without one
lineVersion
lineVersion: number;Goes up with every point of the timeline
listen
listen(): void;Hears the events the stats are counted from: again when the game takes a new version (reloadGame)
on
get on(): boolean;Whether the game counts anything
players
players(): PlayerId[];The players whose numbers are kept, by id
rules
get rules(): ResolvedScore | null;The game's score, as its rules say: none for a game that counts nothing
sample
sample(point?: boolean): void;Reads the gauges, and on a point of the timeline (or point) takes a point. Run once a second by the score's system
set
set(player: PlayerId, id: string, value: number, type?: string): void;Sets a player's number, whatever the stat's kind
stateFor
stateFor(viewer: PlayerId | undefined, final: boolean): ScoreState | undefined;What viewer is told of the numbers (Snapshot.score): nothing for a game that counts none, or a viewer told of no one
stats
stats(): readonly ScoreStatDef[];The stats, in order
team
team(team: number, id: string): number;A team's number of a stat: its players' added up, or the most or the least of them for max and min
tells
tells(viewer: PlayerId | undefined, player: PlayerId, final: boolean): boolean;Whether viewer (undefined for an observer) is told player's numbers now
timeline
timeline(player: PlayerId, id: string): {
ticks: readonly number[];
values: readonly number[];
};The timeline of a player's number of a stat on it: its points, at ticks
version
version: number;Goes up with every change of a number: what a session tells the screens again by