encodeWarfunction
A game of War as text: its table, its seed and its moves, never a pile.
Import it
import { encodeWar } from "@johnmorrisdotca/toranpu/war";
Definition
function encodeWar(game: WarGame): string
Parameters
| Name | Type | Description |
|---|---|---|
game | WarGame | The current native game; applying a move returns a new state. |
Returns
string
A game of War as text: its table, its seed and its moves, never a pile.
Examples
import { CARD_GAME_TABLES, newGame } from "@johnmorrisdotca/toranpu";
import { 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(encodeWar(game));{"v":1,"g":"war","size":100,"players":["Seat 1","Seat 2"],"computers":[false,false],"seed":42,"moves":[]}What it prints (run when this page was built)