From 9e453c5b0f6b8808c7ec43d148730ca3cf3a394c Mon Sep 17 00:00:00 2001 From: Douglas Marchione de Souza <42784723+Tiduzz@users.noreply.github.com> Date: Sun, 12 May 2024 16:53:54 -0300 Subject: [PATCH] Fix sturdy (#604) * Fixes sturdy to stop popping up even if not used * Made changes to better the code, also added a check for wonder_guard 1hp * Refined code, as requested by bennybroseph * Made a small fix and added better comments in relation to interaction with Wonder_guard ability --- src/data/ability.ts | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/data/ability.ts b/src/data/ability.ts index 90335a85d02..cad6257152d 100644 --- a/src/data/ability.ts +++ b/src/data/ability.ts @@ -249,10 +249,13 @@ export class PreDefendFormChangeAbAttr extends PreDefendAbAttr { } export class PreDefendFullHpEndureAbAttr extends PreDefendAbAttr { applyPreDefend(pokemon: Pokemon, passive: boolean, attacker: Pokemon, move: PokemonMove, cancelled: Utils.BooleanHolder, args: any[]): boolean { - if (pokemon.getMaxHp() <= 1 && (pokemon.getHpRatio() < 1 || (args[0] as Utils.NumberHolder).value < pokemon.hp)) - return false; - - return pokemon.addTag(BattlerTagType.STURDY, 1); + if (pokemon.hp === pokemon.getMaxHp() && + pokemon.getMaxHp() > 1 && //Checks if pokemon has wonder_guard (which forces 1hp) + (args[0] as Utils.NumberHolder).value >= pokemon.hp){ //Damage >= hp + return pokemon.addTag(BattlerTagType.STURDY, 1); + } + + return false } }