Reference · Rolls and exact odds
normalizeSpecfunction
A spec brought into range, so a hand-typed or stored one can never roll
eleven dice, five kinds or a die with no faces. A part that cannot be kept
is left out, never guessed at; checkNotation is the strict reader, and
says which part. Two kinds that are the same dice under the same rules
become one: 2d6+3d6 is 5d6.
Import it
import { normalizeSpec } from "@johnmorrisdotca/korokoro";
Definition
function normalizeSpec(spec: Partial<RollSpec>, limits?: { maxDice?: number; }): RollSpec
Parameters
| Name | Type | Description |
|---|---|---|
spec | Partial<RollSpec> | Dice counts, sides, rules and modifier; omitted fields use the documented defaults. |
limits (optional) | { maxDice?: number; } | Optional limits for callers that allow larger plain pools. |
Returns
RollSpec
A spec brought into range, so a hand-typed or stored one can never roll eleven dice, five kinds or a die with no faces. A part that cannot be kept is left out, never guessed at; checkNotation is the strict reader, and says which part. Two kinds that are the same dice under the same rules become one: 2d6+3d6 is 5d6.
Examples
import { normalizeSpec } from "@johnmorrisdotca/korokoro";
console.log(normalizeSpec({ count: 2, sides: 6 }));{ count: 2, sides: 6, modifier: 0, keep: 'all' }What it prints (run when this page was built)