[Bug] Fix Berserk and Anger Shell from crashing the game when pokemon is forced to switch out (#1699)
* fix PostDefendHpGatedStatChangeAbAttr crashing the game * remove new line * refactor condition * refactor condition
This commit is contained in:
parent
e6c24dceab
commit
0e794fe2fc
|
@ -677,7 +677,9 @@ export class PostDefendHpGatedStatChangeAbAttr extends PostDefendAbAttr {
|
|||
applyPostDefend(pokemon: Pokemon, passive: boolean, attacker: Pokemon, move: Move, hitResult: HitResult, args: any[]): boolean {
|
||||
const hpGateFlat: integer = Math.ceil(pokemon.getMaxHp() * this.hpGate);
|
||||
const lastAttackReceived = pokemon.turnData.attacksReceived[pokemon.turnData.attacksReceived.length - 1];
|
||||
if (this.condition(pokemon, attacker, move) && (pokemon.hp <= hpGateFlat && (pokemon.hp + lastAttackReceived.damage) > hpGateFlat)) {
|
||||
const damageReceived = lastAttackReceived?.damage || 0;
|
||||
|
||||
if (this.condition(pokemon, attacker, move) && (pokemon.hp <= hpGateFlat && (pokemon.hp + damageReceived) > hpGateFlat)) {
|
||||
pokemon.scene.unshiftPhase(new StatChangePhase(pokemon.scene, (this.selfTarget ? pokemon : attacker).getBattlerIndex(), true, this.stats, this.levels));
|
||||
return true;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue