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

multiple-result rolls #205

Open
2 tasks
draco963 opened this issue Feb 1, 2021 · 4 comments
Open
2 tasks

multiple-result rolls #205

draco963 opened this issue Feb 1, 2021 · 4 comments

Comments

@draco963
Copy link

draco963 commented Feb 1, 2021

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!

  • Allow explode modifier to roll multiple dice for each "explode"
  • Allow re-roll modifier to roll multiple dice for each re-roll
@GreenImp
Copy link
Collaborator

GreenImp commented Feb 3, 2021

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): #198 (comment)
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
Copy link
Author

draco963 commented Feb 4, 2021 via email

@Zireael07 Zireael07 mentioned this issue Apr 14, 2021
@GreenImp GreenImp added the modifier Dice modifier label Apr 23, 2021
@GreenImp
Copy link
Collaborator

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
Copy link
Collaborator

@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.

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

No branches or pull requests

2 participants