Update Second Change Form Function and Fix Form Change on Refresh

This commit is contained in:
Benjamin Odom 2024-05-03 13:12:23 -05:00
parent 0b9392f21b
commit db4373ab4a
2 changed files with 12 additions and 2 deletions

View File

@ -115,7 +115,10 @@ export class SpeciesFormChange {
formIndexes.push(pokemon.fusionFormIndex);
}
const formMatch = [true, true];
const formMatch = [true];
if (pokemon.isFusion())
formMatch.push(true);
for (let i = 0; i < speciesArray.length; ++i) {
const species = speciesArray[i];
const formIndex = formIndexes[i];

View File

@ -1660,8 +1660,15 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
}
changeForm(formChange: SpeciesFormChange): Promise<void> {
const matchesBase = this.species.speciesId == formChange.speciesId;
return new Promise(resolve => {
this.formIndex = Math.max(this.species.forms.findIndex(f => f.formKey === formChange.formKey), 0);
const newFormIndex = Math.max((matchesBase ? this.species : this.fusionSpecies).forms.findIndex(f => f.formKey === formChange.formKey), 0);
if (matchesBase)
this.formIndex = newFormIndex;
else
this.fusionFormIndex = newFormIndex;
this.generateName();
const abilityCount = this.getSpeciesForm().getAbilityCount();
if (this.abilityIndex >= abilityCount) // Shouldn't happen