Add encore tests

This commit is contained in:
innerthunder 2024-11-06 15:31:56 -08:00
parent 856c540b7e
commit 756aeb2897

View File

@ -1,5 +1,6 @@
import { BattlerTagType } from "#app/enums/battler-tag-type";
import { BattlerTagType } from "#enums/battler-tag-type";
import { BattlerIndex } from "#app/battle";
import { MoveResult } from "#app/field/pokemon";
import { Abilities } from "#enums/abilities";
import { Moves } from "#enums/moves";
import { Species } from "#enums/species";
@ -32,6 +33,59 @@ describe("Moves - Encore", () => {
.enemyMoveset(Moves.SPLASH);
});
it("should prevent the target from using any move except the last used move", async () => {
await game.classicMode.startBattle([ Species.SNORLAX ]);
const enemyPokemon = game.scene.getEnemyPokemon()!;
game.move.select(Moves.ENCORE);
await game.forceEnemyMove(Moves.SPLASH);
await game.toNextTurn();
expect(enemyPokemon.getTag(BattlerTagType.ENCORE)).toBeDefined();
game.move.select(Moves.SPLASH);
// The enemy AI would normally be inclined to use Tackle, but should be
// forced into using Splash.
await game.phaseInterceptor.to("BerryPhase", false);
expect(enemyPokemon.getLastXMoves().every(turnMove => turnMove.move === Moves.SPLASH)).toBeTruthy();
});
describe("should fail against the following moves:", () => {
it.each([
{ moveId: Moves.TRANSFORM, name: "Transform", delay: false },
{ moveId: Moves.MIMIC, name: "Mimic", delay: true },
{ moveId: Moves.SKETCH, name: "Sketch", delay: true },
{ moveId: Moves.ENCORE, name: "Encore", delay: false },
{ moveId: Moves.STRUGGLE, name: "Struggle", delay: false }
])("$name", async ({ moveId, delay }) => {
game.override.enemyMoveset(moveId);
await game.classicMode.startBattle([ Species.SNORLAX ]);
const playerPokemon = game.scene.getPlayerPokemon()!;
const enemyPokemon = game.scene.getEnemyPokemon()!;
if (delay) {
game.move.select(Moves.SPLASH);
await game.setTurnOrder([ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]);
await game.toNextTurn();
}
game.move.select(Moves.ENCORE);
const turnOrder = delay
? [ BattlerIndex.PLAYER, BattlerIndex.ENEMY ]
: [ BattlerIndex.ENEMY, BattlerIndex.PLAYER ];
await game.setTurnOrder(turnOrder);
await game.phaseInterceptor.to("BerryPhase", false);
expect(playerPokemon.getLastXMoves(1)[0].result).toBe(MoveResult.FAIL);
expect(enemyPokemon.getTag(BattlerTagType.ENCORE)).toBeUndefined();
});
});
it("Pokemon under both Encore and Torment should alternate between Struggle and restricted move", async () => {
const turnOrder = [ BattlerIndex.ENEMY, BattlerIndex.PLAYER ];
game.override.moveset([ Moves.ENCORE, Moves.TORMENT, Moves.SPLASH ]);