Merge pull request #11 from innerthunder/encore-tests

Add encore tests
This commit is contained in:
Mumble 2024-11-06 16:33:27 -08:00 committed by GitHub
commit 24fc92e212
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

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";
@ -24,12 +25,68 @@ describe("Moves - Encore", () => {
beforeEach(() => {
game = new GameManager(phaserGame);
game.override
.moveset([ Moves.SPLASH, Moves.ENCORE ])
.ability(Abilities.BALL_FETCH)
.battleType("single")
.disableCrits()
.enemySpecies(Species.MAGIKARP)
.enemyAbility(Abilities.BALL_FETCH)
.enemyMoveset(Moves.SPLASH);
.enemyMoveset([ Moves.SPLASH, Moves.TACKLE ])
.startingLevel(100)
.enemyLevel(100);
});
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 () => {