Reference · Rolls and exact odds
DieOptionstype
What a lone die is told when it is made. Everything may be left out.
Import it
import type { DieOptions } from "@johnmorrisdotca/korokoro";
Definition
type DieOptions = {
sides?: Sides;
faces?: CustomFace[];
face?: number;
rollable?: boolean;
size?: DieSize;
width?: number;
onePip?: "red" | "black";
cloth?: Cloth;
theme?: Record<`--kk-${string}`, string>;
locale?: string;
strings?: Partial<RollerStrings>;
source?: RandomSource;
animationMs?: number;
sound?: boolean;
playSound?: PlaySound;
onRoll?: (face: number) => void;
};
Members
| Name | Type | Description |
|---|---|---|
sides (optional) | Sides | undefined | The kind of die: 2 to 1000 sides, or "F" for a Fate die. 6 when left out. |
faces (optional) | CustomFace[] | undefined | A die of your own: its faces, in order, in place of numbers. |
face (optional) | number | undefined | The face showing at first, from 1 (from −1 for a Fate die). Left out, the highest face of the die, or a 6 on a d6. |
rollable (optional) | boolean | undefined | Whether a tap rolls it: true when left out. False is a die that only shows a face. |
size (optional) | DieSize | undefined |
|
width (optional) | number | undefined | Its width in pixels, in place of |
onePip (optional) | "red" | "black" | undefined | The colour of a d6's one pip: |
cloth (optional) | "green" | "blue" | "red" | "black" | "wood" | undefined | A cloth's name, for the page's own colours to follow the tray's: only the ink and the die's edge on a felt. |
theme (optional) | Record<`--kk-${string}`, string> | undefined | CSS variables for the die, such as |
locale (optional) | string | undefined | "ja…" for Japanese, anything else English. The page's own language when left out. |
strings (optional) | Partial<RollerStrings> | undefined | Words to use instead of the built-in ones. |
source (optional) | RandomSource | undefined | Where the throw comes from: |
animationMs (optional) | number | undefined | The length of the tumble in milliseconds: 600 when left out. Reduced motion always skips it. |
sound (optional) | boolean | undefined | Whether a throw makes the sound of dice. Off when left out, because a die on its own is a thing on somebody's page, and a page that has not asked for noise gets none. |
playSound (optional) | PlaySound | undefined | A sound of your own for each throw, in place of the recorded dice. Used only when |
onRoll (optional) | ((face: number) => void) | undefined | Called once the die has landed, with the face. |
Examples
import type { DieOptions } from "@johnmorrisdotca/korokoro";
const value: DieOptions = { sides: 20, face: 6, sound: false };
console.log(value.sides);20What it prints (run when this page was built)