Reference · Rolls and exact odds
formatNotationfunction
Notation for a spec: the inverse of parseNotation. One spelling for each
roll: each kind of dice as its count and sides, !, the reroll as r< or
ro<, what is kept as kh or kl; the kinds joined by +; then the
bonus. So 4d6dl1 is written back as 4d6kh3.
Import it
import { formatNotation } from "@johnmorrisdotca/korokoro";
Definition
function formatNotation(spec: RollSpec): string
Parameters
| Name | Type | Description |
|---|---|---|
spec | RollSpec | Dice counts, sides, rules and modifier; omitted fields use the documented defaults. |
Returns
string
Notation for a spec: the inverse of parseNotation. One spelling for each roll: each kind of dice as its count and sides, !, the reroll as r< or ro<, what is kept as kh or kl; the kinds joined by +; then the bonus. So 4d6dl1 is written back as 4d6kh3.
Examples
import { formatNotation } from "@johnmorrisdotca/korokoro";
import { parseNotation } from "@johnmorrisdotca/korokoro";
console.log(formatNotation(parseNotation("2d20kh1+5")!));2d20kh1+5What it prints (run when this page was built)