From a71015e97cb84d4f14262c0786ba0d81e77138ce Mon Sep 17 00:00:00 2001 From: Wlowscha <54003515+Wlowscha@users.noreply.github.com> Date: Tue, 21 Jan 2025 20:44:54 +0100 Subject: [PATCH] Prevolutions are shown properly again; battle forms are considered caught as long as the base form is caught --- src/ui/pokedex-page-ui-handler.ts | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/src/ui/pokedex-page-ui-handler.ts b/src/ui/pokedex-page-ui-handler.ts index 1835cd5ebdd..42e6b3013da 100644 --- a/src/ui/pokedex-page-ui-handler.ts +++ b/src/ui/pokedex-page-ui-handler.ts @@ -659,7 +659,9 @@ export default class PokedexPageUiHandler extends MessageUiHandler { // 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) + (preSpecies.forms.length > 0 && species.forms.length === 0) || + // This takes care of everything else + (preSpecies.forms.length === 0 && (species.forms.length === 0 || species.forms[formIndex]?.formKey === "")) ) ) // This takes care of Burmy, Shellos etc @@ -729,6 +731,16 @@ export default class PokedexPageUiHandler extends MessageUiHandler { return biomes; } + isFormCaught(): boolean { + const allFormChanges = pokemonFormChanges.hasOwnProperty(this.species.speciesId) ? pokemonFormChanges[this.species.speciesId] : []; + // This shows battle forms such as megas and gmax as unlocked. + const formChangeAccess = allFormChanges.filter(f => (f.formKey === this.species.forms[this.formIndex].formKey)).length > 0; + const isFormCaught = this.speciesStarterDexEntry ? + (this.speciesStarterDexEntry.caughtAttr & globalScene.gameData.getFormAttr(this.formIndex ?? 0)) > 0n || formChangeAccess + : false; + return isFormCaught; + } + /** * Get the starter attributes for the given PokemonSpecies, after sanitizing them. * If somehow a preference is set for a form, variant, gender, ability or nature @@ -882,7 +894,7 @@ export default class PokedexPageUiHandler extends MessageUiHandler { let error = false; const isCaught = this.speciesStarterDexEntry?.caughtAttr; - const isFormCaught = (this.speciesStarterDexEntry!.caughtAttr! & globalScene.gameData.getFormAttr(this.formIndex ?? 0)) > 0n; + const isFormCaught = this.isFormCaught(); if (this.blockInputOverlay) { if (button === Button.CANCEL || button === Button.ACTION) { @@ -1820,10 +1832,7 @@ export default class PokedexPageUiHandler extends MessageUiHandler { return; } - let isFormCaught: Boolean = false; - if (this.speciesStarterDexEntry) { - isFormCaught = (this.speciesStarterDexEntry?.caughtAttr! & globalScene.gameData.getFormAttr(this.formIndex ?? 0)) > 0n; - } + const isFormCaught = this.isFormCaught(); if (this.speciesStarterDexEntry?.caughtAttr) { if (isFormCaught) { @@ -1877,7 +1886,7 @@ export default class PokedexPageUiHandler extends MessageUiHandler { const ui = this.getUi(); - const isFormCaught = this.speciesStarterDexEntry ? (this.speciesStarterDexEntry.caughtAttr & globalScene.gameData.getFormAttr(this.formIndex ?? 0)) > 0n : false; + const isFormCaught = this.isFormCaught(); if ((this.speciesStarterDexEntry?.caughtAttr && isFormCaught) || (this.speciesStarterDexEntry?.seenAttr && cursor === 5)) { ui.showText(this.menuDescriptions[cursor]); @@ -2146,7 +2155,7 @@ export default class PokedexPageUiHandler extends MessageUiHandler { } } - const isFormCaught = (this.speciesStarterDexEntry!.caughtAttr! & globalScene.gameData.getFormAttr(formIndex ?? 0)) > 0n; + const isFormCaught = this.isFormCaught(); this.shinyOverlay.setVisible(shiny ?? false); // TODO: is false the correct default? this.pokemonNumberText.setColor(this.getTextColor(shiny ? TextStyle.SUMMARY_GOLD : TextStyle.SUMMARY, false));