Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
d3169c4
updates for new laptop
stevesea Jun 26, 2025
f36c4b8
upgrade to dart 3.8 and petitparser 7.0.0
stevesea Jun 26, 2025
2694ed8
reformat w/ latest dart fmt
stevesea Jun 26, 2025
95f435d
RollResult's results are now list of RolledDie
stevesea Jun 27, 2025
a1a9789
split results into 'results' and 'discarded'
stevesea Jul 1, 2025
2f488ea
correct examples/simple.dart
stevesea Jul 3, 2025
bbd0c76
fix analysis error -- unused import
stevesea Jul 3, 2025
f1b2513
refactor ast into multiple files. cleanup rerolls. allow explode of …
stevesea Jul 4, 2025
352c8a7
consistent logging for rerolls. cleanup min/max
stevesea Jul 4, 2025
2f96d96
enhance dieType to know more capabilities, throw error on misconfigure
stevesea Jul 4, 2025
d7933fe
split results.dart into multiple files
stevesea Jul 4, 2025
88751ed
implement penetrating dice
stevesea Jul 5, 2025
954ad7c
add support for commas and sorting
stevesea Jul 5, 2025
893a1ca
fix analysis error
stevesea Jul 5, 2025
ab9b674
add topics to pubspec
stevesea Jul 5, 2025
aaa1a92
cleanup comments
stevesea Jul 5, 2025
5efce2b
setup pubspec Workspace and split off example/main.dart into dicecli…
stevesea Jul 6, 2025
9d9c50d
fix paths
stevesea Jul 6, 2025
8c24ae6
more github actions flailing
stevesea Jul 6, 2025
9bccc51
more github actions flailing
stevesea Jul 6, 2025
aa7ee1a
make example README.md
stevesea Jul 6, 2025
3c06d84
more gha actions
stevesea Jul 6, 2025
c9d5057
create diceui via flutter cli
stevesea Jul 6, 2025
a25b7a9
change to async roll method and allow passing in dice roller
stevesea Jul 7, 2025
15404cd
exclude diceui from analysis
stevesea Jul 7, 2025
467c4ea
rollback to petitparser 6.1.0
stevesea Jul 7, 2025
65438e8
move default fudge vals field to RolledDie
stevesea Jul 7, 2025
33e436d
bring the diceui package into the workspace again
stevesea Jul 7, 2025
2a346e9
don't bring in diceui package
stevesea Jul 7, 2025
143b958
pass dieType as param to DiceRoller
stevesea Jul 8, 2025
c748e66
minor cleanup
stevesea Jul 8, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions .github/workflows/dart.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,17 +44,17 @@ jobs:
run: dart analyze --fatal-infos .

- name: "VM Tests"
run: dart test --platform vm
run: cd packages/dart_dice_parser && dart test --platform vm
- name: "Chrome Tests"
run: dart test --platform chrome
run: cd packages/dart_dice_parser && dart test --platform chrome
- name: "Run example/simple.dart"
run: dart run --enable-asserts example/simple.dart
- name: "Run example/main.dart"
run: "dart run --enable-asserts example/main.dart -n 10 -o pretty '(3d6 + 3d6! + 3d6!!) #cs #cf #s #f'"
run: cd packages/dart_dice_parser && dart run --enable-asserts example/simple.dart
- name: "Run dicecli"
run: "dart run --enable-asserts dicecli -n 10 -o pretty '(3d6 + 3d6! + 3d6!!) #cs #cf #s #f'"
- name: "Collect coverage"
run: |
dart pub global activate coverage
dart pub global run coverage:test_with_coverage --branch-coverage
dart pub global activate coverage
cd packages/dart_dice_parser && dart pub global run coverage:test_with_coverage --branch-coverage
- name: "Upload coverage"
uses: codecov/codecov-action@v4
env:
Expand Down
9 changes: 9 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,15 @@
"request": "launch",
"type": "dart"
},
{
"name": "(3d6!! + 4d6!) -<2",
"program": "example/main.dart",
"args": [
"(3d6!! + 4d6!) -<2",
],
"request": "launch",
"type": "dart"
},
{
"name": "explode - old syntax",
"program": "example/main.dart",
Expand Down
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,5 @@
// Force all files to have a trailing newline for consistency and reduced diffs when
// adding new lines at the bottom of the file.
"files.insertFinalNewline": true,
"dart.sdkPath": "~/.local/share/mise/installs/dart/3",
}
124 changes: 106 additions & 18 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,27 +1,69 @@
# 8.0.0

