Reference · Rolls and exact odds
checkMathfunction
Whether a formula can be used with kinds of dice whose totals run over these ranges: the problem, or null when there is none. It has to name each kind exactly once (so the kinds stay independent and the odds exact), come to a whole number, never divide by nothing, and stay small enough to count.
Import it
import { checkMath } from "@johnmorrisdotca/korokoro";
Definition
function checkMath(node: MathNode, ranges: readonly { min: number; max: number; }[]): MathProblem | null
Parameters
| Name | Type | Description |
|---|---|---|
node | MathNode | The arithmetic expression tree. |
ranges | readonly { min: number; max: number; }[] | The minimum and maximum for each dice group. |
Returns
MathProblem | null
Whether a formula can be used with kinds of dice whose totals run over these ranges: the problem, or null when there is none. It has to name each kind exactly once (so the kinds stay independent and the odds exact), come to a whole number, never divide by nothing, and stay small enough to count.
Examples
import { checkMath } from "@johnmorrisdotca/korokoro";
console.log(checkMath({ kind: "dice", group: 0 }, [{ min: 1, max: 6 }]));nullWhat it prints (run when this page was built)