Move queueAbilityDisplay to battlescene

This commit is contained in:
Dean 2025-02-21 15:59:52 -08:00
parent 5413332818
commit 165c5fa7bc
2 changed files with 17 additions and 15 deletions

View File

@ -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)
*/

View File

@ -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<TAttr extends AbAttr>(
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<TAttr extends AbAttr>(
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.