Skip to content

Score beta ​

Class of @v12-engine/engine

ts
export declare class Score

The 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 ​

ts
constructor(world: World);

Constructs a new instance of the Score class

add ​

ts
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 ​

ts
byType(player: PlayerId, id: string): Readonly<Record<string, number>>;

A player's numbers of a stat kept by type, by type

counts ​

ts
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 ​

ts
get(player: PlayerId, id: string): number;

A player's number of a stat: 0 for one never counted

lineFor ​

ts
lineFor(viewer: PlayerId | undefined, final: boolean): ScoreLineState | undefined;

What viewer is told of the timeline (Snapshot.scoreLine): nothing without one

lineVersion ​

ts
lineVersion: number;

Goes up with every point of the timeline

listen ​

ts
listen(): void;

Hears the events the stats are counted from: again when the game takes a new version (reloadGame)

on ​

ts
get on(): boolean;

Whether the game counts anything

players ​

ts
players(): PlayerId[];

The players whose numbers are kept, by id

rules ​

ts
get rules(): ResolvedScore | null;

The game's score, as its rules say: none for a game that counts nothing

sample ​

ts
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 ​

ts
set(player: PlayerId, id: string, value: number, type?: string): void;

Sets a player's number, whatever the stat's kind

stateFor ​

ts
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 ​

ts
stats(): readonly ScoreStatDef[];

The stats, in order

team ​

ts
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 ​

ts
tells(viewer: PlayerId | undefined, player: PlayerId, final: boolean): boolean;

Whether viewer (undefined for an observer) is told player's numbers now

timeline ​

ts
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 ​

ts
version: number;

Goes up with every change of a number: what a session tells the screens again by