[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
This commit is contained in:
schmidtc1 2024-07-13 14:07:28 -04:00 committed by GitHub
parent f7b53faae3
commit cbc6005c57
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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;