From 39a458cb3a2b447b8557ddde3e2c02260e217f08 Mon Sep 17 00:00:00 2001 From: Flashfyre Date: Tue, 7 Nov 2023 20:02:42 -0500 Subject: [PATCH] Don't allow instant revivals for a one hit KO move --- src/battle-phases.ts | 32 +++++++++++++++++++------------- src/pokemon.ts | 2 +- 2 files changed, 20 insertions(+), 14 deletions(-) diff --git a/src/battle-phases.ts b/src/battle-phases.ts index 51bdd4b32..486ad7ba4 100644 --- a/src/battle-phases.ts +++ b/src/battle-phases.ts @@ -2011,8 +2011,12 @@ export class DamagePhase extends PokemonPhase { } export class FaintPhase extends PokemonPhase { - constructor(scene: BattleScene, battlerIndex: BattlerIndex) { + private preventEndure: boolean; + + constructor(scene: BattleScene, battlerIndex: BattlerIndex, preventEndure?: boolean) { super(scene, battlerIndex); + + this.preventEndure = preventEndure; } start() { @@ -2020,20 +2024,22 @@ export class FaintPhase extends PokemonPhase { const pokemon = this.getPokemon(); - const instantReviveModifier = this.scene.applyModifier(PokemonInstantReviveModifier, this.player, this.getPokemon()) as PokemonInstantReviveModifier; + if (!this.preventEndure) { + const instantReviveModifier = this.scene.applyModifier(PokemonInstantReviveModifier, this.player, this.getPokemon()) as PokemonInstantReviveModifier; - if (instantReviveModifier) { - if (!--instantReviveModifier.stackCount) - this.scene.removeModifier(instantReviveModifier); - this.scene.updateModifiers(this.player); - return this.end(); - } + if (instantReviveModifier) { + if (!--instantReviveModifier.stackCount) + this.scene.removeModifier(instantReviveModifier); + this.scene.updateModifiers(this.player); + return this.end(); + } - if (!pokemon.isPlayer()) { - const enemyInstantReviveModifiers = this.scene.findModifiers(m => m instanceof EnemyInstantReviveChanceModifier, false); - for (let modifier of enemyInstantReviveModifiers) { - if (modifier.shouldApply([ pokemon ]) && modifier.apply([ pokemon ])) - return this.end(); + if (!pokemon.isPlayer()) { + const enemyInstantReviveModifiers = this.scene.findModifiers(m => m instanceof EnemyInstantReviveChanceModifier, false); + for (let modifier of enemyInstantReviveModifiers) { + if (modifier.shouldApply([ pokemon ]) && modifier.apply([ pokemon ])) + return this.end(); + } } } diff --git a/src/pokemon.ts b/src/pokemon.ts index 7c7e2c1b0..e315658a7 100644 --- a/src/pokemon.ts +++ b/src/pokemon.ts @@ -858,7 +858,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { this.hp = Math.max(this.hp - damage, 0); if (this.isFainted()) { - this.scene.unshiftPhase(new FaintPhase(this.scene, this.getBattlerIndex())); + this.scene.unshiftPhase(new FaintPhase(this.scene, this.getBattlerIndex(), preventEndure)); this.resetSummonData(); } }