-
Notifications
You must be signed in to change notification settings - Fork 2
roll outcome uses RolledDie object instead of simple ints #6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
introduce new object to hold roll results. among the fixes this will enable is exploding after a sum of heterogenous die `((1d6 + 1d8)-L)!`. it'll also enable roll rendering in client applications
example output:
note that it correctly explodes the 6, adding a 1 to the results. |
Can't wait to test this! Thank you |
feels like these are distinct things, so they should be put into distinct bins. it also felt awkward to always remember when performing operations on 'results' that some of those need to be skipped due to being discarded.
Welcome to Codecov 🎉Once you merge this PR into your default branch, you're all set! Codecov will compare coverage reports and display results in all future pull requests. Thanks for integrating Codecov - We've got you covered ☂️ |
2fa23f3
to
954ad7c
Compare
Lots of activity :) So, what will be the change or perceived change after this PR? |
there's some new syntax:
but the biggest change to the API is how the results are modeled. instead of a collection of ints, it's a collection of RolledDie objects. The RolledDie objects also changed how scoring/metadata are captured into the rolls. an example roll:
or, the same result as JSON: {
"expression": "((((4d6) ! ) #cs ) #cf )",
"total": 17,
"critSuccessCount": 1,
"critFailureCount": 1,
"results": [
{
"result": 1,
"nsides": 6,
"dieType": "polyhedral",
"critFailure": true
},
{
"result": 6,
"nsides": 6,
"dieType": "polyhedral",
"critSuccess": true,
"exploded": true
},
{
"result": 3,
"nsides": 6,
"dieType": "polyhedral",
"explosion": true
},
{
"result": 2,
"nsides": 6,
"dieType": "polyhedral"
},
{
"result": 5,
"nsides": 6,
"dieType": "polyhedral"
}
],
"detailedResults": {
"expression": "((((4d6) ! ) #cs ) #cf )",
"opType": "count",
"results": [
{
"result": 1,
"nsides": 6,
"dieType": "polyhedral",
"critFailure": true
},
{
"result": 6,
"nsides": 6,
"dieType": "polyhedral",
"critSuccess": true,
"exploded": true
},
{
"result": 3,
"nsides": 6,
"dieType": "polyhedral",
"explosion": true
},
{
"result": 2,
"nsides": 6,
"dieType": "polyhedral"
},
{
"result": 5,
"nsides": 6,
"dieType": "polyhedral"
}
],
"left": {
"expression": "(((4d6) ! ) #cs )",
"opType": "count",
"results": [
{
"result": 6,
"nsides": 6,
"dieType": "polyhedral",
"critSuccess": true,
"exploded": true
},
{
"result": 3,
"nsides": 6,
"dieType": "polyhedral",
"explosion": true
},
{
"result": 2,
"nsides": 6,
"dieType": "polyhedral"
},
{
"result": 1,
"nsides": 6,
"dieType": "polyhedral"
},
{
"result": 5,
"nsides": 6,
"dieType": "polyhedral"
}
],
"left": {
"expression": "((4d6) ! )",
"opType": "explode",
"results": [
{
"result": 6,
"nsides": 6,
"dieType": "polyhedral",
"exploded": true
},
{
"result": 3,
"nsides": 6,
"dieType": "polyhedral",
"explosion": true
},
{
"result": 2,
"nsides": 6,
"dieType": "polyhedral"
},
{
"result": 1,
"nsides": 6,
"dieType": "polyhedral"
},
{
"result": 5,
"nsides": 6,
"dieType": "polyhedral"
}
],
"left": {
"expression": "(4d6)",
"opType": "rollDice",
"results": [
{
"result": 6,
"nsides": 6,
"dieType": "polyhedral"
},
{
"result": 2,
"nsides": 6,
"dieType": "polyhedral"
},
{
"result": 1,
"nsides": 6,
"dieType": "polyhedral"
},
{
"result": 5,
"nsides": 6,
"dieType": "polyhedral"
}
],
"total": 14
},
"total": 17
},
"total": 17,
"critSuccessCount": 1
},
"total": 17,
"critSuccessCount": 1,
"critFailureCount": 1
}
}
Each RolledDie should have enough information that you can render the die and result and metadata nicely. {
"result": 6,
"nsides": 6,
"dieType": "polyhedral",
"critSuccess": true,
"exploded": true
},
{
"result": 3,
"nsides": 6,
"dieType": "polyhedral",
"explosion": true
},
from that you could draw two 6-sided die, one showing a 6 and another a 3. |
support curly brace syntax for totals
dep conflicts w/ flutter SDK upon upgrading to petitparser 7.0.0.
previously, a RollResult held a simple list of Integers are the result of a roll. There were various issues with this. Among them was inability to handle explosion after combining results of different nsides. e.g. for savage worlds roll of
((1d6+1d8)-L)!
now, each die roll outcome is represented by a RolledDie object -- this carries with it the number of sides of the die, as well as metadata/scoring.
fixes #5