Reference · Tiles, Mexican Train and replay
replayTrainfunction
A game played again from its table and its moves: what reading a kept game back does. Null if any move is one the rules would not have taken.
Import it
import { replayTrain } from "@johnmorrisdotca/domino";
Definition
function replayTrain(set: number, players: readonly string[], seed: number, options: TrainOptions, computers: readonly boolean[], moves: readonly TrainMove[]): TrainGame | null
Parameters
| Name | Type | Description |
|---|---|---|
set | number | The highest double of the supported set: 9, 12 or 15. |
players | readonly string[] | Player count, or names in seat order, as specified by this signature. |
seed | number | The seed for reproducible shuffles. |
options | TrainOptions | Native sound-player choices or Mexican Train house rules specified by the signature. |
computers | readonly boolean[] | Which seats are computer-controlled, in player order. |
moves | readonly TrainMove[] | Recorded native moves in chronological order. |
Returns
TrainGame | null
A game played again from its table and its moves: what reading a kept game back does. null if any move is one the rules would not have taken.
Examples
import { movesOf, playTrain, replayTrain, startTrain, trainMoves } from "@johnmorrisdotca/domino";
const game = startTrain(9,["A","B"],42,{length:"short",doubles:"one",mexican:"any"},[false,true])!;
const moved = playTrain(game,trainMoves(game)[0])!;
console.log(replayTrain(game.set,game.players,game.seed,game.options,game.computers,movesOf(moved))?.turn);1What it prints (run when this page was built)