decodePresidentfunction
Text read back into the game of President it records, by playing every move again through the rules; null for anything they cannot play out.
Import it
import { decodePresident } from "@johnmorrisdotca/toranpu/president";
Definition
function decodePresident(text: string | null): PresidentGame | null
Parameters
| Name | Type | Description |
|---|---|---|
text | string | null | The notation, encoded state or saved text to read. |
Returns
PresidentGame | null
Text read back into the game of President it records, by playing every move again through the rules; null for anything they cannot play out.
Examples
import { CARD_GAME_TABLES, newGame } from "@johnmorrisdotca/toranpu";
import { decodePresident, encodePresident } from "@johnmorrisdotca/toranpu/president";
const names = Array.from({ length: CARD_GAME_TABLES.president.defaultPlayers }, (_, seat) => `Seat ${seat + 1}`);
let game = newGame("president", { players: names, seed: 42 })!;
console.log(decodePresident(encodePresident(game))?.phase);playingWhat it prints (run when this page was built)