From 839264506b634f2d62aeb230aaac438977d36593 Mon Sep 17 00:00:00 2001 From: Flashfyre Date: Sat, 2 Dec 2023 23:31:45 -0500 Subject: [PATCH] Add shiny indicator to battle info --- src/data/pokemon-species.ts | 2 ++ src/pokemon.ts | 1 + src/ui/battle-info.ts | 12 +++++++++++- 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/data/pokemon-species.ts b/src/data/pokemon-species.ts index a3b4a6965..512c7a4b6 100644 --- a/src/data/pokemon-species.ts +++ b/src/data/pokemon-species.ts @@ -45,6 +45,8 @@ export function getFusedSpeciesName(speciesAName: string, speciesBName: string): if (splitNameA.length > 1) fragA = `${splitNameA.slice(0, splitNameA.length - 1).join(' ')} ${fragA}`; + fragB = `${fragB.slice(0, 1).toLowerCase()}${fragB.slice(1)}`; + return `${fragA}${fragB}`; } diff --git a/src/pokemon.ts b/src/pokemon.ts index 52d3435e4..c72e83de2 100644 --- a/src/pokemon.ts +++ b/src/pokemon.ts @@ -240,6 +240,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { return; } this.name = getFusedSpeciesName(this.species.name, this.fusionSpecies.name); + this.updateInfo(true); } abstract isPlayer(): boolean; diff --git a/src/ui/battle-info.ts b/src/ui/battle-info.ts index 8047d91bf..d79727fa4 100644 --- a/src/ui/battle-info.ts +++ b/src/ui/battle-info.ts @@ -25,6 +25,7 @@ export default class BattleInfo extends Phaser.GameObjects.Container { private genderText: Phaser.GameObjects.Text; private ownedIcon: Phaser.GameObjects.Sprite; private splicedIcon: Phaser.GameObjects.Sprite; + private shinyIcon: Phaser.GameObjects.Sprite; private statusIndicator: Phaser.GameObjects.Sprite; private levelContainer: Phaser.GameObjects.Container; private hpBar: Phaser.GameObjects.Image; @@ -89,6 +90,12 @@ export default class BattleInfo extends Phaser.GameObjects.Container { const levelOverlay = this.scene.add.image(0, 0, 'overlay_lv'); this.levelContainer.add(levelOverlay); + this.shinyIcon = this.scene.add.sprite(0, 0, 'shiny_star'); + this.shinyIcon.setVisible(false); + this.shinyIcon.setOrigin(0, 0); + this.shinyIcon.setPositionRelative(this.levelContainer, -12, -5); + this.add(this.shinyIcon); + this.hpBar = this.scene.add.image(player ? -61 : -71, player ? -1 : 4.5, 'overlay_hp'); this.hpBar.setOrigin(0); this.add(this.hpBar); @@ -124,7 +131,7 @@ export default class BattleInfo extends Phaser.GameObjects.Container { this.splicedIcon.setPositionRelative(this.nameText, nameTextWidth + this.genderText.displayWidth + 1, 1); this.splicedIcon.setVisible(!!pokemon.fusionSpecies); if (this.splicedIcon.visible) { - this.splicedIcon.on('pointerover', () => (this.scene as BattleScene).ui.showTooltip(null, `Spliced with ${pokemon.fusionSpecies.name}`)); + this.splicedIcon.on('pointerover', () => (this.scene as BattleScene).ui.showTooltip(null, `${pokemon.species.name}/${pokemon.fusionSpecies.name}`)); this.splicedIcon.on('pointerout', () => (this.scene as BattleScene).ui.hideTooltip()); } @@ -270,6 +277,8 @@ export default class BattleInfo extends Phaser.GameObjects.Container { this.lastLevel = pokemon.level; } + this.shinyIcon.setVisible(pokemon.isShiny()); + resolve(); }); } @@ -330,6 +339,7 @@ export default class BattleInfo extends Phaser.GameObjects.Container { for (let i = 0; i < levelStr.length; i++) this.levelNumbersContainer.add(this.scene.add.image(i * 8, 0, `numbers${isCapped && this.player ? '_red' : ''}`, levelStr[i])); this.levelContainer.setX((this.player ? -41 : -50) - 8 * Math.max(levelStr.length - 3, 0)); + this.shinyIcon.setPositionRelative(this.levelContainer, -12, -5); } setHpNumbers(hp: integer, maxHp: integer) {