Skip to content

Commit

Permalink
6.0.1 - fix lint warnings, correct readme language
Browse files Browse the repository at this point in the history
  • Loading branch information
stevesea committed Oct 4, 2023
1 parent d41e59f commit d877240
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 12 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# 6.0.1
- fix deprecation
- minor readme language changes

# 6.0.0
- dart 3.0 requirement
- upgrade deps
Expand Down
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
[![Dart](https://github.com/Adventuresmith/dart-dice-parser/actions/workflows/dart.yml/badge.svg)](https://github.com/Adventuresmith/dart-dice-parser/actions/workflows/dart.yml)
[![codecov](https://codecov.io/gh/Adventuresmith/dart-dice-parser/branch/main/graph/badge.svg?token=YG5OYN9VY1)](https://codecov.io/gh/Adventuresmith/dart-dice-parser)
[![Contributor Covenant](https://img.shields.io/badge/Contributor%20Covenant-2.1-4baaaa.svg)](CODE_OF_CONDUCT.md)
[![style: lint](https://img.shields.io/badge/style-lint-4BC0F5.svg)](https://pub.dev/packages/lint)



A dart library for parsing dice notation (e.g. "2d6+4"). Supports advantage/disadvantage, exploding die, and other variations.
Expand Down Expand Up @@ -119,7 +121,7 @@ for use cases where security doesn't matter, you may want to use Random().
* operations on dice rolls:
* counting:
* `4d6 #` -- how many results?
* For example, you might use this to count # of dice above a target. `(5d10-<6)#` -- roll 5 d10, drop any 5 or under, count results
* For example, you might use this to count # of dice above a target. `(5d10 -<6)#` -- roll 5 d10, drop any less than 6, count results
* `4d6 #>3` -- roll 4d6, count any > 3
* `4d6 #<3` -- roll 4d6, count any < 3
* `4d6 #>=5` -- roll 4d6, count any >= 5
Expand All @@ -138,7 +140,7 @@ for use cases where security doesn't matter, you may want to use Random().
* Addition of integers is the usual sum
* `4+5`
* `2d6 + 1`
* Addition of roll results combines the results (use parens to ensure the order of operations is as you expect)
* Addition of roll results combines the results (use parens to ensure the order of operations is what you desire)
* `(5d6+5d10)-L2` -- roll 5d6 and 5d10, and from aggregate results drop the lowest 2.
* `5d6+5d10-L2` -- roll 5d6 and 5d10, and from only the 5d10 results drop the lowest 2. equivalent to `5d6+(5d10-L2)`
* `*` for multiplication
Expand Down
19 changes: 10 additions & 9 deletions lib/src/parser.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,16 @@ import 'package:petitparser/petitparser.dart';

Parser<DiceExpression> parserBuilder(DiceRoller roller) {
final builder = ExpressionBuilder<DiceExpression>();
builder.group()
..primitive(
digit().star().flatten('integer expected').trim().map((v) => Value(v)),
)
..wrapper(
char('(').trim(),
char(')').trim(),
(left, value, right) => value,
);
// numbers
builder.primitive(
digit().star().flatten('integer expected').trim().map((v) => Value(v)),
);
// parens
builder.group().wrapper(
char('(').trim(),
char(')').trim(),
(left, value, right) => value,
);
// special dice handling need to have higher precedence than 'd'
builder.group()
..postfix(
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: dart_dice_parser
description: A dart library for parsing dice notation (e.g. "2d6+4"). Supports advantage/disadvantage, exploding die, and other variations.
version: 6.0.0
version: 6.0.1
homepage: https://github.com/Adventuresmith/dart-dice-parser
repository: https://github.com/Adventuresmith/dart-dice-parser

Expand Down

0 comments on commit d877240

Please sign in to comment.