Don't allow instant revivals for a one hit KO move

pull/2/head
Flashfyre 2023-11-07 20:02:42 -05:00
parent fdc1bc5b61
commit 39a458cb3a
2 changed files with 20 additions and 14 deletions

View File

@ -2011,8 +2011,12 @@ export class DamagePhase extends PokemonPhase {
} }
export class FaintPhase 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); super(scene, battlerIndex);
this.preventEndure = preventEndure;
} }
start() { start() {
@ -2020,20 +2024,22 @@ export class FaintPhase extends PokemonPhase {
const pokemon = this.getPokemon(); 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) {
if (!--instantReviveModifier.stackCount) if (!--instantReviveModifier.stackCount)
this.scene.removeModifier(instantReviveModifier); this.scene.removeModifier(instantReviveModifier);
this.scene.updateModifiers(this.player); this.scene.updateModifiers(this.player);
return this.end(); return this.end();
} }
if (!pokemon.isPlayer()) { if (!pokemon.isPlayer()) {
const enemyInstantReviveModifiers = this.scene.findModifiers(m => m instanceof EnemyInstantReviveChanceModifier, false); const enemyInstantReviveModifiers = this.scene.findModifiers(m => m instanceof EnemyInstantReviveChanceModifier, false);
for (let modifier of enemyInstantReviveModifiers) { for (let modifier of enemyInstantReviveModifiers) {
if (modifier.shouldApply([ pokemon ]) && modifier.apply([ pokemon ])) if (modifier.shouldApply([ pokemon ]) && modifier.apply([ pokemon ]))
return this.end(); return this.end();
}
} }
} }

View File

@ -858,7 +858,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
this.hp = Math.max(this.hp - damage, 0); this.hp = Math.max(this.hp - damage, 0);
if (this.isFainted()) { if (this.isFainted()) {
this.scene.unshiftPhase(new FaintPhase(this.scene, this.getBattlerIndex())); this.scene.unshiftPhase(new FaintPhase(this.scene, this.getBattlerIndex(), preventEndure));
this.resetSummonData(); this.resetSummonData();
} }
} }