Skip to content
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

Include dice sides in RollResult and RollResults #244

Conversation

erik-jenkins
Copy link

When creating custom outputs for the dice roller, it's necessary to tell which type of die a RollResult (or RollResults object) was generated from. This PR adds a sides property to RollResult and RollResults. This property is populated when calling the roll or rollOnce methods on the standard, fudge, and percentile dice objects. Tests have been updated for each dice object and RollResult/RollResults to make sure the correct value is returned for sides.

@GreenImp
Copy link
Collaborator

GreenImp commented Mar 5, 2022

This looks interesting. Would you mind providing a code / example of how you'd use it?

@bdc4
Copy link

bdc4 commented Mar 17, 2022

Any updates on this? I am very excitedly awaiting this feature and am checking in on it every day :)

@bdc4
Copy link

bdc4 commented Mar 17, 2022

This looks interesting. Would you mind providing a code / example of how you'd use it?

Not the original poster, but my team is working on a dice roller for a homebrew 5e site, and having the original sides would help for a couple of things:

  • displaying UI for the dice rolled with the result itself on top of the die (ie: showing a d20 icon with a "4" in the middle, roll20 style)
  • easily calculating and running logic if the min/max value was rolled AFTER output generation (using the example above, turning the die icon red/green for a critical miss/hit respectively)

I see there is logic for adding _ or * for crit miss or hit, but this is added in the output string only (the docs themselves say this is only cosmetic to the string). This logic also breaks if the input string contains any sort of +/- mods. Having the sides abstracted out would help run comparisons with the roll result.

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

Successfully merging this pull request may close these issues.

3 participants