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

ExportedRolltype

One roll as the JSON export writes it.

Import it

import type { ExportedRoll } from "@johnmorrisdotca/korokoro";

Definition

type ExportedRoll = {
    id: string;
    notation: string;
    spec: Roll["spec"];
    faces: number[];
    kept: boolean[];
    total: number;
    successes?: true;
    words?: string[];
    at: number;
    time: string;
    seed: string | null;
    held?: boolean[];
    loaded?: true;
    set?: Roll["set"];
    dice: DieRoll[];
};

Members

NameTypeDescription
idstring
notationstring

The dice as notation, its label included.

specRollSpec

The same dice as a spec: what fromJSON reads.

facesnumber[]

Every die thrown, in the order thrown.

keptboolean[]

Which faces count.

totalnumber
successes (optional)true | undefined

True when the total is a count of successes. Left out otherwise.

words (optional)string[] | undefined

What the faces say, on a roll of custom dice. Left out otherwise.

atnumber

Epoch milliseconds, and the same moment as ISO 8601 in UTC.

timestring
seedstring | null
held (optional)boolean[] | undefined
loaded (optional)true | undefined
set (optional){ id: string; index: number; of: number; } | undefined
diceDieRoll[]

What became of each die.

Examples

import type { ExportedRoll } from "@johnmorrisdotca/korokoro";
import { DEFAULT_SPEC, rollFrom, exportedRoll } from "@johnmorrisdotca/korokoro";
const value: ExportedRoll = exportedRoll(rollFrom(DEFAULT_SPEC, [2, 5], "saved", 0, null)!);
console.log(value.total);
7

What it prints (run when this page was built)

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