Reference · Rolls and exact odds
readDicefunction
What happened to each die of a roll, from its faces alone: which were rerolled, which exploded, which were dropped. Null when the faces are not ones this spec could have thrown, one too many or too few included.
Import it
import { readDice } from "@johnmorrisdotca/korokoro";
Definition
function readDice(spec: RollSpec, faces: readonly unknown[]): DieRoll[] | 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. |
Returns
DieRoll[] | null
What happened to each die of a roll, from its faces alone: which were rerolled, which exploded, which were dropped. null when the faces are not ones this spec could have thrown, one too many or too few included.
Examples
import { readDice } from "@johnmorrisdotca/korokoro";
import { normalizeSpec } from "@johnmorrisdotca/korokoro";
const spec = normalizeSpec({ count: 2, sides: 6 });
console.log(readDice(spec, [2, 5])?.map((die) => die.status));[ 'kept', 'kept' ]What it prints (run when this page was built)