Fix: Accept additional correct solutions in L14.P2 damage check - #1389
Open
madison-nicole wants to merge 1 commit into
Open
Fix: Accept additional correct solutions in L14.P2 damage check#1389madison-nicole wants to merge 1 commit into
madison-nicole wants to merge 1 commit into
Conversation
The static check for the "Reducing damage at higher levels" practice only matched 'amount *= 0.5' and 'amount = amount * 0.5'. Also accept 'amount -= amount * 0.5' and 'amount /= 2', which produce the specified behavior (half damage above level 2) and still assign the reduced value back to the parameter.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Please check if the PR fulfills these requirements:
Related issue (if applicable): #1388
What kind of change does this PR introduce?
Bug fix: widens the static check for practice L14.P2 "Reducing damage at
higher levels" so it accepts more correct solutions.
Does this PR introduce a breaking change?
No. All previously accepted solutions still pass; the change only adds
alternatives to the existing
GDExpr.any_ofpattern inTestReducingDamage.gd. No practice text or error messages were touched,so there is no translation churn.
New feature or change
What is the current behavior?
The check "Multiplication Is Used To Reduce Damage Amount" only matches
amount *= 0.5andamount = amount * 0.5(operand order is alreadyflexible, so
amount = 0.5 * amountalso passes). Other solutions thatproduce exactly the specified behavior, half damage above level 2, full
damage below, fail with "It looks like amount isn't reduced by a
percentage," even though the behavioral check passes.
What is the new behavior?
Two additional forms are accepted, both of which keep the practice's
intent of assigning the reduced value back to the parameter:
amount -= amount * 0.5amount /= 2(also matches2.0, since literal matching uses Variant==)Out of scope, up to the maintainer
health -= amount * 0.5with anelsebranch which is the exact code from L14.P2 Reducing damage at higher levels: check rejects correct solutions that don't reassign amount #1388): accepting it would drop theassign-to-parameter requirement entirely, which is a lesson-design call
for a practice about multiplication.
amount = amount / 2: easy to add withGDExpr.bin_op(..., OP_DIVISION)if wanted.