-
-
Notifications
You must be signed in to change notification settings - Fork 414
Add support for a negation/fail check on CondChance #8320
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
base: dev/feature
Are you sure you want to change the base?
Add support for a negation/fail check on CondChance #8320
Conversation
| String baseString = "chance of " + chance.toString(event, debug) + (percent ? "%" : ""); | ||
| if (isNegated()) baseString += " failed"; | ||
| return baseString; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Quick note this doesn't use a SyntaxStringBulder as it would cause with percentage to format as chance of 10 %
edit: fixed the usage of if () baseString += "" not being on a new line
sovdeeth
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just some nitpicks
| @Override | ||
| public boolean init(final Expression<?>[] exprs, final int matchedPattern, final Kleenean isDelayed, final ParseResult parser) { | ||
| public boolean init(Expression<?>[] exprs, int matchedPattern, Kleenean isDelayed, ParseResult parseResult) { | ||
| //noinspection unchecked |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can leave this as a suppression on the method if you'd like
Co-authored-by: sovdee <10354869+sovdeeth@users.noreply.github.com>
Co-authored-by: sovdee <10354869+sovdeeth@users.noreply.github.com>

Problem
In skript there is no way currently to get the negated result of a
CondChancewithout 4 semi annoying work arounds.10%->90%0-1value use1 - xelseSolution
In order to provide developers a more flexible condition I'm proposing to add a new end bit for whether it failed
i.e.
if chance of 10% failedallowing easier and simpler guard conditions in their codeTesting Completed
Manual testing was completed with a debug method added within the

checkmethodSupporting Information
While doing this I've taken the chance to update methods and annotations to skript's newer designs, wasn't sure if the team wanted this swapped too the new registration api or where you'd want it moved to if so.
Completes: #8319
Related: none
AI assistance: none