From bd8fa9811f9bf195362f14743f696a9d7eb5a993 Mon Sep 17 00:00:00 2001 From: Flashfyre Date: Sat, 4 Nov 2023 23:09:46 -0400 Subject: [PATCH] Add fix for missing form data in dex --- src/system/game-data.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/system/game-data.ts b/src/system/game-data.ts index 28807bf6d..7e527e2a3 100644 --- a/src/system/game-data.ts +++ b/src/system/game-data.ts @@ -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];