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
| Name | Type | Description |
|---|---|---|
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 |
setLocale | (locale: string): void | Change the tray's language: "ja…" for Japanese, anything else for English, with |
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());