From dbecb728906c6efaaf8cd186475d5eca419d67b2 Mon Sep 17 00:00:00 2001 From: Adrian T <68144167+torranx@users.noreply.github.com> Date: Sun, 16 Jun 2024 00:13:59 +0800 Subject: [PATCH] [Bug] add ability revelead for trace, refactor (#2258) --- src/data/ability.ts | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/data/ability.ts b/src/data/ability.ts index daaa82baf68..4c27e6c6859 100755 --- a/src/data/ability.ts +++ b/src/data/ability.ts @@ -1899,6 +1899,7 @@ export class TraceAbAttr extends PostSummonAbAttr { pokemon.summonData.ability = target.getAbility().id; pokemon.scene.queueMessage(getPokemonMessage(pokemon, ` traced ${target.name}'s\n${allAbilities[target.getAbility().id].name}!`)); + setAbilityRevealed(target); return true; } @@ -2457,9 +2458,7 @@ export class FriskAbAttr extends PostSummonAbAttr { applyPostSummon(pokemon: Pokemon, passive: boolean, args: any[]): boolean { for (const opponent of pokemon.getOpponents()) { pokemon.scene.queueMessage(getPokemonMessage(pokemon, " frisked " + opponent.name + "'s " + opponent.getAbility().name + "!")); - if (opponent.battleData) { - opponent.battleData.abilityRevealed = true; - } + setAbilityRevealed(opponent); } return true; } @@ -3820,6 +3819,17 @@ function queueShowAbility(pokemon: Pokemon, passive: boolean): void { pokemon.scene.clearPhaseQueueSplice(); } +/** + * Sets the ability of a Pokémon as revealed. + * + * @param pokemon - The Pokémon whose ability is being revealed. + */ +function setAbilityRevealed(pokemon: Pokemon): void { + if (pokemon.battleData) { + pokemon.battleData.abilityRevealed = true; + } +} + export const allAbilities = [ new Ability(Abilities.NONE, 3) ]; export function initAbilities() {