From d69fc04188a702f4fd085fcea4998b37a5b7f8ba Mon Sep 17 00:00:00 2001 From: Sirz Benjie <142067137+SirzBenjie@users.noreply.github.com> Date: Wed, 23 Apr 2025 09:46:53 -0500 Subject: [PATCH] Make statOrder specific to subclass --- src/ui/battle-info/battle-info.ts | 22 ++++++---------------- src/ui/battle-info/enemy-battle-info.ts | 17 +++++++++++++++++ src/ui/battle-info/player-battle-info.ts | 11 ++++++----- 3 files changed, 29 insertions(+), 21 deletions(-) diff --git a/src/ui/battle-info/battle-info.ts b/src/ui/battle-info/battle-info.ts index 52ed151e61e..73221c5a28a 100644 --- a/src/ui/battle-info/battle-info.ts +++ b/src/ui/battle-info/battle-info.ts @@ -13,7 +13,7 @@ import type BattleFlyout from "../battle-flyout"; import i18next from "i18next"; import { ExpGainsSpeed } from "#app/enums/exp-gains-speed"; -export default class BattleInfo extends Phaser.GameObjects.Container { +export default abstract class BattleInfo extends Phaser.GameObjects.Container { public static readonly EXP_GAINS_DURATION_BASE = 1650; protected baseY: number; @@ -71,18 +71,9 @@ export default class BattleInfo extends Phaser.GameObjects.Container { public flyoutMenu?: BattleFlyout; - protected statOrder: Stat[]; - protected readonly statOrderPlayer = [Stat.ATK, Stat.DEF, Stat.SPATK, Stat.SPDEF, Stat.ACC, Stat.EVA, Stat.SPD]; - protected readonly statOrderEnemy = [ - Stat.HP, - Stat.ATK, - Stat.DEF, - Stat.SPATK, - Stat.SPDEF, - Stat.ACC, - Stat.EVA, - Stat.SPD, - ]; + get statOrder(): Stat[] { + return []; + } constructor(x: number, y: number, player: boolean) { super(globalScene, x, y); @@ -201,9 +192,8 @@ export default class BattleInfo extends Phaser.GameObjects.Container { const startingX = this.player ? -this.statsBox.width + 8 : -this.statsBox.width + 5; const paddingX = this.player ? 4 : 2; const statOverflow = this.player ? 1 : 0; - this.statOrder = this.player ? this.statOrderPlayer : this.statOrderEnemy; // this tells us whether or not to use the player or enemy battle stat order - this.statOrder.map((s, i) => { + for (const [i, s] of this.statOrder.entries()) { // we do a check for i > statOverflow to see when the stat labels go onto the next column // For enemies, we have HP (i=0) by itself then a new column, so we check for i > 0 // For players, we don't have HP, so we start with i = 0 and i = 1 for our first column, and so need to check for i > 1 @@ -241,7 +231,7 @@ export default class BattleInfo extends Phaser.GameObjects.Container { statLabel.setVisible(false); statNumber.setVisible(false); } - }); + } this.type1Icon = globalScene.add.sprite( player ? -139 : -15, diff --git a/src/ui/battle-info/enemy-battle-info.ts b/src/ui/battle-info/enemy-battle-info.ts index 17da661a7c0..eb55cd07ee9 100644 --- a/src/ui/battle-info/enemy-battle-info.ts +++ b/src/ui/battle-info/enemy-battle-info.ts @@ -3,8 +3,25 @@ import { globalScene } from "#app/global-scene"; 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"; export class EnemyBattleInfo extends BattleInfo { + protected player: false = false; + protected championRibbon: Phaser.GameObjects.Sprite; + protected ownedIcon: Phaser.GameObjects.Sprite; + public flyoutMenu: BattleFlyout; + + // #region Type effectiveness hint objects + protected effectivenessContainer: Phaser.GameObjects.Container; + protected effectivenessWindow: Phaser.GameObjects.NineSlice; + protected effectivenessText: Phaser.GameObjects.Text; + protected currentEffectiveness?: string; + // #endregion + + override get statOrder(): Stat[] { + return [Stat.HP, Stat.ATK, Stat.DEF, Stat.SPATK, Stat.SPDEF, Stat.ACC, Stat.EVA, Stat.SPD]; + } + constructor() { super(140, -141, false); diff --git a/src/ui/battle-info/player-battle-info.ts b/src/ui/battle-info/player-battle-info.ts index 0ad965eea9b..10e827c96e4 100644 --- a/src/ui/battle-info/player-battle-info.ts +++ b/src/ui/battle-info/player-battle-info.ts @@ -1,17 +1,18 @@ import { globalScene } from "#app/global-scene"; +import { Stat } from "#enums/stat"; import BattleInfo from "./battle-info"; export class PlayerBattleInfo extends BattleInfo { + override get statOrder(): Stat[] { + return [Stat.ATK, Stat.DEF, Stat.SPATK, Stat.SPDEF, Stat.ACC, Stat.EVA, Stat.SPD]; + } constructor() { super(Math.floor(globalScene.game.canvas.width / 6) - 10, -72, true); - this.hpNumbersContainer = globalScene.add.container(-15, 10); - this.hpNumbersContainer.setName("container_hp"); + this.hpNumbersContainer = globalScene.add.container(-15, 10).setName("container_hp"); this.add(this.hpNumbersContainer); - const expBar = globalScene.add.image(-98, 18, "overlay_exp"); - expBar.setName("overlay_exp"); - expBar.setOrigin(0); + const expBar = globalScene.add.image(-98, 18, "overlay_exp").setName("overlay_exp").setOrigin(0); this.add(expBar); const expMaskRect = globalScene.make