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

cs and cf with default comparison. A way to add default values in the modifier class. #288

Merged
merged 3 commits into from
Nov 28, 2023

Conversation

parnas
Copy link
Contributor

@parnas parnas commented Nov 21, 2023

Modifier.js now calls the ensureParameters function during run, which checks if there is a defaults function in the current modifier. And processes it in the "variable name: variable value" loop.

Additionally, in ComparisonModifier.js there is an additional simplification for the classes that extend it, and that only have default compare point definition (which is the only use case at the moment):

  defaultComparePoint(_context) {
    return ['=', _context.min];
  }

Additionally (or, rather, this is how it is started), I've added default values to Critical Success and Critical Failure modifiers. So now it is possible to do just 1d20cscf (instead of 1d20cs=20cf=1).

No tests yet, but, of course, I'll add them if the approach gets approved.

@parnas parnas requested a review from GreenImp as a code owner November 21, 2023 19:31
Copy link
Collaborator

@GreenImp GreenImp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I really like this, thanks! A much better way of handling it than what I was doing. Thanks for this 😄

I've left a few minor comments. And another thing is just to make sure that the doc block descriptions describe the what the methods do, as they're used to auto-generate the API docs.

src/modifiers/Modifier.js Outdated Show resolved Hide resolved
src/modifiers/ComparisonModifier.js Outdated Show resolved Hide resolved
src/modifiers/Modifier.js Outdated Show resolved Hide resolved
@parnas
Copy link
Contributor Author

parnas commented Nov 27, 2023

@GreenImp Updated and added tests. Let me know, if you'll spot anything else.

Copy link
Collaborator

@GreenImp GreenImp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! Thanks so much for working on this

@GreenImp GreenImp merged commit 6ce3c10 into dice-roller:develop Nov 28, 2023
5 checks passed
@GreenImp
Copy link
Collaborator

GreenImp commented Nov 28, 2023

@parnas this has just gone out in v5.5.0. Thanks for you help 😃

The API docs have been updated, but the notation sections haven't yet.
Also, the roller in the docs is still currently using the older version, so you'll have to specify the compare point in the docs for now.

The docs have been updated, and the inbuilt roller should also be working without compare points for cs and cf modifiers.

@parnas parnas deleted the feature/default-values branch November 29, 2023 00:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants