saif-ellafi / play-by-the-writing

Play by the Writing is a bundle of scripts for Espanso, written in python to expand SOLO RPG rulesets as you write
Apache License 2.0
24 stars 6 forks source link

Include "exploding dice" functionality #3

Closed paladiusdarkhelm closed 1 year ago

paladiusdarkhelm commented 2 years ago

The goal would be to include "exploding die(dice) functionality.

Example via java Math class would be something like "1d6eo6+1" which would mean:

  1. Roll 1d6
  2. If a 6, keep it, roll again and add the next roll no matter what number it is to that original 6
  3. Add 1 to subtotal
  4. Present grand total

Example 3d6eo6+1 would mean:

  1. Roll 3d6
  2. If a 6 is rolled on any one of them, keep it, roll again for that die and add the next roll no matter what number it is to that original 6
  3. If multiple 6s are rolled, perform the function per die and add to subtotal
  4. Add 1 to subtotal
  5. Present grand total
paladiusdarkhelm commented 2 years ago

I looked at the other author of python-dice's setup and it looks like he uses e and o for other die manipulating effects. May need to use other operands for this sort of die functionality.

saif-ellafi commented 1 year ago

Hi @paladiusdarkhelm sorry I never answered this, but this is already implemented in the library I use here. :rr1d6x. does -> 1d6x: [3] The available options are all here: https://github.com/borntyping/python-dice Let me know if there is an expression that this library does not already have we can add it here, although I prefer not to add much custom logic to the dice roller as it is it can achieve many things already.