mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-07-05 16:02:20 +02:00
Move subclass specific parts of constructor to subclass constructor
This commit is contained in:
parent
3baaffd057
commit
ec3a54273d
@ -9,72 +9,80 @@ import { getTypeRgb } from "#app/data/type";
|
|||||||
import { PokemonType } from "#enums/pokemon-type";
|
import { PokemonType } from "#enums/pokemon-type";
|
||||||
import { getVariantTint } from "#app/sprites/variant";
|
import { getVariantTint } from "#app/sprites/variant";
|
||||||
import { Stat } from "#enums/stat";
|
import { Stat } from "#enums/stat";
|
||||||
import BattleFlyout from "../battle-flyout";
|
import type BattleFlyout from "../battle-flyout";
|
||||||
import { WindowVariant, addWindow } from "../ui-theme";
|
|
||||||
import i18next from "i18next";
|
import i18next from "i18next";
|
||||||
import { ExpGainsSpeed } from "#app/enums/exp-gains-speed";
|
import { ExpGainsSpeed } from "#app/enums/exp-gains-speed";
|
||||||
|
|
||||||
export default class BattleInfo extends Phaser.GameObjects.Container {
|
export default class BattleInfo extends Phaser.GameObjects.Container {
|
||||||
public static readonly EXP_GAINS_DURATION_BASE = 1650;
|
public static readonly EXP_GAINS_DURATION_BASE = 1650;
|
||||||
|
|
||||||
private baseY: number;
|
protected baseY: number;
|
||||||
|
|
||||||
private player: boolean;
|
protected player: boolean;
|
||||||
private mini: boolean;
|
protected mini: boolean;
|
||||||
private boss: boolean;
|
protected boss: boolean;
|
||||||
private bossSegments: number;
|
protected bossSegments: number;
|
||||||
private offset: boolean;
|
protected offset: boolean;
|
||||||
private lastName: string | null;
|
protected lastName: string | null;
|
||||||
private lastTeraType: PokemonType;
|
protected lastTeraType: PokemonType;
|
||||||
private lastStatus: StatusEffect;
|
protected lastStatus: StatusEffect;
|
||||||
private lastHp: number;
|
protected lastHp: number;
|
||||||
private lastMaxHp: number;
|
protected lastMaxHp: number;
|
||||||
private lastHpFrame: string | null;
|
protected lastHpFrame: string | null;
|
||||||
private lastExp: number;
|
protected lastExp: number;
|
||||||
private lastLevelExp: number;
|
protected lastLevelExp: number;
|
||||||
private lastLevel: number;
|
protected lastLevel: number;
|
||||||
private lastLevelCapped: boolean;
|
protected lastLevelCapped: boolean;
|
||||||
private lastStats: string;
|
protected lastStats: string;
|
||||||
|
|
||||||
private box: Phaser.GameObjects.Sprite;
|
protected box: Phaser.GameObjects.Sprite;
|
||||||
private nameText: Phaser.GameObjects.Text;
|
protected nameText: Phaser.GameObjects.Text;
|
||||||
private genderText: Phaser.GameObjects.Text;
|
protected genderText: Phaser.GameObjects.Text;
|
||||||
private ownedIcon: Phaser.GameObjects.Sprite;
|
protected ownedIcon: Phaser.GameObjects.Sprite;
|
||||||
private championRibbon: Phaser.GameObjects.Sprite;
|
protected championRibbon: Phaser.GameObjects.Sprite;
|
||||||
private teraIcon: Phaser.GameObjects.Sprite;
|
protected teraIcon: Phaser.GameObjects.Sprite;
|
||||||
private shinyIcon: Phaser.GameObjects.Sprite;
|
protected shinyIcon: Phaser.GameObjects.Sprite;
|
||||||
private fusionShinyIcon: Phaser.GameObjects.Sprite;
|
protected fusionShinyIcon: Phaser.GameObjects.Sprite;
|
||||||
private splicedIcon: Phaser.GameObjects.Sprite;
|
protected splicedIcon: Phaser.GameObjects.Sprite;
|
||||||
private statusIndicator: Phaser.GameObjects.Sprite;
|
protected statusIndicator: Phaser.GameObjects.Sprite;
|
||||||
private levelContainer: Phaser.GameObjects.Container;
|
protected levelContainer: Phaser.GameObjects.Container;
|
||||||
private hpBar: Phaser.GameObjects.Image;
|
protected hpBar: Phaser.GameObjects.Image;
|
||||||
private hpBarSegmentDividers: Phaser.GameObjects.Rectangle[];
|
protected hpBarSegmentDividers: Phaser.GameObjects.Rectangle[];
|
||||||
private levelNumbersContainer: Phaser.GameObjects.Container;
|
protected levelNumbersContainer: Phaser.GameObjects.Container;
|
||||||
private hpNumbersContainer: Phaser.GameObjects.Container;
|
protected hpNumbersContainer: Phaser.GameObjects.Container;
|
||||||
private type1Icon: Phaser.GameObjects.Sprite;
|
protected type1Icon: Phaser.GameObjects.Sprite;
|
||||||
private type2Icon: Phaser.GameObjects.Sprite;
|
protected type2Icon: Phaser.GameObjects.Sprite;
|
||||||
private type3Icon: Phaser.GameObjects.Sprite;
|
protected type3Icon: Phaser.GameObjects.Sprite;
|
||||||
private expBar: Phaser.GameObjects.Image;
|
protected expBar: Phaser.GameObjects.Image;
|
||||||
|
|
||||||
// #region Type effectiveness hint objects
|
// #region Type effectiveness hint objects
|
||||||
private effectivenessContainer: Phaser.GameObjects.Container;
|
protected effectivenessContainer: Phaser.GameObjects.Container;
|
||||||
private effectivenessWindow: Phaser.GameObjects.NineSlice;
|
protected effectivenessWindow: Phaser.GameObjects.NineSlice;
|
||||||
private effectivenessText: Phaser.GameObjects.Text;
|
protected effectivenessText: Phaser.GameObjects.Text;
|
||||||
private currentEffectiveness?: string;
|
protected currentEffectiveness?: string;
|
||||||
// #endregion
|
// #endregion
|
||||||
|
|
||||||
public expMaskRect: Phaser.GameObjects.Graphics;
|
public expMaskRect: Phaser.GameObjects.Graphics;
|
||||||
|
|
||||||
private statsContainer: Phaser.GameObjects.Container;
|
protected statsContainer: Phaser.GameObjects.Container;
|
||||||
private statsBox: Phaser.GameObjects.Sprite;
|
protected statsBox: Phaser.GameObjects.Sprite;
|
||||||
private statValuesContainer: Phaser.GameObjects.Container;
|
protected statValuesContainer: Phaser.GameObjects.Container;
|
||||||
private statNumbers: Phaser.GameObjects.Sprite[];
|
protected statNumbers: Phaser.GameObjects.Sprite[];
|
||||||
|
|
||||||
public flyoutMenu?: BattleFlyout;
|
public flyoutMenu?: BattleFlyout;
|
||||||
|
|
||||||
private statOrder: Stat[];
|
protected statOrder: Stat[];
|
||||||
private readonly statOrderPlayer = [Stat.ATK, Stat.DEF, Stat.SPATK, Stat.SPDEF, Stat.ACC, Stat.EVA, Stat.SPD];
|
protected readonly statOrderPlayer = [Stat.ATK, Stat.DEF, Stat.SPATK, Stat.SPDEF, Stat.ACC, Stat.EVA, Stat.SPD];
|
||||||
private readonly statOrderEnemy = [Stat.HP, 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,
|
||||||
|
];
|
||||||
|
|
||||||
constructor(x: number, y: number, player: boolean) {
|
constructor(x: number, y: number, player: boolean) {
|
||||||
super(globalScene, x, y);
|
super(globalScene, x, y);
|
||||||
@ -112,22 +120,6 @@ export default class BattleInfo extends Phaser.GameObjects.Container {
|
|||||||
this.genderText.setPositionRelative(this.nameText, 0, 2);
|
this.genderText.setPositionRelative(this.nameText, 0, 2);
|
||||||
this.add(this.genderText);
|
this.add(this.genderText);
|
||||||
|
|
||||||
if (!this.player) {
|
|
||||||
this.ownedIcon = globalScene.add.sprite(0, 0, "icon_owned");
|
|
||||||
this.ownedIcon.setName("icon_owned");
|
|
||||||
this.ownedIcon.setVisible(false);
|
|
||||||
this.ownedIcon.setOrigin(0, 0);
|
|
||||||
this.ownedIcon.setPositionRelative(this.nameText, 0, 11.75);
|
|
||||||
this.add(this.ownedIcon);
|
|
||||||
|
|
||||||
this.championRibbon = globalScene.add.sprite(0, 0, "champion_ribbon");
|
|
||||||
this.championRibbon.setName("icon_champion_ribbon");
|
|
||||||
this.championRibbon.setVisible(false);
|
|
||||||
this.championRibbon.setOrigin(0, 0);
|
|
||||||
this.championRibbon.setPositionRelative(this.nameText, 8, 11.75);
|
|
||||||
this.add(this.championRibbon);
|
|
||||||
}
|
|
||||||
|
|
||||||
this.teraIcon = globalScene.add.sprite(0, 0, "icon_tera");
|
this.teraIcon = globalScene.add.sprite(0, 0, "icon_tera");
|
||||||
this.teraIcon.setName("icon_tera");
|
this.teraIcon.setName("icon_tera");
|
||||||
this.teraIcon.setVisible(false);
|
this.teraIcon.setVisible(false);
|
||||||
@ -188,30 +180,6 @@ export default class BattleInfo extends Phaser.GameObjects.Container {
|
|||||||
this.levelNumbersContainer.setName("container_level");
|
this.levelNumbersContainer.setName("container_level");
|
||||||
this.levelContainer.add(this.levelNumbersContainer);
|
this.levelContainer.add(this.levelNumbersContainer);
|
||||||
|
|
||||||
if (this.player) {
|
|
||||||
this.hpNumbersContainer = globalScene.add.container(-15, 10);
|
|
||||||
this.hpNumbersContainer.setName("container_hp");
|
|
||||||
this.add(this.hpNumbersContainer);
|
|
||||||
|
|
||||||
const expBar = globalScene.add.image(-98, 18, "overlay_exp");
|
|
||||||
expBar.setName("overlay_exp");
|
|
||||||
expBar.setOrigin(0);
|
|
||||||
this.add(expBar);
|
|
||||||
|
|
||||||
const expMaskRect = globalScene.make.graphics({});
|
|
||||||
expMaskRect.setScale(6);
|
|
||||||
expMaskRect.fillStyle(0xffffff);
|
|
||||||
expMaskRect.beginPath();
|
|
||||||
expMaskRect.fillRect(127, 126, 85, 2);
|
|
||||||
|
|
||||||
const expMask = expMaskRect.createGeometryMask();
|
|
||||||
|
|
||||||
expBar.setMask(expMask);
|
|
||||||
|
|
||||||
this.expBar = expBar;
|
|
||||||
this.expMaskRect = expMaskRect;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.statsContainer = globalScene.add.container(0, 0);
|
this.statsContainer = globalScene.add.container(0, 0);
|
||||||
this.statsContainer.setName("container_stats");
|
this.statsContainer.setName("container_stats");
|
||||||
this.statsContainer.setAlpha(0);
|
this.statsContainer.setAlpha(0);
|
||||||
@ -275,13 +243,6 @@ export default class BattleInfo extends Phaser.GameObjects.Container {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!this.player) {
|
|
||||||
this.flyoutMenu = new BattleFlyout(this.player);
|
|
||||||
this.add(this.flyoutMenu);
|
|
||||||
|
|
||||||
this.moveBelow<Phaser.GameObjects.GameObject>(this.flyoutMenu, this.box);
|
|
||||||
}
|
|
||||||
|
|
||||||
this.type1Icon = globalScene.add.sprite(
|
this.type1Icon = globalScene.add.sprite(
|
||||||
player ? -139 : -15,
|
player ? -139 : -15,
|
||||||
player ? -17 : -15.5,
|
player ? -17 : -15.5,
|
||||||
@ -308,19 +269,6 @@ export default class BattleInfo extends Phaser.GameObjects.Container {
|
|||||||
this.type3Icon.setName("icon_type_3");
|
this.type3Icon.setName("icon_type_3");
|
||||||
this.type3Icon.setOrigin(0, 0);
|
this.type3Icon.setOrigin(0, 0);
|
||||||
this.add(this.type3Icon);
|
this.add(this.type3Icon);
|
||||||
|
|
||||||
if (!this.player) {
|
|
||||||
this.effectivenessContainer = globalScene.add.container(0, 0);
|
|
||||||
this.effectivenessContainer.setPositionRelative(this.type1Icon, 22, 4);
|
|
||||||
this.effectivenessContainer.setVisible(false);
|
|
||||||
this.add(this.effectivenessContainer);
|
|
||||||
|
|
||||||
this.effectivenessText = addTextObject(5, 4.5, "", TextStyle.BATTLE_INFO);
|
|
||||||
this.effectivenessWindow = addWindow(0, 0, 0, 20, undefined, false, undefined, undefined, WindowVariant.XTHIN);
|
|
||||||
|
|
||||||
this.effectivenessContainer.add(this.effectivenessWindow);
|
|
||||||
this.effectivenessContainer.add(this.effectivenessText);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
getStatsValueContainer(): Phaser.GameObjects.Container {
|
getStatsValueContainer(): Phaser.GameObjects.Container {
|
||||||
|
@ -1,8 +1,42 @@
|
|||||||
import BattleInfo from "./battle-info";
|
import BattleInfo from "./battle-info";
|
||||||
|
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";
|
||||||
|
|
||||||
export class EnemyBattleInfo extends BattleInfo {
|
export class EnemyBattleInfo extends BattleInfo {
|
||||||
constructor() {
|
constructor() {
|
||||||
super(140, -141, false);
|
super(140, -141, false);
|
||||||
|
|
||||||
|
this.ownedIcon = globalScene.add.sprite(0, 0, "icon_owned");
|
||||||
|
this.ownedIcon.setName("icon_owned");
|
||||||
|
this.ownedIcon.setVisible(false);
|
||||||
|
this.ownedIcon.setOrigin(0, 0);
|
||||||
|
this.ownedIcon.setPositionRelative(this.nameText, 0, 11.75);
|
||||||
|
this.add(this.ownedIcon);
|
||||||
|
|
||||||
|
this.championRibbon = globalScene.add.sprite(0, 0, "champion_ribbon");
|
||||||
|
this.championRibbon.setName("icon_champion_ribbon");
|
||||||
|
this.championRibbon.setVisible(false);
|
||||||
|
this.championRibbon.setOrigin(0, 0);
|
||||||
|
this.championRibbon.setPositionRelative(this.nameText, 8, 11.75);
|
||||||
|
this.add(this.championRibbon);
|
||||||
|
|
||||||
|
this.flyoutMenu = new BattleFlyout(this.player);
|
||||||
|
this.add(this.flyoutMenu);
|
||||||
|
|
||||||
|
this.moveBelow<Phaser.GameObjects.GameObject>(this.flyoutMenu, this.box);
|
||||||
|
|
||||||
|
this.effectivenessContainer = globalScene.add.container(0, 0);
|
||||||
|
this.effectivenessContainer.setPositionRelative(this.type1Icon, 22, 4);
|
||||||
|
this.effectivenessContainer.setVisible(false);
|
||||||
|
this.add(this.effectivenessContainer);
|
||||||
|
|
||||||
|
this.effectivenessText = addTextObject(5, 4.5, "", TextStyle.BATTLE_INFO);
|
||||||
|
this.effectivenessWindow = addWindow(0, 0, 0, 20, undefined, false, undefined, undefined, WindowVariant.XTHIN);
|
||||||
|
|
||||||
|
this.effectivenessContainer.add(this.effectivenessWindow);
|
||||||
|
this.effectivenessContainer.add(this.effectivenessText);
|
||||||
}
|
}
|
||||||
|
|
||||||
setMini(_mini: boolean): void {} // Always mini
|
setMini(_mini: boolean): void {} // Always mini
|
||||||
|
@ -4,5 +4,27 @@ import BattleInfo from "./battle-info";
|
|||||||
export class PlayerBattleInfo extends BattleInfo {
|
export class PlayerBattleInfo extends BattleInfo {
|
||||||
constructor() {
|
constructor() {
|
||||||
super(Math.floor(globalScene.game.canvas.width / 6) - 10, -72, true);
|
super(Math.floor(globalScene.game.canvas.width / 6) - 10, -72, true);
|
||||||
|
|
||||||
|
this.hpNumbersContainer = globalScene.add.container(-15, 10);
|
||||||
|
this.hpNumbersContainer.setName("container_hp");
|
||||||
|
this.add(this.hpNumbersContainer);
|
||||||
|
|
||||||
|
const expBar = globalScene.add.image(-98, 18, "overlay_exp");
|
||||||
|
expBar.setName("overlay_exp");
|
||||||
|
expBar.setOrigin(0);
|
||||||
|
this.add(expBar);
|
||||||
|
|
||||||
|
const expMaskRect = globalScene.make.graphics({});
|
||||||
|
expMaskRect.setScale(6);
|
||||||
|
expMaskRect.fillStyle(0xffffff);
|
||||||
|
expMaskRect.beginPath();
|
||||||
|
expMaskRect.fillRect(127, 126, 85, 2);
|
||||||
|
|
||||||
|
const expMask = expMaskRect.createGeometryMask();
|
||||||
|
|
||||||
|
expBar.setMask(expMask);
|
||||||
|
|
||||||
|
this.expBar = expBar;
|
||||||
|
this.expMaskRect = expMaskRect;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user