Fix additional cases of missing form data causing crash
parent
39a458cb3a
commit
5fa7921e41
|
@ -397,11 +397,18 @@ export class GameData {
|
||||||
const genderIndex = !female ? 0 : 1;
|
const genderIndex = !female ? 0 : 1;
|
||||||
const data = this.dexData[species.speciesId];
|
const data = this.dexData[species.speciesId];
|
||||||
if (species.forms?.length) {
|
if (species.forms?.length) {
|
||||||
try {
|
const getEntry = () => {
|
||||||
if (species.malePercent !== null)
|
if (species.malePercent !== null)
|
||||||
return data[shinyIndex][formIndex][genderIndex][abilityIndex];
|
return data[shinyIndex][formIndex][genderIndex][abilityIndex];
|
||||||
return data[shinyIndex][formIndex][abilityIndex];
|
return data[shinyIndex][formIndex][abilityIndex];
|
||||||
} catch (err) {
|
};
|
||||||
|
let entry: DexEntry;
|
||||||
|
try {
|
||||||
|
entry = getEntry();
|
||||||
|
} catch (err) { }
|
||||||
|
if (entry)
|
||||||
|
return entry;
|
||||||
|
else {
|
||||||
console.warn(`Form data not found for dex entry for ${species.name}: Restructuring dex entry`);
|
console.warn(`Form data not found for dex entry for ${species.name}: Restructuring dex entry`);
|
||||||
for (let s = 0; s < 2; s++) {
|
for (let s = 0; s < 2; s++) {
|
||||||
const oldData = Object.assign({}, data[s]);
|
const oldData = Object.assign({}, data[s]);
|
||||||
|
@ -411,9 +418,7 @@ export class GameData {
|
||||||
}
|
}
|
||||||
this.saveSystem();
|
this.saveSystem();
|
||||||
}
|
}
|
||||||
if (species.malePercent !== null)
|
return getEntry();
|
||||||
return data[shinyIndex][formIndex][genderIndex][abilityIndex];
|
|
||||||
return data[shinyIndex][formIndex][abilityIndex];
|
|
||||||
} else if (species.malePercent !== null)
|
} else if (species.malePercent !== null)
|
||||||
return data[shinyIndex][genderIndex][abilityIndex];
|
return data[shinyIndex][genderIndex][abilityIndex];
|
||||||
return data[shinyIndex][abilityIndex] as DexEntry;
|
return data[shinyIndex][abilityIndex] as DexEntry;
|
||||||
|
|
|
@ -131,7 +131,7 @@ export default class BattleInfo extends Phaser.GameObjects.Container {
|
||||||
if (!this.player) {
|
if (!this.player) {
|
||||||
const speciesOwned = !!pokemon.scene.gameData.getDefaultDexEntry(pokemon.species)?.entry?.caught;
|
const speciesOwned = !!pokemon.scene.gameData.getDefaultDexEntry(pokemon.species)?.entry?.caught;
|
||||||
this.ownedIcon.setVisible(speciesOwned);
|
this.ownedIcon.setVisible(speciesOwned);
|
||||||
if (!pokemon.scene.gameData.getPokemonDexEntry(pokemon).caught)
|
if (!pokemon.scene.gameData.getPokemonDexEntry(pokemon)?.caught)
|
||||||
this.ownedIcon.setTint(0x808080);
|
this.ownedIcon.setTint(0x808080);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue