Issue #591 The Pokemon is now revived when it holds a reviver seed and kills itself with something like explosion

pull/689/head
Jannik Tappert 2024-05-09 21:32:52 +02:00
parent d5681a6e03
commit e4e6b50f46
1 changed files with 26 additions and 1 deletions

View File

@ -3077,10 +3077,30 @@ 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() {
switch (this.scene.currentBattle.battleSpec) {
case BattleSpec.FINAL_BOSS:
@ -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;