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

Is it possible to set the minimum value on a DiceRoll object? #229

Open
XaeroDegreaz opened this issue Jun 30, 2021 · 2 comments
Open

Is it possible to set the minimum value on a DiceRoll object? #229

XaeroDegreaz opened this issue Jun 30, 2021 · 2 comments

Comments

@XaeroDegreaz
Copy link

XaeroDegreaz commented Jun 30, 2021

For instance, if I use the notation d3, is there a way to set the minimum value to 0 for the DiceRoll object? This would make possible values 0, 1, 2.

My use case is such that I'm using an average value to determine which types of dice to throw. The average value is a static value based upon different character attributes, but I would like to randomize the outcome to where the roll can deviate up or down some, though statistically over time would equal the average value. For instance, if the average value is 1, I would like to throw a d3 that would have an averageTotal of 1.

I know that I could construct a bunch of StandardDice to define the min, and max values, but I really like the ability to use notations to describe the dice throws. Is there a way that one can use the DiceRoll object in this way? I also know that I could just subtract 1 from the roll, but I would rather have the roll itself just return 0's if possible.

@GreenImp
Copy link
Collaborator

This currently isn't possible; Standard dice have a min value of 1.

As you mentioned, you could create a custom StandardDice object, and specify the min / max values manually.
Or do something like d3-1.

I am hoping to allow developers to create custom dice at some point, but it would require a fundamental re-write of how the parser works, so it's unlikely to be done any time soon.

@GreenImp
Copy link
Collaborator

GreenImp commented Dec 28, 2021

Thinking about it, it could be useful to allow the StandardDice min value to be modified through notation, and for it to offset the sides / 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 sided 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)

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