import type { RollType } from "../common/types.js"; import { PMF } from "../pmf/pmf.js"; /** * Parse without throwing — for UI code that reparses on every keystroke, where * a transiently invalid expression is normal rather than exceptional. * * Also accepts a *signed* integer, which the grammar rejects: `"-3"` becomes a * delta at -3, `"+7"` one at 7. Unsigned integers need no help — `parse("7")` * already returns a delta at 7 — but a half-typed damage field is a bare signed * number often enough to be worth covering. * * The failure value is {@link PMF.empty}, which has **mass 0**, not a * distribution. Convolving it collapses the whole result to mass 0, so a caller * combining several expressions should check `mass()` (or skip empties) rather * than assume a usable PMF. Anywhere a bad expression should be surfaced instead * of absorbed, call {@link parse} and handle `DiceParseError`. * * Takes no second argument on purpose. {@link parse}'s is `n`, the substitution * value for an `n`-dice expression — not an epsilon — so forwarding one here * would silently reinterpret it: `tryParse("nd6", 1e-9)` rolled `1d6` and * reported 3.5 where the default `n` of 0 means no dice at all. * * @returns the parsed PMF, or an empty (mass 0) PMF for input that is neither a * valid expression nor an integer. */ export declare function tryParse(expression: string): PMF; /** * Rewrite an expression's attack roll to a different d20 {@link RollType}, * leaving everything else — damage, crit clause, miss clause, bonuses — * untouched. * * ```ts * withRollType("(d20 + 8 AC 16) * (1d4 + 4)", "advantage"); * // "(d20 > d20 + 8 AC 16) * (1d4 + 4)" * ``` * * **Every** `AC` group is rewritten, because one expression can hold several * attacks (`(d20 + 8 AC 16) * (1d8) + (d20 + 5 AC 16) * (1d6)`) and leaving the * later ones flat would quietly chart the wrong curve. * * A `DC` group is the *target's* saving throw, which the attacker's advantage * does not touch, so save expressions come back unchanged — as does anything * with no attack roll at all. This makes the function safe to map over a mixed * list of expressions. * * Assumes **one check per group**, which is what every well-formed attack or * save expression looks like and what `modelToExpression` emits. The grammar * will swallow a group naming two — `(d20 + 5 DC 16 + d20 + 8 AC 16)` parses, * as a single `AC` check whose roll happens to contain the save's 0/1 result — * but that is not an expression anyone means, and the roll type it should get is * undefined. Such input is rewritten on a best-effort basis rather than * diagnosed. * * A halfling-luck `h` prefix is preserved on the first die of each run, since it * describes the same roll. */ export declare function withRollType(expression: string, rollType: RollType): string; //# sourceMappingURL=rollType.d.ts.map