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