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 abilitypull/766/head^2
parent
512cc5b965
commit
9e453c5b0f
|
@ -249,10 +249,13 @@ export class PreDefendFormChangeAbAttr extends PreDefendAbAttr {
|
||||||
}
|
}
|
||||||
export class PreDefendFullHpEndureAbAttr extends PreDefendAbAttr {
|
export class PreDefendFullHpEndureAbAttr extends PreDefendAbAttr {
|
||||||
applyPreDefend(pokemon: Pokemon, passive: boolean, attacker: Pokemon, move: PokemonMove, cancelled: Utils.BooleanHolder, args: any[]): boolean {
|
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))
|
if (pokemon.hp === pokemon.getMaxHp() &&
|
||||||
return false;
|
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 pokemon.addTag(BattlerTagType.STURDY, 1);
|
return false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue