From 165c5fa7bc06e5bbe08fdf180eabffdee7d6e020 Mon Sep 17 00:00:00 2001 From: Dean Date: Fri, 21 Feb 2025 15:59:52 -0800 Subject: [PATCH] Move queueAbilityDisplay to battlescene --- src/battle-scene.ts | 13 +++++++++++++ src/data/ability.ts | 19 ++++--------------- 2 files changed, 17 insertions(+), 15 deletions(-) diff --git a/src/battle-scene.ts b/src/battle-scene.ts index 1abec03327c..77af34c58a8 100644 --- a/src/battle-scene.ts +++ b/src/battle-scene.ts @@ -175,6 +175,8 @@ import { BattlerTagType } from "#enums/battler-tag-type"; import { FRIENDSHIP_GAIN_FROM_BATTLE } from "#app/data/balance/starters"; import { StatusEffect } from "#enums/status-effect"; import { initGlobalScene } from "#app/global-scene"; +import { ShowAbilityPhase } from "#app/phases/show-ability-phase"; +import { HideAbilityPhase } from "#app/phases/hide-ability-phase"; export const bypassLogin = import.meta.env.VITE_BYPASS_LOGIN === "1"; @@ -3138,6 +3140,17 @@ export default class BattleScene extends SceneBase { } } + /** + * Queues an ability bar flyout phase + * @param pokemon The pokemon who has the ability + * @param passive Whether the ability is a passive + * @param show Whether to show or hide the bar + */ + public queueAbilityDisplay(pokemon: Pokemon, passive: boolean, show: boolean): void { + this.unshiftPhase((show) ? new ShowAbilityPhase(pokemon.id, passive) : new HideAbilityPhase(pokemon.id, passive)); + this.clearPhaseQueueSplice(); + } + /** * Moves everything from nextCommandPhaseQueue to phaseQueue (keeping order) */ diff --git a/src/data/ability.ts b/src/data/ability.ts index 9f563ac1c80..388b03f26f8 100644 --- a/src/data/ability.ts +++ b/src/data/ability.ts @@ -32,7 +32,6 @@ import { Species } from "#enums/species"; import { Stat, type BattleStat, type EffectiveStat, BATTLE_STATS, EFFECTIVE_STATS, getStatKey } from "#app/enums/stat"; import { MovePhase } from "#app/phases/move-phase"; import { PokemonHealPhase } from "#app/phases/pokemon-heal-phase"; -import { ShowAbilityPhase } from "#app/phases/show-ability-phase"; import { StatStageChangePhase } from "#app/phases/stat-stage-change-phase"; import { globalScene } from "#app/global-scene"; import { SwitchType } from "#app/enums/switch-type"; @@ -45,7 +44,6 @@ import { PokemonAnimType } from "#enums/pokemon-anim-type"; import { StatusEffect } from "#enums/status-effect"; import { WeatherType } from "#enums/weather-type"; import { PokemonTransformPhase } from "#app/phases/pokemon-transform-phase"; -import { HideAbilityPhase } from "#app/phases/hide-ability-phase"; export class Ability implements Localizable { public id: Abilities; @@ -1250,7 +1248,7 @@ export class IgnoreMoveEffectsAbAttr extends PreDefendAbAttr { export class VariableMovePowerAbAttr extends PreAttackAbAttr { override canApplyPreAttack(pokemon: Pokemon, passive: boolean, simulated: boolean, defender: Pokemon, move: Move, args: any[]): boolean { - return false; + return true; } } @@ -2692,7 +2690,7 @@ export class PostSummonFormChangeByWeatherAbAttr extends PostSummonAbAttr { if (!simulated) { globalScene.triggerPokemonFormChange(pokemon, SpeciesFormChangeWeatherTrigger); globalScene.triggerPokemonFormChange(pokemon, SpeciesFormChangeRevertWeatherFormTrigger); - queueShowAbility(pokemon, passive); + globalScene.queueAbilityDisplay(pokemon, passive, true); } } } @@ -5104,7 +5102,7 @@ function applySingleAbAttrs( globalScene.setPhaseQueueSplice(); if (attr.showAbility && !simulated) { - queueShowAbility(pokemon, passive); + globalScene.queueAbilityDisplay(pokemon, passive, true); abShown = true; } const message = attr.getTriggerMessage(pokemon, ability.name, args); @@ -5118,7 +5116,7 @@ function applySingleAbAttrs( applyFunc(attr, passive); if (abShown) { - queueHideAbility(pokemon, passive); + globalScene.queueAbilityDisplay(pokemon, passive, false); } if (pokemon.summonData && !pokemon.summonData.abilitiesApplied.includes(ability.id)) { @@ -5951,15 +5949,6 @@ export function applyOnLoseClearWeatherAbAttrs( simulated, ); } -function queueShowAbility(pokemon: Pokemon, passive: boolean): void { - globalScene.unshiftPhase(new ShowAbilityPhase(pokemon.id, passive)); - globalScene.clearPhaseQueueSplice(); -} - -function queueHideAbility(pokemon: Pokemon, passive: boolean): void { - globalScene.unshiftPhase(new HideAbilityPhase(pokemon.id, passive)); - globalScene.clearPhaseQueueSplice(); -} /** * Sets the ability of a Pokémon as revealed.