Reference · Rolls and exact odds
Outcometype
How a roll is read in a game. A reading is one of a small, fixed set of
named functions, so that a new game is a line of data and rarely new code.
Each takes the dice, kind by kind, and says what they come to in the game's
own terms: an outcome with a stable name, and the figures that go with it.
The words for each outcome, in English and Japanese, are in words.ts.
Readings are small and particular on purpose. They do not run a game (turn order, scores across rounds): they read one roll, with the rolls just before it where a game needs them, as craps does for its point.
Import it
import type { Outcome } from "@johnmorrisdotca/korokoro";
Definition
type Outcome = {
outcome: string;
values: Record<string, string | number>;
tone: "good" | "bad" | "plain";
};
Members
| Name | Type | Description |
|---|---|---|
outcome | string | The outcome's name within its reading: "natural", "point", "yahtzee". |
values | Record<string, string | number> | The figures the outcome's words are filled in with. |
tone | "good" | "bad" | "plain" | Whether it is good news, bad news or neither, for a tray to colour. |
Examples
import type { Outcome } from "@johnmorrisdotca/korokoro";
import { getPreset, presetSpec, roll, seededSource, readDiceAs } from "@johnmorrisdotca/korokoro";
const value: Outcome = readDiceAs(getPreset("cho-han")!.reading, roll(presetSpec(getPreset("cho-han")!), seededSource("docs"), 0));
console.log(value.outcome);hanWhat it prints (run when this page was built)