dart_dice_parser library
A Parser for dice notation
Usage example:
const input = '2d20-L'; // D20 advantage -- roll 2d20, drop lowest
final diceExpr = DiceExpression.create(input);
for (var i = 0; i < 2; i++) {
final int result = diceExpr.roll();
stdout.writeln("$i : $result");
}
Classes
- DiceExpression
- An abstract expression that can be evaluated.
- DiceRoller
-
A dice roller for M dice of N sides (e.g.
2d6
). A roll returns a list of ints. - RollMetadata
- RollMetadata represents 'interesting' things that happens during certain operations. This will include the 'score' (if any), a list of which dice were rolled by the operation, and a list of which dice were discarded by the operation.
- RollResult
- RollResult represents the result of evaluating a particular node of the AST.
- RollScore
- RollScore represents the # of successes and failures.
- RollSummary
-
RollSummary is the final result of rolling a dice expression.
It rolls up the metadata of sub-expressions, and includes a
detailResults
if the caller wants to do something interesting to display the result graph.
Functions
-
pprint(
RollResult? rr, {String indent = ''}) → String -
rollupMetadata(
RollResult? rr) → RollMetadata