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
pull/766/head^2
Douglas Marchione de Souza 2024-05-12 16:53:54 -03:00 committed by GitHub
parent 512cc5b965
commit 9e453c5b0f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 7 additions and 4 deletions

View File

@ -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
}
}