Add HideAbilityPhase to hide ability bar after effects

This commit is contained in:
Dean 2025-01-31 23:46:28 -08:00
parent c55e60ea0c
commit e4630716c9
3 changed files with 50 additions and 18 deletions

View File

@ -44,6 +44,7 @@ import { MoveEndPhase } from "#app/phases/move-end-phase";
import { PokemonAnimType } from "#enums/pokemon-anim-type";
import { StatusEffect } from "#enums/status-effect";
import { WeatherType } from "#enums/weather-type";
import { HideAbilityPhase } from "#app/phases/hide-ability-phase";
export class Ability implements Localizable {
public id: Abilities;
@ -4881,32 +4882,32 @@ async function applyAbAttrsInternal<TAttr extends AbAttr>(
globalScene.setPhaseQueueSplice();
if (attr.showAbility && !simulated) {
queueShowAbility(pokemon, passive);
}
const message = attr.getTriggerMessage(pokemon, ability.name, args);
if (message) {
if (!simulated) {
globalScene.queueMessage(message);
}
}
messages.push(message!);
let result = applyFunc(attr, passive);
// TODO Remove this when promises get reworked
if (result instanceof Promise) {
result = await result;
}
if (result) {
globalScene.phaseQueue;
queueHideAbility(pokemon, passive);
if (pokemon.summonData && !pokemon.summonData.abilitiesApplied.includes(ability.id)) {
pokemon.summonData.abilitiesApplied.push(ability.id);
}
if (pokemon.battleData && !simulated && !pokemon.battleData.abilitiesApplied.includes(ability.id)) {
pokemon.battleData.abilitiesApplied.push(ability.id);
}
if (attr.showAbility && !simulated) {
if (showAbilityInstant) {
globalScene.abilityBar.showAbility(pokemon, passive);
} else {
queueShowAbility(pokemon, passive);
}
}
const message = attr.getTriggerMessage(pokemon, ability.name, args);
if (message) {
if (!simulated) {
globalScene.queueMessage(message);
}
}
messages.push(message!);
}
}
globalScene.clearPhaseQueueSplice();
@ -5299,6 +5300,11 @@ function queueShowAbility(pokemon: Pokemon, passive: boolean): void {
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.
*

View File

@ -0,0 +1,27 @@
import { globalScene } from "#app/global-scene";
import type { BattlerIndex } from "#app/battle";
import { PokemonPhase } from "./pokemon-phase";
export class HideAbilityPhase extends PokemonPhase {
private passive: boolean;
constructor(battlerIndex: BattlerIndex, passive: boolean = false) {
super(battlerIndex);
this.passive = passive;
}
start() {
super.start();
const pokemon = this.getPokemon();
if (pokemon) {
globalScene.abilityBar.hide().then(() => {
this.end();
});
} else {
this.end();
}
}
}

View File

@ -41,7 +41,6 @@ export default class AbilityBar extends Phaser.GameObjects.Container {
startTween(config: any, text?: string): Promise<void> {
this.setVisible(true);
this.shown = true;
if (text) {
this.abilityBarText.setText(text);
}
@ -73,11 +72,11 @@ export default class AbilityBar extends Phaser.GameObjects.Container {
}, text);
}
hide(): void {
this.startTween({
hide(): Promise<void> {
return this.startTween({
targets: this,
x: -91,
duration: 500,
duration: 200,
ease: "Sine.easeIn",
onComplete: () => {
this.setVisible(false);