Reference · Rolls and exact odds
readDiceAsfunction
Read a roll the way a reading does, with the rolls before it in the same game where that matters.
Import it
import { readDiceAs } from "@johnmorrisdotca/korokoro";
Definition
function readDiceAs(reading: ReadingId, roll: Roll, before?: readonly Roll[], options?: Record<string, number>): Outcome
Parameters
| Name | Type | Description |
|---|---|---|
reading | "successes" | "faces" | "sum" | "doubles" | "robber" | "backgammon" | "sixAgain" | "cowries" | "craps" | "hazard" | "yahtzee" | "pokerDice" | "farkle" | "scores" | "bunco" | "pig" | "counts" | "shipCaptainCrew" | "shutTheBox" | "mexico" | "sicBo" | "choHan" | "chinchirorin" | "risk" | "highest" | "d20" | "fate" | "bladesPool" | "pbta" | "hitsAndGlitch" | "percentile" | "rollUnder" | "d66" | The named game reading to apply. |
roll | Roll | The completed roll to read or record. |
before (optional) | readonly Roll[] | Earlier rolls needed by a reading with a running result. |
options (optional) | Record<string, number> | Options for this call; omitted fields keep their documented defaults. |
Returns
Outcome
Read a roll the way a reading does, with the rolls before it in the same game where that matters.
Examples
import { readDiceAs } 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(readDiceAs(preset.reading, sample).outcome);hanWhat it prints (run when this page was built)