rpg-dice-roller
rpg-dice-roller copied to clipboard
Support arbitarily sided dice
Is your feature request related to a problem? Please describe.
AnyDice supports arbitarily sided dice with syntax d{1,2,4,8}
these are often handy, for example when you need some weirder values for "coin flips" e.g. d10 * d{1,1,2}
would be d10
multiplied by two 1/3 of the time.
Describe alternatives you've considered Very generic tool but in reality not needed that often. might allow the internals to change how e.g. fudge and exploding dice work.
This was actually partially discussed here https://github.com/dice-roller/rpg-dice-roller/issues/229#issuecomment-1002124520
Thinking about it, it could be useful to allow the
StandardDice
min value to be modified through notation, and for it to offset thesides
/ max value.I think it should be fairly simple to implement, but I'd have to run some tests.
I'm not sure what the notation would be for something like that though. Any thoughts?
A couple of idea off the top of my head:
// using "db" for Dice with Base number db0,3 // roll a 3 sides die, with a min value of `0` (0, 1, 2) db4,2 // roll a 2 sided die, with a min value of `4` (4, 5) // square brackets to define a range (Same rolls as above) d[0, 2] // roll a dice that has all values between 0, and 2 inclusive (0, 1, 2) d[4, 5] // roll a dice that has all values between 4, 5 inclusive (4, 5)
But with no conclusion.
I think what you're suggesting seems like a further enhancement of that suggestion.
When implemented properly it could also be used to create multichoice rolls. For example to roll a random item from multiple tables (such as loot in D&D) you could do d{d8,d20,d100}
, of course in that case you would also need to render which side the dice landed on somehow...
Basing this off the examples on AnyDice, and how MathJS handles ranges, I think a reasonable syntax would be:
// roll a die with values between n1 and n2 inclusive
d{n1...n2}
// Same as above
d{n1:n2}}
// Same as above, but with specifying an optional step value
d{n1:s:n2}}
// roll a die with the specific values
d{n1, n2, n3}
For example:
// Roll a dice with a minimum value of 1 and a maximum of 6 (Same as `d6`)
d{1..6}
// Same as above
d{1:6}
// Roll a dice with a minimum of -1 and a maximum of 1 (A Fudge die)
d{-1..1}
// Same as above
d{-1:1}
// Roll a dice with a minimum of -0.5 and a maximum of 10.5, with a step of .25
d{-0.5:0.25:10.5}}
// Roll a die with specific values
d{2, 3, 3, 4}
We can't currently support die notation as a value (e.g. d{d8,d20,d100}
as the parser can't handle this at the moment (See #206)
Also, supporting none numbers sides, something like : 2d[blue, red, green] might return blue, green or red, red
In those case, I only see {cp} = working. For example 2d[blue, red, green]=green, or maybe something 2d[blue, red, green]double will give 1 is twice the same value appear.