From 73c527af0523622fd0744e837f3756e201aa6b1b Mon Sep 17 00:00:00 2001 From: Flashfyre Date: Sun, 24 Mar 2024 23:15:29 -0400 Subject: [PATCH] Fix encore not working correctly --- src/data/battler-tags.ts | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/data/battler-tags.ts b/src/data/battler-tags.ts index 8786c29c7..362f31357 100644 --- a/src/data/battler-tags.ts +++ b/src/data/battler-tags.ts @@ -378,9 +378,15 @@ export class EncoreTag extends BattlerTag { pokemon.scene.queueMessage(getPokemonMessage(pokemon, ' got\nan Encore!')); - const turnCommand = pokemon.scene.currentBattle.turnCommands[pokemon.getFieldIndex()]; - if (turnCommand) - turnCommand.move = { move: this.moveId, targets: pokemon.getLastXMoves(1)[0].targets }; + const movePhase = pokemon.scene.findPhase(m => m instanceof MovePhase && m.pokemon === pokemon); + if (movePhase) { + const movesetMove = pokemon.getMoveset().find(m => m.moveId === this.moveId); + if (movesetMove) { + const lastMove = pokemon.getLastXMoves(1)[0]; + pokemon.scene.tryReplacePhase((m => m instanceof MovePhase && m.pokemon === pokemon), + new MovePhase(pokemon.scene, pokemon, lastMove.targets, movesetMove)); + } + } } onRemove(pokemon: Pokemon): void {