Fix IV text not comparing against starter species

This commit is contained in:
Flashfyre 2024-05-01 09:44:57 -04:00
parent eac9b4d385
commit 3b09e176a2
3 changed files with 9 additions and 6 deletions

View File

@ -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;
}

View File

@ -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) => {

View File

@ -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);