Reference · Rolls and exact odds
RollSpectype
What to roll: the dice, the bonus, and the rules. A roll of one kind of die
is { count, sides, modifier, keep } and whichever optional fields it
uses. A roll of several kinds keeps its first kind there and the others in
more, so a one-kind spec is the same object it always was.
Import it
import type { RollSpec } from "@johnmorrisdotca/korokoro";
Definition
type RollSpec = DiceGroup & {
modifier: number;
more?: DiceGroup[];
times?: number;
math?: MathNode;
label?: string;
};
Members
| Name | Type | Description |
|---|---|---|
count | number | How many dice: at least 1, and no more than |
sides | Sides | The kind of die: 2 to 1000 sides, or "F" for a Fate die. |
keep | Keep | Which dice count towards the total. |
keepCount (optional) | number | undefined | How many dice |
explode (optional) | true | undefined | A die showing its highest face throws another, which may do the same. Left out when the dice do not explode. |
reroll (optional) | number | undefined | A die showing this face or lower is thrown again, once, and the new face stands: |
rerollUntil (optional) | number | undefined | A die showing this face or lower is thrown again until it shows more, up to |
rerollWhen (optional) | Compare | undefined | A die meeting this is thrown again, once: |
rerollUntilWhen (optional) | Compare | undefined | A die meeting this is thrown again until it does not, up to |
explodeWhen (optional) | Compare | undefined | With |
explodeKind (optional) | ExplodeKind | undefined | With |
floor (optional) | number | undefined | The least a die counts for: a face below it counts as it. |
ceiling (optional) | number | undefined | The most a die counts for: a face above it counts as it. |
success (optional) | Compare | undefined | The dice are counted, not added: each die meeting this is one success, and the total is how many. |
failure (optional) | Compare | undefined | With |
critical (optional) | Compare | undefined | Dice meeting this are marked as critical successes. Only a mark: the total is the same. |
fumble (optional) | Compare | undefined | Dice meeting this are marked as critical failures. Only a mark. |
sort (optional) | "ascending" | "descending" | undefined | The order the dice are shown in: |
unique (optional) | true | undefined | The dice all show different faces: each is thrown from the faces not yet showing, which comes to the same as rerolling any duplicate until there is none. |
faces (optional) | CustomFace[] | undefined | A custom die: its faces, in order, and |
weights (optional) | number[] | undefined | A loaded die: how heavily each face is weighted, from the lowest face up,
where a fair die has every face at 1. |
modifier | number | Added to the total, as in 1d20+5. |
more (optional) | DiceGroup[] | undefined | The other kinds of dice in the roll, in order. Left out when there is one kind. |
times (optional) | number | undefined | How many times |
math (optional) | MathNode | undefined | How the kinds' totals are put together, when that is not simply adding
them: |
label (optional) | string | undefined | What the roll is for, in a few words: "fire damage". Text, only ever shown as text. |
Examples
import type { RollSpec } from "@johnmorrisdotca/korokoro";
import { normalizeSpec } from "@johnmorrisdotca/korokoro";
const value: RollSpec = normalizeSpec({ count: 2, sides: 6 });
console.log(value.sides);6What it prints (run when this page was built)