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

Add dice "keep" (k) notation #6

Closed
Vlek opened this issue Oct 25, 2020 · 5 comments
Closed

Add dice "keep" (k) notation #6

Vlek opened this issue Oct 25, 2020 · 5 comments
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@Vlek
Copy link
Owner

Vlek commented Oct 25, 2020

Add the ability to denote that a dice should be rolled and only a number of highest or lowest rolls should be kept.

(Dice) K/k [count]

2d20K - Keep the highest roll out of the two.

4d6K3 - Keep the highest three rolls out of four. (Like for stat generation for D&D)

2d20k - Keep the lowest roll out of the two.

4d6k2 - Keep the lowest two rolls out of four.
@Vlek Vlek added the enhancement New feature or request label Oct 25, 2020
@Vlek Vlek self-assigned this Oct 25, 2020
@Vlek Vlek added this to the 3.0 milestone Oct 25, 2020
@Vlek
Copy link
Owner Author

Vlek commented Feb 15, 2021

Currently working on this and ran into a bit of a thinker of a problem:

The parser that we have is going to throw a fit and be much slower the more I add onto the operators that we have. This is especially the case if I had recursive issues by supplying more dice-specific ones as I have not found a way to use the built-ins well in regards to having order of operations and also optional operands for a given operation.

My current thought is that I should use this as a separate operation outside of the dice notation and have it only accept a dice as the left-side operand. That way it keeps my code cleaner and, more importantly, I don't have to go through all of the headache cases or somehow figure out how to notate that any of these adder things to the dice notation are acceptable in any order. I am going to chew on this some more and try to create a prototype based on the above.

@Vlek
Copy link
Owner Author

Vlek commented Feb 16, 2021

Currently works except for the implied amount when the right-hand number is not given.

I'm wondering whether negative keep means we should roll more dice? We already have the necessary information to do so and it's being passed currently in the RollResult object.

@Vlek
Copy link
Owner Author

Vlek commented Jun 24, 2021

Currently working on this again. It's proving to be more difficult than originally thought.

The logic that I had previously used was that, if we didn't have at least the number of dice that the keep notation asked for, we would zero out that last roll. Now I believe that it should be that we keep all dice up to and including the requested amount. e.g. 1d20K100 == 1d20.

Another thing that I am considering for this is whether 2d6K1.5 is 2d6K2 or keep the highest plus 50% of the second.

@Vlek
Copy link
Owner Author

Vlek commented Jun 26, 2021

One thing that is going to be hard to test with this is ensuring that the proper dice are kept after they're rolled. Even with the current verbose setting, that isn't going to give us all of the dice because they're being removed from the object without a historical entry to reference after the fact.

In order to address this, I am likely going to have to create a way of keeping track of the parsing history. This will be tracked using a new ticket because it's a different feature than the keep dice notation.

One helpful thing that we could do for this if it is implemented is overloading the str method of EvaluationResults to give the verbose output of the history of the roll:

roll 4d20K3 -v

# output:
Rolled: 4d20: [ 2, 13, 17, 10 ]
Keep: K3: [ 13, 17, 10 ]

@Vlek Vlek mentioned this issue Jul 11, 2021
@Vlek
Copy link
Owner Author

Vlek commented Jul 16, 2021

This has been added as of 2.1 and merged into the development branch.

@Vlek Vlek closed this as completed May 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant