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

rollFromfunction

A roll put back together from its spec and its faces: for a history read from storage and a roll read from a link. The dice, which are kept and the total are all worked out again, never trusted as given. Null when the dice could not have shown those faces.

Import it

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

Definition

function rollFrom(spec: RollSpec, faces: readonly unknown[], id: string, at: number, seed: string | null): Roll | 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.

idstring

The id recorded with the reconstructed roll.

atnumber

The recorded time in epoch milliseconds.

seedstring | null

Text that reproduces the same random sequence, or null for an unseeded stored roll.

Returns

Roll | null

A roll put back together from its spec and its faces: for a history read from storage and a roll read from a link. The dice, which are kept and the total are all worked out again, never trusted as given. null when the dice could not have shown those faces.

Examples

import { rollFrom } from "@johnmorrisdotca/korokoro";
import { normalizeSpec } from "@johnmorrisdotca/korokoro";
const spec = normalizeSpec({ count: 2, sides: 6 });
console.log(rollFrom(spec, [2, 5], "saved", 0, null)?.total);
7

What it prints (run when this page was built)

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