Fix encore not working correctly

pull/16/head
Flashfyre 2024-03-24 23:15:29 -04:00
parent c77ea04120
commit 73c527af05
1 changed files with 9 additions and 3 deletions

View File

@ -378,9 +378,15 @@ export class EncoreTag extends BattlerTag {
pokemon.scene.queueMessage(getPokemonMessage(pokemon, ' got\nan Encore!')); pokemon.scene.queueMessage(getPokemonMessage(pokemon, ' got\nan Encore!'));
const turnCommand = pokemon.scene.currentBattle.turnCommands[pokemon.getFieldIndex()]; const movePhase = pokemon.scene.findPhase(m => m instanceof MovePhase && m.pokemon === pokemon);
if (turnCommand) if (movePhase) {
turnCommand.move = { move: this.moveId, targets: pokemon.getLastXMoves(1)[0].targets }; 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 { onRemove(pokemon: Pokemon): void {