Reference · Rolls and exact odds
Rolltype
One throw of the dice: what was asked for, every die thrown, and the total.
Import it
import type { Roll } from "@johnmorrisdotca/korokoro";
Definition
type Roll = {
id: string;
spec: RollSpec;
faces: number[];
kept: boolean[];
total: number;
at: number;
seed: string | null;
dice?: DieRoll[];
held?: boolean[];
loaded?: true;
set?: {
id: string;
index: number;
of: number;
};
};
Members
| Name | Type | Description |
|---|---|---|
id | string | Unique within one history. |
spec | RollSpec | |
faces | number[] | Every die's face, in the order thrown: rerolled dice and the dice an explosion added are among them. |
kept | boolean[] | Which faces count: all of them unless some are dropped or rerolled. |
total | number | The kept faces added up, plus the bonus. |
at | number | Epoch milliseconds. |
seed | string | null | The seed this roll came from, when it is reproducible. |
dice (optional) | DieRoll[] | undefined | What happened to each die, one entry per face. Every roll this package makes has it; |
held (optional) | boolean[] | undefined | On a roll that held some dice from the roll before: which faces were held and not thrown again. Left out of an ordinary roll. |
loaded (optional) | true | undefined | True on a roll of loaded dice, and left out of every other: a loaded roll always says so. |
set (optional) | { id: string; index: number; of: number; } | undefined | On a roll thrown as one of a set: which set, which roll of it from 0, and how many there are. Left out of a roll thrown on its own. |
Examples
import type { Roll } from "@johnmorrisdotca/korokoro";
import { DEFAULT_SPEC, rollFrom } from "@johnmorrisdotca/korokoro";
const value: Roll = rollFrom(DEFAULT_SPEC, [2, 5], "saved", 0, null)!;
console.log(value.total);7What it prints (run when this page was built)