[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
This commit is contained in:
schmidtc1 2024-08-06 15:25:20 -04:00 committed by GitHub
parent c722490f60
commit 06ed89ef13
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 34 additions and 4 deletions

View File

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