Skip to content
This repository has been archived by the owner on Dec 8, 2022. It is now read-only.

Exploding dice #2

Closed
9 of 11 tasks
ArtemGr opened this issue Aug 15, 2016 · 6 comments
Closed
9 of 11 tasks

Exploding dice #2

ArtemGr opened this issue Aug 15, 2016 · 6 comments

Comments

@ArtemGr
Copy link
Owner

ArtemGr commented Aug 15, 2016

2d6e -- explode indefinitely
2d6e10 -- explode up to ten times
=> Will probably stick with the roll20 syntax: https://wiki.roll20.net/Dice_Reference#Exploding_Dice

cf. https://www.reddit.com/r/discordapp/comments/4vfbqi/looking_for_a_dice_bot/d6f4so8

  • Pick a parser. Nom or...
  • Install the selected library.
  • Refactor how the TargetNumber works. First, in the parser, separate the basic dice (4d6) specification from the target number specification. Next, roll the basic dice right there in the parser and remember the rolls. Now, when the parser finds the target number specification - it should apply it to the existing rolls, marking some of them as failed. The goal here is to a) make the position matter, e.g. "4d6!6>5" (explode then apply DC) is different from "4d6>5!6" (apply DC then explode), b) simplify the code (TargetNumber becomes a Dice function).
  • Implement something (a function? a nom macro?) to find and replace all the matches of a nom parser.
  • Instead of passing the entire dice expression as a string to the dice evaluation engine - pass a representative structure from the parser.
  • Refactor dice replacement into one-liner.
  • Implement the exploding dice parsing.
  • Implement the exploding dice calculation.
  • Tweak the output formatting.
  • Unit test the parser?
  • README update.
@JustLikeAMetaphor
Copy link

Hey ArtemGr!

Wanted to report a minor issue: Consecutive dice do not explode. For example, if Sidekick rolls an exploding 10, and the added dice also rolls a 10, the second 10 does not explode.

@ArtemGr
Copy link
Owner Author

ArtemGr commented Sep 10, 2016

You're right, I've overlooked this.

Filed a bug: #7

Thanks for reporting!

@ArtemGr
Copy link
Owner Author

ArtemGr commented Sep 15, 2016

@JustLikeAMetaphor, fixed!
You can test it with "/r 1d1!".

@JustLikeAMetaphor
Copy link

@ArtemGr Just did, works like a charm!

Thank you so much, my nWoD group will love this

@ArtemGr
Copy link
Owner Author

ArtemGr commented Sep 15, 2016

You're welcome )

@ArtemGr
Copy link
Owner Author

ArtemGr commented Sep 15, 2016

@JustLikeAMetaphor
I'm confused with this passage in Wikipedia:

"If another 10 is rolled, this step is repeated until anything but a 10 is rolled"

https://en.wikipedia.org/wiki/World_of_Darkness#New_rule_system

Does it mean that if we a) roll 10, b) explode into another 10, then c) we should keep exploding until we get a 10?

e.g. "1d10" might give us "10, 10, 2, 3, 4, 5, 6, 7, 8, 9, 1, 10" = five successes (10, 10, 8, 9, 10) ?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants