Reference · Rolls and exact odds
readPresetfunction
Read a roll the way a game does. before is the rolls made just before it
in the same game, oldest first, for a game that reads a roll in their
light: the point in craps, a turn's total in Pig. language is "en" or
"ja". The roll may be of other dice than the preset opens with (a pool made
larger, a bonus added): it is read all the same.
Import it
import { readPreset } from "@johnmorrisdotca/korokoro";
Definition
function readPreset(preset: Preset, thrown: Roll, before?: readonly Roll[], language?: "en" | "ja"): PresetReading
Parameters
| Name | Type | Description |
|---|---|---|
preset | Preset | The game preset whose dice and reading are used. |
thrown | Roll | The completed roll to read or announce. |
before (optional) | readonly Roll[] | Earlier rolls needed by a reading with a running result. |
language (optional) | "en" | "ja" | English or Japanese for the reading text. |
Returns
PresetReading
Read a roll the way a game does. before is the rolls made just before it in the same game, oldest first, for a game that reads a roll in their light: the point in craps, a turn's total in Pig. language is "en" or "ja". The roll may be of other dice than the preset opens with (a pool made larger, a bonus added): it is read all the same.
Examples
import { readPreset } from "@johnmorrisdotca/korokoro";
import { getPreset, normalizeSpec, rollFrom } from "@johnmorrisdotca/korokoro";
const preset = getPreset("cho-han")!;
const spec = normalizeSpec({ count: 2, sides: 6 });
const sample = rollFrom(spec, [2, 5], "saved", 0, null)!;
console.log(readPreset(preset, sample, [], "en").text);Han: 7 is oddWhat it prints (run when this page was built)