mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-07-23 08:42:19 +02:00
Add HideAbilityPhase to hide ability bar after effects
This commit is contained in:
parent
c55e60ea0c
commit
e4630716c9
@ -44,6 +44,7 @@ import { MoveEndPhase } from "#app/phases/move-end-phase";
|
|||||||
import { PokemonAnimType } from "#enums/pokemon-anim-type";
|
import { PokemonAnimType } from "#enums/pokemon-anim-type";
|
||||||
import { StatusEffect } from "#enums/status-effect";
|
import { StatusEffect } from "#enums/status-effect";
|
||||||
import { WeatherType } from "#enums/weather-type";
|
import { WeatherType } from "#enums/weather-type";
|
||||||
|
import { HideAbilityPhase } from "#app/phases/hide-ability-phase";
|
||||||
|
|
||||||
export class Ability implements Localizable {
|
export class Ability implements Localizable {
|
||||||
public id: Abilities;
|
public id: Abilities;
|
||||||
@ -4881,32 +4882,32 @@ async function applyAbAttrsInternal<TAttr extends AbAttr>(
|
|||||||
|
|
||||||
globalScene.setPhaseQueueSplice();
|
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);
|
let result = applyFunc(attr, passive);
|
||||||
// TODO Remove this when promises get reworked
|
// TODO Remove this when promises get reworked
|
||||||
if (result instanceof Promise) {
|
if (result instanceof Promise) {
|
||||||
result = await result;
|
result = await result;
|
||||||
}
|
}
|
||||||
if (result) {
|
if (result) {
|
||||||
|
globalScene.phaseQueue;
|
||||||
|
queueHideAbility(pokemon, passive);
|
||||||
|
|
||||||
if (pokemon.summonData && !pokemon.summonData.abilitiesApplied.includes(ability.id)) {
|
if (pokemon.summonData && !pokemon.summonData.abilitiesApplied.includes(ability.id)) {
|
||||||
pokemon.summonData.abilitiesApplied.push(ability.id);
|
pokemon.summonData.abilitiesApplied.push(ability.id);
|
||||||
}
|
}
|
||||||
if (pokemon.battleData && !simulated && !pokemon.battleData.abilitiesApplied.includes(ability.id)) {
|
if (pokemon.battleData && !simulated && !pokemon.battleData.abilitiesApplied.includes(ability.id)) {
|
||||||
pokemon.battleData.abilitiesApplied.push(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();
|
globalScene.clearPhaseQueueSplice();
|
||||||
@ -5299,6 +5300,11 @@ function queueShowAbility(pokemon: Pokemon, passive: boolean): void {
|
|||||||
globalScene.clearPhaseQueueSplice();
|
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.
|
* Sets the ability of a Pokémon as revealed.
|
||||||
*
|
*
|
||||||
|
27
src/phases/hide-ability-phase.ts
Normal file
27
src/phases/hide-ability-phase.ts
Normal 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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -41,7 +41,6 @@ export default class AbilityBar extends Phaser.GameObjects.Container {
|
|||||||
|
|
||||||
startTween(config: any, text?: string): Promise<void> {
|
startTween(config: any, text?: string): Promise<void> {
|
||||||
this.setVisible(true);
|
this.setVisible(true);
|
||||||
this.shown = true;
|
|
||||||
if (text) {
|
if (text) {
|
||||||
this.abilityBarText.setText(text);
|
this.abilityBarText.setText(text);
|
||||||
}
|
}
|
||||||
@ -73,11 +72,11 @@ export default class AbilityBar extends Phaser.GameObjects.Container {
|
|||||||
}, text);
|
}, text);
|
||||||
}
|
}
|
||||||
|
|
||||||
hide(): void {
|
hide(): Promise<void> {
|
||||||
this.startTween({
|
return this.startTween({
|
||||||
targets: this,
|
targets: this,
|
||||||
x: -91,
|
x: -91,
|
||||||
duration: 500,
|
duration: 200,
|
||||||
ease: "Sine.easeIn",
|
ease: "Sine.easeIn",
|
||||||
onComplete: () => {
|
onComplete: () => {
|
||||||
this.setVisible(false);
|
this.setVisible(false);
|
||||||
|
Loading…
Reference in New Issue
Block a user