Add fix for missing form data in dex

pull/2/head
Flashfyre 2023-11-04 23:09:46 -04:00
parent 49a2231245
commit bd8fa9811f
1 changed files with 14 additions and 0 deletions

View File

@ -397,6 +397,20 @@ export class GameData {
const genderIndex = !female ? 0 : 1;
const data = this.dexData[species.speciesId];
if (species.forms?.length) {
try {
if (species.malePercent !== null)
return data[shinyIndex][formIndex][genderIndex][abilityIndex];
return data[shinyIndex][formIndex][abilityIndex];
} catch (err) {
console.warn(`Form data not found for dex entry for ${species.name}: Restructuring dex entry`);
for (let s = 0; s < 2; s++) {
const oldData = Object.assign({}, data[s]);
data[s] = {};
for (let f = 0; f < species.forms.length; f++)
data[s][f] = oldData;
}
this.saveSystem();
}
if (species.malePercent !== null)
return data[shinyIndex][formIndex][genderIndex][abilityIndex];
return data[shinyIndex][formIndex][abilityIndex];