[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:
parent
c722490f60
commit
06ed89ef13
|
@ -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 {
|
export class SketchAttr extends MoveEffectAttr {
|
||||||
constructor() {
|
constructor() {
|
||||||
super(true);
|
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 {
|
apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean {
|
||||||
if (!super.apply(user, target, move, args)) {
|
if (!super.apply(user, target, move, args)) {
|
||||||
|
@ -5453,14 +5469,28 @@ export class SketchAttr extends MoveEffectAttr {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
const targetMoves = target.getMoveHistory().filter(m => !m.virtual);
|
const targetMove = target.getMoveHistory().filter(m => !m.virtual).at(-1);
|
||||||
if (!targetMoves.length) {
|
if (!targetMove) {
|
||||||
return false;
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue