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

readDicefunction

What happened to each die of a roll, from its faces alone: which were rerolled, which exploded, which were dropped. Null when the faces are not ones this spec could have thrown, one too many or too few included.

Import it

import { readDice } from "@johnmorrisdotca/korokoro";

Definition

function readDice(spec: RollSpec, faces: readonly unknown[]): DieRoll[] | null

Parameters

NameTypeDescription
specRollSpec

Dice counts, sides, rules and modifier; omitted fields use the documented defaults.

facesreadonly unknown[]

Physical face values, in the order thrown.

Returns

DieRoll[] | null

What happened to each die of a roll, from its faces alone: which were rerolled, which exploded, which were dropped. null when the faces are not ones this spec could have thrown, one too many or too few included.

Examples

import { readDice } from "@johnmorrisdotca/korokoro";
import { normalizeSpec } from "@johnmorrisdotca/korokoro";
const spec = normalizeSpec({ count: 2, sides: 6 });
console.log(readDice(spec, [2, 5])?.map((die) => die.status));
[ 'kept', 'kept' ]

What it prints (run when this page was built)

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