## ⚠️⚠️ Breaking changes ⚠️⚠️

Roll results have changed significantly. Now, the individual die results are modeled
as a RolledDie object, rather than an integer. The RolledDie object incorporates
a lot of the metadata/scoring in pre-8.0.0 results.

Having a more elaborate result will make it easier for client applications
to render the outcome of a roll. Each RolledDie knows its result, the # of sides on the die, and
whether it was counted as a success/failure.

## 📈 Enhancements

- upgrade to dart 3.8.0
- added dependency on fast_immutable_collections
- allow compounding, exploding, and rerolls for 'odd' die (`dF, D66, and d[vals]`)
- API Changes
- change signature of roll method to be async `Future<RollResult> DiceExpression.roll()`
- on DiceExpression.create(), allow passing a `DiceRoller` implementation that returns `Stream<int>` results
- remove metadata & score from RollResult
- rather than simple list of Integers representing the output of a roll or operation, now each
die rolled is a 'RolledDie' object which has the metadata/score.
- the RollResult's results field changes from List<int> to IList<RolledDie>. RolledDie represents not just the
outcome of the roll, but also includes metadata about the type of die, nsides of the die (if polyhedral die),
and metadata about the dice expression's modification of the rolls.
- RollResult.results will include both discarded an not-discarded RolledDie.
- RollSummary.results is just not-discarded die, there's a separate RollSummary.discarded. Alternatively, look at
RollSummary.detailedResults.results to see the whole set of die that accumulated while evaluating the expression.
- new dice expression syntax:
- add 'sort' to dice syntax -- `4d6 s` (ascending) or `4d6 sd` (descending)
- allow commas to separate different dice expressions: `4d4,6d6,8d8`
- implement penetrating dice ala Hackmaster
- `1d6p` -- roll d6, if 6 is rolled explode with d6s subtracting one each time.
- `1d100p20` -- roll a d100, if 100 is rolled penetrate with d20s
- use curly braces to create a 'total' result instead of keeping each individual result.
- `{3d6}` -- if that rolled `2,4,1`, those would be discarded and replaced with a `7` for the total.

# 7.1.1

## 🛠️ Bug fixes
- fix typo in readme

- fix typo in readme

# 7.1.0

## 📈 Enhancements
- upgrade to dart 3.6.0
- add roll notation to support defining your own values. `1d[val1,val2,val3]`
For example, to roll 2 dice of primes under 20, use: `2d[2,3,5,7,11,13,17,19]`

- upgrade to dart 3.6.0
- add roll notation to support defining your own values. `1d[val1,val2,val3]`.
For example, to roll 2 dice of primes under 20, use: `2d[2,3,5,7,11,13,17,19]`

# 7.0.3

## 🛠️ Bug fixes

- Previously, `4d6 + 3d6 #s #f` would only count success/failures of the 3d6 rolls, since counting
had higher priority than the plus operation. You could workaround that with parens `(4d6 + 3d6) #s #f`
In 7.0.3 and later, the counting operations now have the lowest priority.

# 7.0.2

- remove demo code accidentally added

# 7.0.1

- remove direct dependency on `meta`

# 7.0.0
Expand All @@ -33,175 +75,219 @@ a tree of results from evaluating the dice expression. See the README for exampl
traverse the graph.

## 📈 Enhancements

- new API for registering roll listeners. see README.md
- analysis cleanup and dep upgrades

## 🛠️ Bug fixes
- propagate the roll metadata up to the top of the graph

- propagate the roll metadata up to the top of the graph

# 6.0.2

- more readme fixes
- cleanup error handling / exceptions

# 6.0.1

- fix deprecation
- minor readme language changes

# 6.0.0

- dart 3.0 requirement
- upgrade deps

# 5.1.5

- clean up example documenation in README.md

# 5.1.4

- upgrade deps (lint)

# 5.1.3

- transfer repository to Adventuresmith org

# 5.1.2

- fix error messages with extraneous `'`
- make examples in README less abstract
- add method for json encoding roll result

# 5.1.1

- add syntax for exploding/compounding/reroll once
- `4d6 !o`
- `4d6 !!o`
- `4d6 ro`
- `4d6 !o`
- `4d6 !!o`
- `4d6 ro`
- add syntax for success, failure, as well as crit success & failure.
- `4d6 #s=6`
- plain `#` counts results and transforms the expression from rolls into a count.
- but `#s`, `#f`, `#cs`, `#cf` only add metadata to the roll result, and can be chained together.
- `9d6! -= 3 #s>=5#f1#cs` -- roll 9d6 with exploding, drop any threes, count >=5 as success, 1s as failures, and 6 as critical success
- `4d6 #s=6`
- plain `#` counts results and transforms the expression from rolls into a count.
- but `#s`, `#f`, `#cs`, `#cf` only add metadata to the roll result, and can be chained together.
- `9d6! -= 3 #s>=5#f1#cs` -- roll 9d6 with exploding, drop any threes, count >=5 as success, 1s as failures, and
6 as critical success

# 5.1.0

- make RollResult aggregate _all_ results for whole AST

# 5.0.0

- add compounding dice: `5d6!!`
- add keep high/low: `2d20k`
- add reroll: `10d4 r<=2`
- allow exploding/compounding dice to have an rhs expression (>=,<=,=,<,>)
- remove `!!` as 'limited explosion' (make it compounding, like Roll20 dice notation)
- fix syntax for exploding dice (2d6!, not 2d!6).
- remove exploding method from DiceRoller -- now it's part of the AST.
- fix syntax for exploding dice (2d6!, not 2d!6).
- remove exploding method from DiceRoller -- now it's part of the AST.
- dice rolls return RollResult
- clean up redundant parser config

# 4.1.0

- cleanup examples
- add syntax for `>=` and `<=` for counts, drop, clamp
- remove redundancy in parser defintion

# 4.0.6

- allow subtraction

# 4.0.5

- remove unused dev dependency

# 4.0.4

- fix typo in unit test

# 4.0.3

- increase test coverage -- test rollN and stats.

# 4.0.1

- add github actions, remove circleci
- add codecov

# 4.0.0

- cleanup petitparser usage -- generate AST so that parsing the dice expression can be separate from rolling dice.

# 3.1.0

- remove subtraction
- clean up add/mult -- don't collapse lists to ints
- `[1,4,5] + 2` => `[1,4,5,2]`
- `[1,4,5] * 2` => `[2,8,10]`
- `[1,4,5] + 2` => `[1,4,5,2]`
- `[1,4,5] * 2` => `[2,8,10]`
- remove subtraction -- like division, too many corner cases
- clean up error handling -- throw less often, less complex if/else statements.

# 3.0.3
- update linter and fix analysis

- update linter and fix analysis

# 3.0.2

- fix circleci build

# 3.0.1

- minor analysis cleanup (dead code)

# 3.0.0

- upgrade deps & null safety
- more error handling

# 2.0.1

- downgrade petitparser

# 2.0.0

- library upgrades including sdk >2.7.0

# 1.4.2

- use unmodifiable view return types

# 1.4.1

- fix return types of stats objects

# 1.4.0

- replace use of stats library w/ implementation of welford's algorithm.
see http://alias-i.com/lingpipe/docs/api/com/aliasi/stats/OnlineNormalEstimator.html
- make DiceParser.rollN an async generator returning stream of results

# 1.3.6

- allow lowercase for `-H`, `-L`, `C>`, `C<`

# 1.3.5

- back off petitparser dependency -- back off to 2.2.1,
so that we don't have dependency on Dart 2.3.0
(current stable flutter is 2.3.0-dev)

# 1.3.4

- make code more idiomatic

# 1.3.3

- make log fields non-public

# 1.3.2

- upgrade mockito dep

# 1.3.0

- add drop equals/less-than/greater-than
- add cap/clamp
- add counting operation
- add exploding dice

# 1.2.2

- more logging and error handling cleanup

# 1.2.1

- more logging and error handling cleanup

# 1.2.0

- add dice stats to the parser
- logging & error handling cleanup

# 1.1.2

- more tests and cleanup examples

# 1.1.1

- fix typo in readme

# 1.1.0

- add drop high/low parsing

# 1.0.2

- fix readme example

# 1.0.1

- fix readme issues

# 1.0.0

- bump min dart SDK to 2.2.2
- cleanup parser code
- cleanup analysis problems
Expand All @@ -210,12 +296,15 @@ traverse the graph.
- flesh out API docs

# 0.2.2

- reformat

# 0.2.1

- upgrade some dependencies

# 0.2.0

- upgrade to dart 2

# 0.1.2
Expand All @@ -242,4 +331,3 @@ traverse the graph.
# 0.0.1

- Initial version, created by Steve Christensen

2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2022 Stephen Christensen
Copyright (c) 2025 Stephen Christensen

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
Loading