From 07010dd703a75e77e72182b24421678e7cc03a20 Mon Sep 17 00:00:00 2001 From: Wlowscha <54003515+Wlowscha@users.noreply.github.com> Date: Fri, 17 Jan 2025 00:58:18 +0100 Subject: [PATCH] Correctly displaying prevolutions for Pikachu and Gholdengo --- src/ui/pokedex-page-ui-handler.ts | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/ui/pokedex-page-ui-handler.ts b/src/ui/pokedex-page-ui-handler.ts index b74c75f9aa6..39cc6f8ea9b 100644 --- a/src/ui/pokedex-page-ui-handler.ts +++ b/src/ui/pokedex-page-ui-handler.ts @@ -651,7 +651,19 @@ export default class PokedexPageUiHandler extends MessageUiHandler { if (preSpecies) { const preEvolutions = pokemonEvolutions.hasOwnProperty(preSpecies.speciesId) ? pokemonEvolutions[preSpecies.speciesId] : []; this.prevolutions = preEvolutions.filter( - e => e.speciesId === species.speciesId && ((e.evoFormKey === "" || e.evoFormKey === null) || e.evoFormKey === species.forms[formIndex]?.formKey)); + e => e.speciesId === species.speciesId && ( + ( + (e.evoFormKey === "" || e.evoFormKey === null) && + ( + // This takes care of Cosplay Pikachu (Pichu is not shown) + (preSpecies.forms.some(form => form.formKey === species.forms[formIndex]?.formKey)) || + // This takes care of Gholdengo + (preSpecies.forms.length > 0 && species.forms.length === 0) + ) + ) + // This takes care of Burmy, Shellos etc + || e.evoFormKey === species.forms[formIndex]?.formKey) + ); } } @@ -1311,7 +1323,7 @@ export default class PokedexPageUiHandler extends MessageUiHandler { handler: () => { const newSpecies = allSpecies.find(species => species.speciesId === pokemonPrevolutions[pre.speciesId]); // Attempts to find the formIndex of the evolved species - const newFormKey = pre.evoFormKey ? pre.evoFormKey : (this.species.forms.length > 0 ? this.species.forms[this.formIndex].formKey : ""); + const newFormKey = pre.preFormKey ? pre.preFormKey : (this.species.forms.length > 0 ? this.species.forms[this.formIndex].formKey : ""); const matchingForm = newSpecies?.forms.find(form => form.formKey === newFormKey); const newFormIndex = matchingForm ? matchingForm.formIndex : 0; this.starterAttributes.form = newFormIndex;