From e4e6b50f46d02130f5bb18368c3fe528987d2f52 Mon Sep 17 00:00:00 2001 From: Jannik Tappert Date: Thu, 9 May 2024 21:32:52 +0200 Subject: [PATCH] Issue #591 The Pokemon is now revived when it holds a reviver seed and kills itself with something like explosion --- src/phases.ts | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/src/phases.ts b/src/phases.ts index 25b0c3b75..fc1a33132 100644 --- a/src/phases.ts +++ b/src/phases.ts @@ -3077,8 +3077,28 @@ export class DamagePhase extends PokemonPhase { this.getPokemon().updateInfo().then(() => this.end()); } }); - } else + } else { this.getPokemon().updateInfo().then(() => this.end()); + } + + // Check if the damage was enough to faint the pokemon + if (this.getPokemon().isFainted()) { + // Check if the pokemon has a reviver_seed + const hasReviverSeed = this.getPokemon().getHeldItems().find(i => i.type.id === 'REVIVER_SEED'); + + // If the Pokémon has a reviver seed, consume it and revive the Pokémon + if (hasReviverSeed) { + 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) + } + + } + } } end() { @@ -3123,6 +3143,11 @@ export class FaintPhase extends PokemonPhase { start() { super.start(); + // Check if the pokemon has fainted and end the phase if it hasn't fainted (e.g. due to endure or reviver seed) + if (!this.getPokemon().isFainted()) + return this.end(); + + if (!this.preventEndure) { const instantReviveModifier = this.scene.applyModifier(PokemonInstantReviveModifier, this.player, this.getPokemon()) as PokemonInstantReviveModifier;