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
| Name | Type | Description |
|---|---|---|
spec | RollSpec | Dice counts, sides, rules and modifier; omitted fields use the documented defaults. |
faces | readonly unknown[] | Physical face values, in the order thrown. |
id | string | The id recorded with the reconstructed roll. |
at | number | The recorded time in epoch milliseconds. |
seed | string | 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);7What it prints (run when this page was built)