Reference · Rules, games and records
ReplayedGametype
One game of a replayed record, finished.
Import it
import type { ReplayedGame } from "@johnmorrisdotca/sugoroku";
Definition
type ReplayedGame = {
readonly result: GameResult;
readonly turns: readonly [
number,
number
];
readonly position: Position;
};
Members
| Name | Type | Description |
|---|---|---|
result | GameResult | |
turns | readonly [number, number] | The turns each side took. |
position | Position | The position the game ended in. |
Examples
import { concede, newGame, rollOpening, settingsFor, startPosition } from "@johnmorrisdotca/sugoroku";
import type { ReplayedGame } from "@johnmorrisdotca/sugoroku";
const settings = settingsFor("backgammon",{points:5,cube:true});
const spec = settings.variant;
const position = startPosition(spec);
const game = rollOpening(newGame(settings),[3,1]);
const result = concede(game,"black","single").result!;
const value: ReplayedGame = {result,turns:[1,0],position};
console.log(value);{
result: {
winner: 'white',
how: 'concede',
kind: 'single',
multiplier: 1,
cube: 1,
points: 1
},
turns: [ 1, 0 ],
position: {
points: [ [Array], [Array] ],
bar: [ 0, 0 ],
reserve: [ 0, 0 ],
off: [ 0, 0 ]
}
}What it prints (run when this page was built)