From 3e6183cd5066caa0872c59ead15068d7d710ea85 Mon Sep 17 00:00:00 2001 From: Felix Staud Date: Wed, 17 Jul 2024 16:24:34 -0700 Subject: [PATCH] move "battle:fainted" into `koPlayerPokemon` --- src/data/mystery-encounters/utils/encounter-phase-utils.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/data/mystery-encounters/utils/encounter-phase-utils.ts b/src/data/mystery-encounters/utils/encounter-phase-utils.ts index 17090467da9..ffaf11b8219 100644 --- a/src/data/mystery-encounters/utils/encounter-phase-utils.ts +++ b/src/data/mystery-encounters/utils/encounter-phase-utils.ts @@ -688,12 +688,14 @@ export function calculateMEAggregateStats(scene: BattleScene, baseSpawnWeight: n /** * Takes care of handling player pokemon KO (with all its side effects) * + * @param scene the battle scene * @param pokemon the player pokemon to KO */ -export function koPlayerPokemon(pokemon: PlayerPokemon) { +export function koPlayerPokemon(scene: BattleScene, pokemon: PlayerPokemon) { pokemon.hp = 0; pokemon.trySetStatus(StatusEffect.FAINT); pokemon.updateInfo(); + queueEncounterMessage(scene, i18next.t("battle:fainted", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon) })); } /** @@ -709,8 +711,7 @@ function applyHpChangeToPokemon(scene: BattleScene, pokemon: PlayerPokemon, valu const hpChange = Math.round(pokemon.hp + value); const nextHp = Math.max(Math.min(hpChange, pokemon.getMaxHp()), 0); if (nextHp === 0) { - koPlayerPokemon(pokemon); - queueEncounterMessage(scene, i18next.t("battle:fainted", { pokemonNameWithAffix: getPokemonNameWithAffix(pokemon) })); + koPlayerPokemon(scene, pokemon); } else { pokemon.hp = nextHp; }