Added test + change to valid move finding conditional.

This commit is contained in:
frutescens 2024-11-07 10:56:17 -08:00
parent 42d22365b5
commit ba0265bfb6
2 changed files with 27 additions and 1 deletions

View File

@ -6748,7 +6748,7 @@ export class SketchAttr extends MoveEffectAttr {
return false;
}
const targetMove = target.getLastXMoves()
const targetMove = target.getLastXMoves(target.battleSummonData.turnCount)
.find(m => m.move !== Moves.NONE && m.move !== Moves.STRUGGLE && !m.virtual);
if (!targetMove) {
return false;

View File

@ -5,6 +5,8 @@ import { MoveResult } from "#app/field/pokemon";
import GameManager from "#test/utils/gameManager";
import Phaser from "phaser";
import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";
import { StatusEffect } from "#app/enums/status-effect";
import { BattlerIndex } from "#app/battle";
describe("Moves - Sketch", () => {
let phaserGame: Phaser.Game;
@ -50,4 +52,28 @@ describe("Moves - Sketch", () => {
expect(playerPokemon?.getLastXMoves()[0].result).toBe(MoveResult.SUCCESS);
// Can't verify if the player Pokemon's moveset was successfully changed because of overrides.
});
it("Sketch should retrieve the most recent valid move from its target history", async () => {
game.override
.moveset([ Moves.SKETCH, Moves.GROWL ])
.enemyStatusEffect(StatusEffect.PARALYSIS);
await game.classicMode.startBattle([ Species.REGIELEKI ]);
const playerPokemon = game.scene.getPlayerPokemon();
const enemyPokemon = game.scene.getEnemyPokemon();
game.move.select(Moves.GROWL);
await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]);
await game.move.forceStatusActivation(false);
await game.phaseInterceptor.to("TurnEndPhase");
expect(enemyPokemon?.getLastXMoves()[0].result).toBe(MoveResult.SUCCESS);
await game.toNextTurn();
game.move.select(Moves.SKETCH);
await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]);
await game.move.forceStatusActivation(true);
await game.phaseInterceptor.to("TurnEndPhase");
expect(playerPokemon?.getLastXMoves()[0].result).toBe(MoveResult.SUCCESS);
// Can't verify if the player Pokemon's moveset was successfully changed because of overrides.
});
});