Reference · Tiles, Mexican Train and replay
playTrainfunction
The game after that move, or null for a move that may not be made now. The game given is left untouched, and the move is added to its record.
Import it
import { playTrain } from "@johnmorrisdotca/domino";
Definition
function playTrain(game: TrainGame, move: TrainMove): TrainGame | null
Parameters
| Name | Type | Description |
|---|---|---|
game | TrainGame | The current immutable Mexican Train game or required fields of it. |
move | TrainMove | A requested native play, draw, pass or next-round action. |
Returns
TrainGame | null
The next immutable game, or null when the move is illegal in this state.
Examples
import { playTrain, startTrain, trainMoves } from "@johnmorrisdotca/domino";
const game = startTrain(9,["A","B"],42,{length:"short",doubles:"one",mexican:"any"},[false,true])!;
console.log(playTrain(game,trainMoves(game)[0])?.turn);1What it prints (run when this page was built)