From 06ed89ef13560a7a31234ee5bd345fd15b2a1278 Mon Sep 17 00:00:00 2001 From: schmidtc1 <62030095+schmidtc1@users.noreply.github.com> Date: Tue, 6 Aug 2024 15:25:20 -0400 Subject: [PATCH] [Bug] Fix sketch being able to copy some unsketchable moves (#3386) * Cherrypicks due to beta issues * Adds flags to some unsketchable moves, adds typedoc * Cherrypicks due to beta issues #2 --- src/data/move.ts | 38 ++++++++++++++++++++++++++++++++++---- 1 file changed, 34 insertions(+), 4 deletions(-) diff --git a/src/data/move.ts b/src/data/move.ts index 0ea4e4221c5..3d1e7820582 100644 --- a/src/data/move.ts +++ b/src/data/move.ts @@ -5419,10 +5419,26 @@ export class MovesetCopyMoveAttr extends OverrideMoveEffectAttr { } } +/** + * Attribute for {@linkcode Moves.SKETCH} that causes the user to copy the opponent's last used move + * This move copies the last used non-virtual move + * e.g. if Metronome is used, it copies Metronome itself, not the virtual move called by Metronome + * Fails if the opponent has not yet used a move. + * Fails if used on an uncopiable move, listed in unsketchableMoves in getCondition + * Fails if the move is already in the user's moveset + */ export class SketchAttr extends MoveEffectAttr { constructor() { super(true); } + /** + * User copies the opponent's last used move, if possible + * @param {Pokemon} user Pokemon that used the move and will replace Sketch with the copied move + * @param {Pokemon} target Pokemon that the user wants to copy a move from + * @param {Move} move Move being used + * @param {any[]} args Unused + * @returns {boolean} true if the function succeeds, otherwise false + */ apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean { if (!super.apply(user, target, move, args)) { @@ -5453,14 +5469,28 @@ 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 sketchableMove = targetMoves[0]; + const unsketchableMoves = [ + Moves.CHATTER, + Moves.MIRROR_MOVE, + Moves.SLEEP_TALK, + Moves.STRUGGLE, + Moves.SKETCH, + Moves.REVIVAL_BLESSING, + Moves.TERA_STARSTORM, + Moves.BREAKNECK_BLITZ__PHYSICAL, + Moves.BREAKNECK_BLITZ__SPECIAL + ]; - if (user.getMoveset().find(m => m.moveId === sketchableMove.move)) { + if (unsketchableMoves.includes(targetMove.move)) { + return false; + } + + if (user.getMoveset().find(m => m.moveId === targetMove.move)) { return false; }