dice-roller / rpg-dice-roller

An advanced JS based dice roller that can roll various types of dice and modifiers, along with mathematical equations.
https://dice-roller.github.io/documentation
MIT License
241 stars 57 forks source link

multiple-result rolls #205

Open draco963 opened 3 years ago

draco963 commented 3 years ago

Hello,

A common roll in TTRPGs is to re-roll twice on a given result, and also, to roll multiple dice and want the individual results of each die roll.

e.g.: roll 1d8, if 8, then roll 2d8 and keep each result. Thus: roll:1d8, [8], automatically reroll:2d8: [6] and [5] and roll 4d4+1, wanting each result of the four dice. Thus: roll:4d4+1, [4+1], [2+1], [4+1], [1+1]: 5, 3, 5, 2

Also, would it be possible to set the result pop-up to be a a different colour on crit success and crit fail? The ** and __ aren't being noticed by my players.

Thank you so much for this script!

GreenImp commented 3 years ago

Hi @draco963

So there's three things here:

Re-roll multiple times

roll 1d8, if 8, then roll 2d8 and keep each result. Thus: roll:1d8, [8], automatically re- roll:2d8: [6] and [5]

Q1. Would this keep the initial d8, or would the first roll be dropped?

For example, If I roll 1d8: [8], then re-roll twice and get [6, 5], would the final result be:

[8, 6, 5] = 19 // keeping all three rolls

Or

[6, 5] = 11 // dropping the initial roll of 8

Q2. If any of the secondary rolls also roll the matching value, do they also explode and, if so, should they explode twice?

For example, If I roll 1d8: [8], I re-roll twice and get [8, 6]. Do I then re-roll the second 8, and so on as long as an 8 is rolled?

Q3. If the initial roll is for more than 1 die, do any initial rolls of an 8 cause a re-roll, or just the first?

3d8: [8, 4, 8] // Do I re-roll 4 times - twice for each roll of an 8?

Addition to individual roll results

roll 4d4+1, wanting each result of the four dice. Thus: roll:4d4+1, [4+1], [2+1], [4+1], [1+1]: 5, 3, 5, 2

I think this is very similar to what's been implemented here (But not released yet): https://github.com/GreenImp/rpg-dice-roller/issues/198#issuecomment-717883609 That introduced a Multiply modifier, which will multiply each individual row by a given factor (Rather than the total value):

5d10mul2: [7, 10*, 4, 6, 10*] = 57 // The max value on the die (10) is multiplied by 2

You can also specify a compare point, to change which values will be multiplied:

5d10mul2>0: [7*, 10*, 4*, 6*, 10*] = 74 // Any roll over 0, which is all rolls, are multiplied by 2

I suppose that the same logic could be applied to an "addition" modifier, which could be used something like:

4d4add1>0: [4+, 2+, 4+, 1+] = 15

Would that do the job?

Colours for critical success / failure

would it be possible to set the result pop-up to be a a different colour on crit success and crit fail?

This isn't really possible, and never will be, with the base library. When notation is parsed, and rolled, it returns various objects that detail the results. These objects provide a very basic text output (When cast to a string) to describe themselves. These are the roll results that you see. It's purposefully designed to be basic text, with no HTML etc. so that it can be used in various different places (Including places that don't support HTML). The idea is that the library can be used as a backbone for GUIs to be built on top of. So, if you need colours, or different formatting, this would have to be built on top of this library.

It is possible to do, using the returned objects, rather than casting them to a string. However, it's probably a bit fiddly as well. There is a ticket open, #132 , which would make this process a lot easier. Although it's quite a big task to complete, and I'm not sure when I'll get the chance to work on it (Pull requests are always appreciated!).

So, in short, if you do need different styles, you'll have to build your own UI wrapper for the library.

draco963 commented 3 years ago

Q1: the double re-roll drops the initial result of 8. However, it also is not added together; it is a double result. So:

Roll:1d8 = [8]

re-rolls 6,3 = [6] and [3]

Q2: for the example I gave, either exploding the 8 a second generation or actually rolling (in the background) 1d7 would ideally both be options that the user could select. So:

Option 1:

Roll:1d8 = [8]

re-rolls 6,8 = [6] and [exploding re-roll]

re-rolls 1,3 = [6] and [1] and [3]

Option 2:

Roll:1d8 = [8]

re-rolls 6,8 = [6] and [8 not allowed on re-roll]

re-rolls 1 = [6] and [1]

Ideally, both a penetrating explosion and an invalid 2nd roll would be possible, as there are spells that use both schema.

Q3: Oh, I hadn't thought of this... I'm not aware of any spells that use more than one die on the initial roll... I think maybe this situation can be ignored?

For the "individual roll results," take, for example, a spell like Magic Missile (emphasis mine):

"A missile of magical energy strikes your target, dealing 1d4+1 points of damage. For every two caster levels beyond 1st, you gain an additional missile — two at 3rd level, three at 5th, etc. If you shoot multiple missiles, you can have them strike a single creature or several creatures."

So, as you can see, the need is not for a grand total of all the dice rolled +1 for each dice, but rather, individual results for each dice rolled. Because each missile may target a different creature, we want individual results. Thus:

1d4+1ea = [4]

2d4+1ea = [4] and [5]

3d4+1ea = [3] and [2] and [5]

4d4+1ea = [2] and [5] and [4] and [5]

etc...

I know it's a super minor thing, but I also know users in general. Lots of players of D&D (and other TTRPGs) don't actually know how to read or use the dice properly, so, anything the DM can do to limit misunderstandings saves a lot of time and frustration.

And the colour bit will be waaay beyond my programming skills, lol. I'd be happy to help, I would, but I don't think I'd be of any use!

Thank you for getting back to me!

GreenImp commented 3 years ago

Thanks for the feedback. I've added some "tasks" to the issue description for sorting out the ability to roll multiple dice on each explode / re-roll, which should cover the first bit.

In terms of the "individual roll results"; am I understanding correctly that what you're actually wanting is for the dice roller to return multiple values as the result? So, using the magic missile example, if they have 3 magic missiles, you would do something like:

// rolling 1d4 for each missile
3d4+1: [3 + 1, 4 + 1, 1 + 1] = [4, 5, 2]

And then the user would choose which missile / damage value to hit each opponent with.

The library is really only designed to return a single result value, and it always totals the rolls.

You could roll the missiles separately:

1d4+1: [3]+1 = 4
1d4+1: [4]+1 = 5
1d4+1: [1]+1 = 2

If you're using the DiceRoller object, rather than the DiceRoll, you would also have all of the roles stored in the log:

const roller = new DiceRoller();

const rolls = roller.roll('1d4+1', '1d4+1', '1d4+1');

With that, rolls would be an array with three DiceRoll objects (One for each notation parsed), and you can access their roll values with something like:

rolls.foreach((roll) => {
    console.log(roll.total);
});
GreenImp commented 3 years ago

@draco963 I've been thinking about the functionality to re-roll multiple times and could do with some feedback on possible notations for it.

The functionality is similar, but not quite the same, to what's being discussed in #207, and I'm having difficulty thinking of sensible notation that could be used for both of them, that wont conflict with each other.

I've created a discussion #224 where I'm hoping that I can get some feedback from Tillerz and yourself, to try and come up with a good solution.