Updated comments on how the logic works

This commit is contained in:
Opaque02 2024-06-17 12:23:01 +10:00
parent 30a4922418
commit 76b4fce435

View File

@ -227,15 +227,22 @@ export default class PokemonInfoContainer extends Phaser.GameObjects.Container {
this.pokemonGenderText.setVisible(false); this.pokemonGenderText.setVisible(false);
} }
let isFormVisible = true; 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) { 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 => { const nonFormKeyForms = pokemon.species.forms.filter(object => {
return !pokemonSpecies.noStarterFormKeys.includes(object.formKey); 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) { if (nonFormKeyForms.length === 1) {
isFormVisible = false; isFormVisible = false;
} }
} else { } else { // If the pokemon doesn't have any forms, hide the form label
isFormVisible = false; isFormVisible = false;
} }