From 3b09e176a29922ef8a20d028eb345eb72bc3df66 Mon Sep 17 00:00:00 2001 From: Flashfyre Date: Wed, 1 May 2024 09:44:57 -0400 Subject: [PATCH] Fix IV text not comparing against starter species --- src/data/pokemon-species.ts | 4 ++-- src/ui/battle-message-ui-handler.ts | 6 ++++-- src/ui/pokemon-info-container.ts | 5 +++-- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/data/pokemon-species.ts b/src/data/pokemon-species.ts index 4136be5b70f..2f8edefa403 100644 --- a/src/data/pokemon-species.ts +++ b/src/data/pokemon-species.ts @@ -138,9 +138,9 @@ export abstract class PokemonSpeciesForm { this.genderDiffs = genderDiffs; } - getRootSpeciesId(): Species { + getRootSpeciesId(forStarter: boolean = false): Species { let ret = this.speciesId; - while (pokemonPrevolutions.hasOwnProperty(ret)) + while (pokemonPrevolutions.hasOwnProperty(ret) && (!forStarter || !speciesStarters.hasOwnProperty(ret))) ret = pokemonPrevolutions[ret]; return ret; } diff --git a/src/ui/battle-message-ui-handler.ts b/src/ui/battle-message-ui-handler.ts index 77144d6bbc0..7819017d896 100644 --- a/src/ui/battle-message-ui-handler.ts +++ b/src/ui/battle-message-ui-handler.ts @@ -5,6 +5,7 @@ import * as Utils from "../utils"; import MessageUiHandler from "./message-ui-handler"; import { getStatName, Stat } from "../data/pokemon-stat"; import { addWindow } from "./ui-theme"; +import BBCodeText from "phaser3-rex-plugins/plugins/bbcodetext"; export default class BattleMessageUiHandler extends MessageUiHandler { private levelUpStatsContainer: Phaser.GameObjects.Container; @@ -223,8 +224,9 @@ export default class BattleMessageUiHandler extends MessageUiHandler { } getIvDescriptor(value: integer, typeIv: integer): string { - let starterIvs: number[] = this.scene.gameData.dexData[this.scene.getEnemyPokemon().species.speciesId].ivs; - let uiTheme = (this.scene as BattleScene).uiTheme; // Assuming uiTheme is accessible + const starterSpecies = this.scene.getEnemyPokemon().species.getRootSpeciesId(true); + const starterIvs: number[] = this.scene.gameData.dexData[starterSpecies].ivs; + const uiTheme = (this.scene as BattleScene).uiTheme; // Assuming uiTheme is accessible // Function to wrap text in color based on comparison const coloredText = (text: string, isBetter: boolean) => { diff --git a/src/ui/pokemon-info-container.ts b/src/ui/pokemon-info-container.ts index 4d8ecfe0b03..572a28f10c8 100644 --- a/src/ui/pokemon-info-container.ts +++ b/src/ui/pokemon-info-container.ts @@ -161,8 +161,9 @@ export default class PokemonInfoContainer extends Phaser.GameObjects.Container { if (isFusion) this.pokemonFusionShinyIcon.setTint(getVariantTint(pokemon.fusionVariant)); - const originalIvs: integer[] = this.scene.gameData.dexData[pokemon.species.speciesId].caughtAttr - ? this.scene.gameData.dexData[pokemon.species.speciesId].ivs + const starterSpeciesId = pokemon.species.getRootSpeciesId(true); + const originalIvs: integer[] = this.scene.gameData.dexData[starterSpeciesId].caughtAttr + ? this.scene.gameData.dexData[starterSpeciesId].ivs : null; this.statsContainer.updateIvs(pokemon.ivs, originalIvs);