Documentation

Game logic

v2 · Stable

Scores and game end

getPlayerScores (required)

type GetPlayerScoresFn<MetaData = Record<string, unknown>> =
  (gameState: GameState<MetaData>) => Scores;

type Scores = Record<string /* playerId */, {
  publicPoints: number[];   // one entry per scoreLabel
  privatePoints: number[];  // nulled on the wire for other viewers
}>;

Keys are player ids stringified : use String(playerId) or [playerId] computed syntax. publicPoints[i] lines up with gameConfig().scoreLabels[i].

isGameOver (required)

type IsGameOverFn<MetaData = Record<string, unknown>> =
  (gameState: GameState<MetaData>, scores: Scores) => boolean;

Called after getPlayerScores. Return true to end the game.

Need a hand with this?

Join our Discord