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