Ensure that gender forms loop correctly with either button

This commit is contained in:
Wlowscha 2025-02-21 01:46:37 +01:00
parent 5b1950a1ae
commit 82da65efb8
No known key found for this signature in database
GPG Key ID: 3C8F1AD330565D04

View File

@ -246,6 +246,7 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
private menuOptions: MenuOptions[];
protected scale: number = 0.1666666667;
private menuDescriptions: string[];
private isFormGender: boolean;
constructor() {
super(Mode.POKEDEX_PAGE);
@ -628,6 +629,8 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
this.tmMoves = speciesTmMoves[species.speciesId]?.filter(m => Array.isArray(m) ? (m[0] === formKey ? true : false ) : true)
.map(m => Array.isArray(m) ? m[1] : m).sort((a, b) => allMoves[a].name > allMoves[b].name ? 1 : -1) ?? [];
this.isFormGender = formKey === "male" || formKey === "female";
const passiveId = starterPassiveAbilities.hasOwnProperty(species.speciesId) ? species.speciesId :
starterPassiveAbilities.hasOwnProperty(this.starterId) ? this.starterId : pokemonPrevolutions[this.starterId];
const passives = starterPassiveAbilities[passiveId];
@ -1586,8 +1589,15 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
starterAttributes.form = newFormIndex; // store the selected form
this.savedStarterAttributes.form = starterAttributes.form;
this.formIndex = newFormIndex;
// Some forms are tied to the gender and should change accordingly
let newFemale = props.female;
if (this.isFormGender) {
newFemale = !props.female;
}
starterAttributes.female = newFemale;
this.savedStarterAttributes.female = starterAttributes.female;
this.starterSetup();
this.setSpeciesDetails(this.species, { formIndex: newFormIndex });
this.setSpeciesDetails(this.species, { formIndex: newFormIndex, female: newFemale });
success = this.setCursor(this.cursor);
}
break;
@ -1595,7 +1605,16 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
if (this.canCycleGender) {
starterAttributes.female = !props.female;
this.savedStarterAttributes.female = starterAttributes.female;
this.setSpeciesDetails(this.species, { female: !props.female });
let newFormIndex = this.formIndex;
// Some forms are tied to the gender and should change accordingly
if (this.isFormGender) {
newFormIndex = this.formIndex === 0 ? 1 : 0;
}
starterAttributes.form = newFormIndex; // store the selected form
this.savedStarterAttributes.form = starterAttributes.form;
this.formIndex = newFormIndex;
this.starterSetup();
this.setSpeciesDetails(this.species, { female: !props.female, formIndex: newFormIndex });
success = true;
}
break;