Reference · Rules, games and records
formatTurnfunction
One line of a game: a turn, with its dice and its play.
Import it
import { formatTurn } from "@johnmorrisdotca/sugoroku";
Definition
function formatTurn(side: Side, dice: readonly number[], moves: readonly Move[]): string
Parameters
| Name | Type | Description |
|---|---|---|
side | Side | The side being examined: white or black. |
dice | readonly number[] | Dice values as thrown, or a reproducible source specified by the signature. |
moves | readonly Move[] | Legal checker moves in their played order. |
Returns
string
One line of a game: a turn, with its dice and its play.
Examples
import { formatTurn, legalPlaysOf, newGame, rollOpening, settingsFor } from "@johnmorrisdotca/sugoroku";
const settings = settingsFor("backgammon",{points:5,cube:true});
const game = rollOpening(newGame(settings),[3,1]);
const play = legalPlaysOf(game)[0];
console.log(formatTurn("white",[3,1],play.moves));white 31: 24/21 24/23What it prints (run when this page was built)