Skip to the content

Korokoroコロコロ

Roll mixed dice or type notation, compare exact probabilities, keep a history and replay seeded rolls.

Korokoro describes something small rolling in Japanese. About the name

Contents

Reference · Rolls and exact odds

DiceGrouptype

Some dice of one kind, with their own rules: the 2d20kh1 of 2d20kh1+1d4. The optional fields are left out of a group that does not use them.

Import it

import type { DiceGroup } from "@johnmorrisdotca/korokoro";

Definition

type DiceGroup = {
    count: number;
    sides: Sides;
    keep: Keep;
    keepCount?: number;
    explode?: true;
    reroll?: number;
    rerollUntil?: number;
    rerollWhen?: Compare;
    rerollUntilWhen?: Compare;
    explodeWhen?: Compare;
    explodeKind?: ExplodeKind;
    floor?: number;
    ceiling?: number;
    success?: Compare;
    failure?: Compare;
    critical?: Compare;
    fumble?: Compare;
    sort?: "ascending" | "descending";
    unique?: true;
    faces?: CustomFace[];
    weights?: number[];
};

Members

NameTypeDescription
countnumber

How many dice: at least 1, and no more than MAX_DICE over the whole roll.

sidesSides

The kind of die: 2 to 1000 sides, or "F" for a Fate die.

keepKeep

Which dice count towards the total.

keepCount (optional)number | undefined

How many dice highest or lowest keep. Left out when it is one.

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: ro< in notation. Left out when nothing is rerolled once.

rerollUntil (optional)number | undefined

A die showing this face or lower is thrown again until it shows more, up to MAX_REROLLS times: r< in notation. Left out when nothing is rerolled until clear.

rerollWhen (optional)Compare | undefined

A die meeting this is thrown again, once: ro>=5, ro=3. For the comparisons reroll cannot say; left out otherwise.

rerollUntilWhen (optional)Compare | undefined

A die meeting this is thrown again until it does not, up to MAX_REROLLS times: r=3, r>=5. For the comparisons rerollUntil cannot say; left out otherwise.

explodeWhen (optional)Compare | undefined

With explode: the faces that explode, when they are not just the highest. !>=5 in notation. Left out when only the highest face explodes.

explodeKind (optional)ExplodeKind | undefined

With explode: how the extra dice are added up. Left out for ordinary explosions.

floor (optional)number | undefined

The least a die counts for: a face below it counts as it. min2 in notation.

ceiling (optional)number | undefined

The most a die counts for: a face above it counts as it. max5 in notation.

success (optional)Compare | undefined

The dice are counted, not added: each die meeting this is one success, and the total is how many. >=8 in notation.

failure (optional)Compare | undefined

With success: each die meeting this takes one success away. f=1 in notation.

critical (optional)Compare | undefined

Dice meeting this are marked as critical successes. Only a mark: the total is the same. cs>=19 in notation.

fumble (optional)Compare | undefined

Dice meeting this are marked as critical failures. Only a mark. cf<=2 in notation.

sort (optional)"ascending" | "descending" | undefined

The order the dice are shown in: sa ascending, sd descending. The order thrown is kept in the roll.

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. u in notation.

faces (optional)CustomFace[] | undefined

A custom die: its faces, in order, and sides is how many there are. A face written twice comes up twice as often. A roll records a custom face by its place, from 1. Left out of a numbered die and a Fate die.

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. [1, 1, 1, 1, 1, 3] is a d6 that shows its 6 three times in eight. Left out of a fair die, and never present by accident: isFair is false for any roll that has it.

Examples

import type { DiceGroup } from "@johnmorrisdotca/korokoro";
const value: DiceGroup = { count: 2, sides: 6, keep: "all" };
console.log(value.count);
2

What it prints (run when this page was built)

View sourceEdit on GitHubMade from the source of @johnmorrisdotca/korokoro 1.16.0.