Reference · Rolls and exact odds
decodeDiceWarfunction
Text read back into the game it records, every move played again through the rules, so that what comes back is exactly the game those moves make. Null for anything that is not a game of Dice War, or whose moves the rules refuse.
Import it
import { decodeDiceWar } from "@johnmorrisdotca/korokoro";
Definition
function decodeDiceWar(text: string | null): DiceWarGame | null
Parameters
| Name | Type | Description |
|---|---|---|
text | string | null | Text to parse, validate or format. |
Returns
DiceWarGame | null
Text read back into the game it records, every move played again through the rules, so that what comes back is exactly the game those moves make. null for anything that is not a game of Dice War, or whose moves the rules refuse.
Examples
import { decodeDiceWar } from "@johnmorrisdotca/korokoro";
import { encodeDiceWar, startDiceWar } from "@johnmorrisdotca/korokoro";
const game = startDiceWar({ players: ["One", "Two"], computers: [true, true], goal: "rounds", to: 1, seed: "table" })!;
console.log(decodeDiceWar(encodeDiceWar(game))?.players.length);2What it prints (run when this page was built)