From 76b4fce435075a7bc2ee9e926cb28a2acaabfaea Mon Sep 17 00:00:00 2001 From: Opaque02 <66582645+Opaque02@users.noreply.github.com> Date: Mon, 17 Jun 2024 12:23:01 +1000 Subject: [PATCH] Updated comments on how the logic works --- src/ui/pokemon-info-container.ts | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/ui/pokemon-info-container.ts b/src/ui/pokemon-info-container.ts index 69147929f84..df8b70edad4 100644 --- a/src/ui/pokemon-info-container.ts +++ b/src/ui/pokemon-info-container.ts @@ -227,15 +227,22 @@ export default class PokemonInfoContainer extends Phaser.GameObjects.Container { this.pokemonGenderText.setVisible(false); } - let isFormVisible = true; - if (pokemon.species.forms?.length > 0) { + let isFormVisible = true; // This sets the form label to be visible by default. We change it later if it has conditions that make it false + if (pokemon.species.forms?.length > 0) { // This code checks to see if the pokemon has forms at all + /* If the pokemon in question does have forms, it compares the form list of the pokemon against the noStarterFormKeys from the pokemon-species.ts file. + This noStarterFormKeys lists all of the form keys that make a form be mega/gmax/primal etc. + If any of the forms of that pokemon have a formKey on the noStarterFormKeys list, it filters them out + */ const nonFormKeyForms = pokemon.species.forms.filter(object => { return !pokemonSpecies.noStarterFormKeys.includes(object.formKey); }); + // If the final list of forms for the pokemon has a length 1, that means there's only one form that's not a mega/gmax etc + // Usually if the remaining forms array has a length of 1, it means the form name remaining is usually "Normal", which should not be shown. + // If this is the case (whether the form name is "Normal" or not), hide the form label as we don't want to be shown the label if this is the only form available if (nonFormKeyForms.length === 1) { isFormVisible = false; } - } else { + } else { // If the pokemon doesn't have any forms, hide the form label isFormVisible = false; }