dart_dice_parser 1.0.1 copy "dart_dice_parser: ^1.0.1" to clipboard
dart_dice_parser: ^1.0.1 copied to clipboard

outdated

A dart library for parsing dice notation (like "2d6+4", "3d6", or "3d10 + 2d6 - 5d4")

dart_dice_parser #

Pub Package

A library for parsing dice notation

Usage #

A simple usage example:

import 'package:dart_dice_parser/dart_dice_parser.dart';

main() {
  var diceExpression = "2d6 + 1 + 3d10";

  print("$diceExpression : ${roll(diceExpression)}");
}

int roll(String diceStr) {
    var result = DiceParser().evaluate(diceStr);

    if (result.isFailure) {
        print("Failure:");
        print('\t{expression}');
        print('\t${' ' * (result.position - 1)}^-- ${result.message}');
        return 1;
    } else {
        return result.value;
    }
}

Features and bugs #

Please file feature requests and bugs at the issue tracker.

1
likes
0
pub points
26%
popularity

Publisher

unverified uploader

A dart library for parsing dice notation (like "2d6+4", "3d6", or "3d10 + 2d6 - 5d4")

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

petitparser

More

Packages that depend on dart_dice_parser