encodeCribbagefunction
A game of Cribbage as text: its table, its seed and its moves, never a hand.
Import it
import { encodeCribbage } from "@johnmorrisdotca/toranpu/cribbage";
Definition
function encodeCribbage(game: CribbageGame): string
Parameters
| Name | Type | Description |
|---|---|---|
game | CribbageGame | The current native game; applying a move returns a new state. |
Returns
string
A game of Cribbage as text: its table, its seed and its moves, never a hand.
Examples
import { CARD_GAME_TABLES, newGame } from "@johnmorrisdotca/toranpu";
import { encodeCribbage } from "@johnmorrisdotca/toranpu/cribbage";
const names = Array.from({ length: CARD_GAME_TABLES.cribbage.defaultPlayers }, (_, seat) => `Seat ${seat + 1}`);
let game = newGame("cribbage", { players: names, seed: 42 })!;
console.log(encodeCribbage(game));{"v":1,"g":"cribbage","size":121,"players":["Seat 1","Seat 2"],"computers":[false,false],"seed":42,"moves":[]}What it prints (run when this page was built)