This module provides a flexible system for dice rolls and modifiers, suitable for any game that requires chance mechanics, RPG-style calculations, or random events.
- Dice Rolls: Support for multiple dice of various sides (d4, d6, d8, d10, d12, d20, etc.).
- Modifiers: Apply bonuses, penalties, or custom calculations to dice rolls.
- Result Tracking: Store detailed roll results for logging, debugging, or game logic.
- Extensible: Easily integrate custom dice types, probability distributions, and special rules.
- Robust Dice Notation Parser: Supports
[count]d[faces][+/-add][*mult]with validation, e.g.d20,2d6+3,3d8-1*1.5. - Detailed Roll Trace: Retrieve parsed data, individual die values, base total, and final modified total.
- Success Check Evaluation: Built-in success / failure / critical success / critical failure evaluation against target thresholds.
- Dice DSL + AST: expression parser with arithmetic and parenthesis, plus tabletop-style dice operators:
kh/kl— keep highest / lowest dice.!— exploding dice.r— reroll with condition, e.g.r<3,r==1,r>=6.- comparisons (
>=,<=,>,<,==) for threshold checks.
4d6kh3+21d20r<3+5>=158d6!>=30(2d8kh1 + 1d6) * 2