From cbc6005c5735d6019b8325ba385a9cd1d6339791 Mon Sep 17 00:00:00 2001 From: schmidtc1 <62030095+schmidtc1@users.noreply.github.com> Date: Sat, 13 Jul 2024 14:07:28 -0400 Subject: [PATCH] [BUG] Fixes Sketch copying the first move used by the opponent instead of the last (#2759) * Changes getMoveHistory to getLastXMoves to fix sketch copying first move used instead of last * Optimizes move search and early return * Reverts check for virtual moves --- src/data/move.ts | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/data/move.ts b/src/data/move.ts index f244b484e00..d6752dd35a7 100644 --- a/src/data/move.ts +++ b/src/data/move.ts @@ -5169,21 +5169,18 @@ export class SketchAttr extends MoveEffectAttr { return false; } - const targetMoves = target.getMoveHistory().filter(m => !m.virtual); - if (!targetMoves.length) { + const targetMove = target.getMoveHistory().filter(m => !m.virtual).at(-1); + if (!targetMove) { return false; } - const sketchedMove = allMoves[targetMoves[0].move]; - + const sketchedMove = allMoves[targetMove.move]; const sketchIndex = user.getMoveset().findIndex(m => m.moveId === move.id); - if (sketchIndex === -1) { return false; } user.setMove(sketchIndex, sketchedMove.id); - user.scene.queueMessage(i18next.t("moveTriggers:sketchedMove", {pokemonName: getPokemonNameWithAffix(user), moveName: sketchedMove.name})); return true;