Skip to the content

Korokoroコロコロ

Roll mixed dice or type notation, compare exact probabilities, keep a history and replay seeded rolls.

Korokoro describes something small rolling in Japanese. About the name

Contents

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

NameTypeDescription
textstring | 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);
2

What it prints (run when this page was built)

View sourceEdit on GitHubMade from the source of @johnmorrisdotca/korokoro 1.16.0.