From d50521755e8bd2d027d4979e94630719c84b37fd Mon Sep 17 00:00:00 2001 From: Flashfyre Date: Thu, 11 Apr 2024 16:30:29 -0400 Subject: [PATCH] Fix fusion move merge happening after wave end --- src/field/pokemon.ts | 37 ++++++++++++++++++------------------- 1 file changed, 18 insertions(+), 19 deletions(-) diff --git a/src/field/pokemon.ts b/src/field/pokemon.ts index 946c10e82bd..209713adc29 100644 --- a/src/field/pokemon.ts +++ b/src/field/pokemon.ts @@ -2319,25 +2319,24 @@ export class PlayerPokemon extends Pokemon { this.generateName(); this.calculateStats(); this.generateCompatibleTms(); - this.updateInfo(true).then(() => { - const fusedPartyMemberIndex = this.scene.getParty().indexOf(pokemon); - let partyMemberIndex = this.scene.getParty().indexOf(this); - if (partyMemberIndex > fusedPartyMemberIndex) - partyMemberIndex--; - pokemon.getMoveset(true).map(m => this.scene.unshiftPhase(new LearnMovePhase(this.scene, partyMemberIndex, m.getMove().id))); - const fusedPartyMemberHeldModifiers = this.scene.findModifiers(m => m instanceof PokemonHeldItemModifier - && (m as PokemonHeldItemModifier).pokemonId === pokemon.id, true) as PokemonHeldItemModifier[]; - const transferModifiers: Promise[] = []; - for (let modifier of fusedPartyMemberHeldModifiers) - transferModifiers.push(this.scene.tryTransferHeldItemModifier(modifier, this, true, false, true, true)); - Promise.allSettled(transferModifiers).then(() => { - this.scene.updateModifiers(true, true).then(() => { - this.scene.removePartyMemberModifiers(fusedPartyMemberIndex); - this.scene.getParty().splice(fusedPartyMemberIndex, 1)[0]; - pokemon.destroy(); - this.updateFusionPalette(); - resolve(); - }); + this.updateInfo(true); + const fusedPartyMemberIndex = this.scene.getParty().indexOf(pokemon); + let partyMemberIndex = this.scene.getParty().indexOf(this); + if (partyMemberIndex > fusedPartyMemberIndex) + partyMemberIndex--; + pokemon.getMoveset(true).map(m => this.scene.unshiftPhase(new LearnMovePhase(this.scene, partyMemberIndex, m.getMove().id))); + const fusedPartyMemberHeldModifiers = this.scene.findModifiers(m => m instanceof PokemonHeldItemModifier + && (m as PokemonHeldItemModifier).pokemonId === pokemon.id, true) as PokemonHeldItemModifier[]; + const transferModifiers: Promise[] = []; + for (let modifier of fusedPartyMemberHeldModifiers) + transferModifiers.push(this.scene.tryTransferHeldItemModifier(modifier, this, true, false, true, true)); + Promise.allSettled(transferModifiers).then(() => { + this.scene.updateModifiers(true, true).then(() => { + this.scene.removePartyMemberModifiers(fusedPartyMemberIndex); + this.scene.getParty().splice(fusedPartyMemberIndex, 1)[0]; + pokemon.destroy(); + this.updateFusionPalette(); + resolve(); }); }); });