[Bug][Beta] Fix hit check so Poison-types do not brick semi-invuln. #4567
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.
What are the changes the user will see?
Currently on beta, all Poison-type Pokemon ignore opposing semi-invulnerability due to a bug introduced by my PR #4445. This bug has not yet hit live servers. This PR fixes the issue so that only Toxic bypasses semi-invuln when used by Poison-types, which is the intended behavior.
Why am I making these changes?
I broke semi-invuln sorry but this should fix it. Thank you DerTapp, Snailman, and PigeonBar for noticing the bug that I caused and raising it to my attention so quickly on discord.
What are the changes from a developer perspective?
Previously my check for Toxic Accuracy attr was incorrect. What I intended to do was bypass semi-invuln if the move used has Toxic Accuracy attr and the user is Poison-type. But instead of checking if the move has a Toxic Accuracy attr, I got the array of all the move's attrs matching Toxic Accuracy attr. For all moves other than Toxic itself, this array would be empty. But all arrays in ts/js, even empty ones, are truthy. So in other words my implementation then caused all moves, when used by a Poison-type, to bypass semi-invuln.
This alters the hit check logic to match its intent, which is to actually check if the move has Toxic's accuracy instead of always evaluating that condition to true. I've also added a unit test for Toxic to test for this bug.
Screenshots/Videos
Before: Screen recording 2024-10-03 4.54.00 PM.webm
After: Screen recording 2024-10-03 4.56.59 PM.webm
How to test the changes?
Load
20241003 Semi-Invulnerable.txt (Credit: PigeonBar) and select Dive. Without this change, Crobat can hit you even through Dive; with this change, Crobat will no longer be able to hit you.
Checklist
beta
as my base branch[ ] If I have text, did I make it translatable and add a key in the English locale file(s)?npm run test
) -> no,src/test/system/game_data.test.ts
is failing. But it's also failing on beta, so I think this change is not the culprit.