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

RollerHandletype

What mountRoller hands back: the tray, driven from code.

Import it

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

Definition

type RollerHandle = {
    roll(): void;
    history(): readonly Roll[];
    setSpec(spec: Partial<RollSpec>): void;
    setLocale(locale: string): void;
    setCloth(cloth: Cloth): void;
    setOnePip(colour: "red" | "black"): void;
    destroy(): void;
};

Members

NameTypeDescription
roll(): void

Throw the dice showing, as a tap on the felt does.

history(): readonly Roll[]

Every roll kept so far, oldest first.

setSpec(spec: Partial<RollSpec>): void

Change part of the dice, or all of them: a spec with its count, sides, bonus and keep all given, as parseNotation returns, replaces the lot.

setLocale(locale: string): void

Change the tray's language: "ja…" for Japanese, anything else for English, with strings still laid over it.

setCloth(cloth: Cloth): void

Lay the felt in another cloth, at once, keeping every die and roll: "green", "blue", "red", "black" or "wood".

setOnePip(colour: "red" | "black"): void

Change the colour of a d6's one pip at once: "red" or "black".

destroy(): void

Take the tray out of the page and stop its timers and its sound.

Examples

import type { RollerHandle } from "@johnmorrisdotca/korokoro";
import { mountRoller } from "@johnmorrisdotca/korokoro";
const value: RollerHandle = mountRoller(document.createElement("div"), { sound: false, storage: null });
console.log(value.history());

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