mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-07-05 07:52:17 +02:00
Make flyout exclusive to EnemyBattleInfo
This commit is contained in:
parent
95c7d34009
commit
2687ce2535
@ -3349,22 +3349,10 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
|
||||
return this.battleInfo.updateInfo(this, instant);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show or hide the type effectiveness multiplier window
|
||||
* Passing undefined will hide the window
|
||||
*/
|
||||
updateEffectiveness(effectiveness?: string) {
|
||||
this.battleInfo.updateEffectiveness(effectiveness);
|
||||
}
|
||||
|
||||
toggleStats(visible: boolean): void {
|
||||
this.battleInfo.toggleStats(visible);
|
||||
}
|
||||
|
||||
toggleFlyout(visible: boolean): void {
|
||||
this.battleInfo.toggleFlyout(visible);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds experience to this PlayerPokemon, subject to wave based level caps.
|
||||
* @param exp The amount of experience to add
|
||||
@ -6040,6 +6028,7 @@ export class PlayerPokemon extends Pokemon {
|
||||
}
|
||||
|
||||
export class EnemyPokemon extends Pokemon {
|
||||
protected battleInfo: EnemyBattleInfo;
|
||||
public trainerSlot: TrainerSlot;
|
||||
public aiType: AiType;
|
||||
public bossSegments: number;
|
||||
@ -6711,6 +6700,19 @@ export class EnemyPokemon extends Pokemon {
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Show or hide the type effectiveness multiplier window
|
||||
* Passing undefined will hide the window
|
||||
*/
|
||||
updateEffectiveness(effectiveness?: string) {
|
||||
this.battleInfo.updateEffectiveness(effectiveness);
|
||||
}
|
||||
|
||||
toggleFlyout(visible: boolean): void {
|
||||
this.battleInfo.toggleFlyout(visible);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -161,7 +161,7 @@ export class UiInputs {
|
||||
|
||||
buttonInfo(pressed = true): void {
|
||||
if (globalScene.showMovesetFlyout) {
|
||||
for (const p of globalScene.getField().filter(p => p?.isActive(true))) {
|
||||
for (const p of globalScene.getEnemyField().filter(p => p?.isActive(true))) {
|
||||
p.toggleFlyout(pressed);
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
import type { default as Pokemon } from "../field/pokemon";
|
||||
import type { EnemyPokemon, default as Pokemon } from "../field/pokemon";
|
||||
import { addTextObject, TextStyle } from "./text";
|
||||
import { fixedInt } from "#app/utils/common";
|
||||
import { globalScene } from "#app/global-scene";
|
||||
@ -126,7 +126,7 @@ export default class BattleFlyout extends Phaser.GameObjects.Container {
|
||||
* Links the given {@linkcode Pokemon} and subscribes to the {@linkcode BattleSceneEventType.MOVE_USED} event
|
||||
* @param pokemon {@linkcode Pokemon} to link to this flyout
|
||||
*/
|
||||
initInfo(pokemon: Pokemon) {
|
||||
initInfo(pokemon: EnemyPokemon) {
|
||||
this.pokemon = pokemon;
|
||||
|
||||
this.name = `Flyout ${getPokemonNameWithAffix(this.pokemon)}`;
|
||||
|
@ -9,7 +9,6 @@ import { getTypeRgb } from "#app/data/type";
|
||||
import { PokemonType } from "#enums/pokemon-type";
|
||||
import { getVariantTint } from "#app/sprites/variant";
|
||||
import { Stat } from "#enums/stat";
|
||||
import type BattleFlyout from "../battle-flyout";
|
||||
import i18next from "i18next";
|
||||
import { ExpGainsSpeed } from "#app/enums/exp-gains-speed";
|
||||
|
||||
@ -55,13 +54,6 @@ export default abstract class BattleInfo extends Phaser.GameObjects.Container {
|
||||
protected type3Icon: Phaser.GameObjects.Sprite;
|
||||
protected expBar: Phaser.GameObjects.Image;
|
||||
|
||||
// #region Type effectiveness hint objects
|
||||
protected effectivenessContainer: Phaser.GameObjects.Container;
|
||||
protected effectivenessWindow: Phaser.GameObjects.NineSlice;
|
||||
protected effectivenessText: Phaser.GameObjects.Text;
|
||||
protected currentEffectiveness?: string;
|
||||
// #endregion
|
||||
|
||||
public expMaskRect: Phaser.GameObjects.Graphics;
|
||||
|
||||
protected statsContainer: Phaser.GameObjects.Container;
|
||||
@ -69,8 +61,6 @@ export default abstract class BattleInfo extends Phaser.GameObjects.Container {
|
||||
protected statValuesContainer: Phaser.GameObjects.Container;
|
||||
protected statNumbers: Phaser.GameObjects.Sprite[];
|
||||
|
||||
public flyoutMenu?: BattleFlyout;
|
||||
|
||||
get statOrder(): Stat[] {
|
||||
return [];
|
||||
}
|
||||
@ -282,8 +272,6 @@ export default abstract class BattleInfo extends Phaser.GameObjects.Container {
|
||||
this.name = pokemon.getNameToRender();
|
||||
this.box.name = pokemon.getNameToRender();
|
||||
|
||||
this.flyoutMenu?.initInfo(pokemon);
|
||||
|
||||
this.genderText.setText(getGenderSymbol(pokemon.gender));
|
||||
this.genderText.setColor(getGenderColor(pokemon.gender));
|
||||
this.genderText.setPositionRelative(this.nameText, nameTextWidth, 0);
|
||||
@ -877,39 +865,6 @@ export default abstract class BattleInfo extends Phaser.GameObjects.Container {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Request the flyoutMenu to toggle if available and hides or shows the effectiveness window where necessary
|
||||
*/
|
||||
toggleFlyout(visible: boolean): void {
|
||||
this.flyoutMenu?.toggleFlyout(visible);
|
||||
|
||||
if (visible) {
|
||||
this.effectivenessContainer?.setVisible(false);
|
||||
} else {
|
||||
this.updateEffectiveness(this.currentEffectiveness);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Show or hide the type effectiveness multiplier window
|
||||
* Passing undefined will hide the window
|
||||
*/
|
||||
updateEffectiveness(effectiveness?: string) {
|
||||
if (this.player) {
|
||||
return;
|
||||
}
|
||||
this.currentEffectiveness = effectiveness;
|
||||
|
||||
if (!globalScene.typeHints || effectiveness === undefined || this.flyoutMenu?.flyoutVisible) {
|
||||
this.effectivenessContainer.setVisible(false);
|
||||
return;
|
||||
}
|
||||
|
||||
this.effectivenessText.setText(effectiveness);
|
||||
this.effectivenessWindow.width = 10 + this.effectivenessText.displayWidth;
|
||||
this.effectivenessContainer.setVisible(true);
|
||||
}
|
||||
|
||||
getBaseY(): number {
|
||||
return this.baseY;
|
||||
}
|
||||
|
@ -4,12 +4,13 @@ import BattleFlyout from "../battle-flyout";
|
||||
import { addTextObject, TextStyle } from "#app/ui/text";
|
||||
import { addWindow, WindowVariant } from "#app/ui/ui-theme";
|
||||
import { Stat } from "#enums/stat";
|
||||
import type { EnemyPokemon } from "#app/field/pokemon";
|
||||
|
||||
export class EnemyBattleInfo extends BattleInfo {
|
||||
protected player: false = false;
|
||||
protected championRibbon: Phaser.GameObjects.Sprite;
|
||||
protected ownedIcon: Phaser.GameObjects.Sprite;
|
||||
public flyoutMenu: BattleFlyout;
|
||||
protected flyoutMenu: BattleFlyout;
|
||||
|
||||
// #region Type effectiveness hint objects
|
||||
protected effectivenessContainer: Phaser.GameObjects.Container;
|
||||
@ -52,5 +53,40 @@ export class EnemyBattleInfo extends BattleInfo {
|
||||
this.effectivenessContainer.add([this.effectivenessWindow, this.effectivenessText]);
|
||||
}
|
||||
|
||||
override initInfo(pokemon: EnemyPokemon): void {
|
||||
this.flyoutMenu.initInfo(pokemon);
|
||||
super.initInfo(pokemon);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show or hide the type effectiveness multiplier window
|
||||
* Passing undefined will hide the window
|
||||
*/
|
||||
updateEffectiveness(effectiveness?: string) {
|
||||
this.currentEffectiveness = effectiveness;
|
||||
|
||||
if (!globalScene.typeHints || effectiveness === undefined || this.flyoutMenu.flyoutVisible) {
|
||||
this.effectivenessContainer.setVisible(false);
|
||||
return;
|
||||
}
|
||||
|
||||
this.effectivenessText.setText(effectiveness);
|
||||
this.effectivenessWindow.width = 10 + this.effectivenessText.displayWidth;
|
||||
this.effectivenessContainer.setVisible(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Request the flyoutMenu to toggle if available and hides or shows the effectiveness window where necessary
|
||||
*/
|
||||
toggleFlyout(visible: boolean): void {
|
||||
this.flyoutMenu.toggleFlyout(visible);
|
||||
|
||||
if (visible) {
|
||||
this.effectivenessContainer?.setVisible(false);
|
||||
} else {
|
||||
this.updateEffectiveness(this.currentEffectiveness);
|
||||
}
|
||||
}
|
||||
|
||||
setMini(_mini: boolean): void {} // Always mini
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ import { getLocalizedSpriteKey, fixedInt, padInt } from "#app/utils/common";
|
||||
import { MoveCategory } from "#enums/MoveCategory";
|
||||
import i18next from "i18next";
|
||||
import { Button } from "#enums/buttons";
|
||||
import type { PokemonMove } from "#app/field/pokemon";
|
||||
import type { EnemyPokemon, PokemonMove } from "#app/field/pokemon";
|
||||
import type Pokemon from "#app/field/pokemon";
|
||||
import type { CommandPhase } from "#app/phases/command-phase";
|
||||
import MoveInfoOverlay from "./move-info-overlay";
|
||||
@ -279,7 +279,7 @@ export default class FightUiHandler extends UiHandler implements InfoToggle {
|
||||
this.moveInfoOverlay.show(pokemonMove.getMove());
|
||||
|
||||
pokemon.getOpponents().forEach(opponent => {
|
||||
opponent.updateEffectiveness(this.getEffectivenessText(pokemon, opponent, pokemonMove));
|
||||
(opponent as EnemyPokemon).updateEffectiveness(this.getEffectivenessText(pokemon, opponent, pokemonMove));
|
||||
});
|
||||
}
|
||||
|
||||
@ -391,7 +391,7 @@ export default class FightUiHandler extends UiHandler implements InfoToggle {
|
||||
|
||||
const opponents = (globalScene.getCurrentPhase() as CommandPhase).getPokemon().getOpponents();
|
||||
opponents.forEach(opponent => {
|
||||
opponent.updateEffectiveness(undefined);
|
||||
(opponent as EnemyPokemon).updateEffectiveness(undefined);
|
||||
});
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user