From fdc2d1cd026d1533acb0f652b7ad8a427de378ad Mon Sep 17 00:00:00 2001 From: ReneGV Date: Sun, 9 Jun 2024 10:45:21 -0600 Subject: [PATCH] [enhacement] Show Egg tier icon on starter UI (#1933) * Show Egg tier on starter UI * Use CamelCase on method name * Remove egg if evolved * Adding ts-doc --- src/data/egg.ts | 19 ++++++++++++++++++- src/ui/starter-select-ui-handler.ts | 29 ++++++++++++++++++++++++----- 2 files changed, 42 insertions(+), 6 deletions(-) diff --git a/src/data/egg.ts b/src/data/egg.ts index 74371049363..da6100446ec 100644 --- a/src/data/egg.ts +++ b/src/data/egg.ts @@ -1,6 +1,6 @@ import BattleScene from "../battle-scene"; import { Species } from "./enums/species"; -import { getPokemonSpecies, speciesStarters } from "./pokemon-species"; +import PokemonSpecies, { getPokemonSpecies, speciesStarters } from "./pokemon-species"; import { EggTier } from "./enums/egg-type"; import i18next from "../plugins/i18n"; @@ -111,3 +111,20 @@ export function getLegendaryGachaSpeciesForTimestamp(scene: BattleScene, timesta return ret; } + +/** + * Check for a given species EggTier Value + * @param species - Species for wich we will check the egg tier it belongs to + * @returns The egg tier of a given pokemon species + */ +export function getEggTierForSpecies(pokemonSpecies :PokemonSpecies): EggTier { + const speciesBaseValue = speciesStarters[pokemonSpecies.getRootSpeciesId()]; + if (speciesBaseValue <= 3) { + return EggTier.COMMON; + } else if (speciesBaseValue <= 5) { + return EggTier.GREAT; + } else if (speciesBaseValue <= 7) { + return EggTier.ULTRA; + } + return EggTier.MASTER; +} diff --git a/src/ui/starter-select-ui-handler.ts b/src/ui/starter-select-ui-handler.ts index 71b61b99e9c..e6be659ce7d 100644 --- a/src/ui/starter-select-ui-handler.ts +++ b/src/ui/starter-select-ui-handler.ts @@ -35,6 +35,7 @@ import {SettingKeyboard} from "#app/system/settings/settings-keyboard"; import {Device} from "#app/enums/devices"; import * as Challenge from "../data/challenge"; import MoveInfoOverlay from "./move-info-overlay"; +import { getEggTierForSpecies } from "#app/data/egg.js"; export type StarterSelectCallback = (starters: Starter[]) => void; @@ -189,6 +190,7 @@ export default class StarterSelectUiHandler extends MessageUiHandler { private pokemonCandyCountText: Phaser.GameObjects.Text; private pokemonCaughtHatchedContainer: Phaser.GameObjects.Container; private pokemonCaughtCountText: Phaser.GameObjects.Text; + private pokemonHatchedIcon : Phaser.GameObjects.Sprite; private pokemonHatchedCountText: Phaser.GameObjects.Text; private genOptionsText: Phaser.GameObjects.Text; private instructionsContainer: Phaser.GameObjects.Container; @@ -585,10 +587,10 @@ export default class StarterSelectUiHandler extends MessageUiHandler { this.pokemonCaughtCountText.setOrigin(0, 0); this.pokemonCaughtHatchedContainer.add(this.pokemonCaughtCountText); - const pokemonHatchedIcon = this.scene.add.sprite(1, 14, "items", "mystery_egg"); - pokemonHatchedIcon.setOrigin(0, 0); - pokemonHatchedIcon.setScale(0.75); - this.pokemonCaughtHatchedContainer.add(pokemonHatchedIcon); + this.pokemonHatchedIcon = this.scene.add.sprite(1, 14, "egg_icons"); + this.pokemonHatchedIcon.setOrigin(0.15, 0.2); + this.pokemonHatchedIcon.setScale(0.8); + this.pokemonCaughtHatchedContainer.add(this.pokemonHatchedIcon); this.pokemonHatchedCountText = addTextObject(this.scene, 24, 19, "0", TextStyle.SUMMARY_ALT); this.pokemonHatchedCountText.setOrigin(0, 0); @@ -1776,11 +1778,26 @@ export default class StarterSelectUiHandler extends MessageUiHandler { this.pokemonPassiveLabelText.setVisible(true); this.pokemonNatureLabelText.setVisible(true); this.pokemonCaughtCountText.setText(`${this.speciesStarterDexEntry.caughtCount}`); + if (species.speciesId === Species.MANAPHY || species.speciesId === Species.PHIONE) { + this.pokemonHatchedIcon.setFrame("manaphy"); + } else { + this.pokemonHatchedIcon.setFrame(getEggTierForSpecies(species)); + } this.pokemonHatchedCountText.setText(`${this.speciesStarterDexEntry.hatchedCount}`); this.pokemonCaughtHatchedContainer.setVisible(true); if (pokemonPrevolutions.hasOwnProperty(species.speciesId)) { this.pokemonCaughtHatchedContainer.setY(16); - [ this.pokemonCandyIcon, this.pokemonCandyOverlayIcon, this.pokemonCandyDarknessOverlay, this.pokemonCandyCountText ].map(c => c.setVisible(false)); + [ + this.pokemonCandyIcon, + this.pokemonCandyOverlayIcon, + this.pokemonCandyDarknessOverlay, + this.pokemonCandyCountText, + this.pokemonHatchedIcon, + this.pokemonHatchedCountText + ].map(c => c.setVisible(false)); + } else if (species.speciesId === Species.ETERNATUS) { + this.pokemonHatchedIcon.setVisible(false); + this.pokemonHatchedCountText.setVisible(false); } else { this.pokemonCaughtHatchedContainer.setY(25); this.pokemonCandyIcon.setTint(argbFromRgba(Utils.rgbHexToRgba(colorScheme[0]))); @@ -1791,6 +1808,8 @@ export default class StarterSelectUiHandler extends MessageUiHandler { this.pokemonCandyCountText.setText(`x${this.scene.gameData.starterData[species.speciesId].candyCount}`); this.pokemonCandyCountText.setVisible(true); this.pokemonFormText.setVisible(true); + this.pokemonHatchedIcon.setVisible(true); + this.pokemonHatchedCountText.setVisible(true); let currentFriendship = this.scene.gameData.starterData[this.lastSpecies.speciesId].friendship; if (!currentFriendship || currentFriendship === undefined) {