2024-08-13 13:47:32 -07:00
|
|
|
import Phaser from "phaser";
|
|
|
|
import { afterEach, beforeAll, beforeEach, describe, expect, test } from "vitest";
|
2025-02-22 22:52:07 -06:00
|
|
|
import GameManager from "#test/testUtils/gameManager";
|
2024-09-02 22:12:34 -04:00
|
|
|
import { Species } from "#enums/species";
|
|
|
|
import { Abilities } from "#enums/abilities";
|
|
|
|
import { Moves } from "#enums/moves";
|
|
|
|
import { Stat } from "#enums/stat";
|
2024-09-05 12:07:04 -07:00
|
|
|
import { BattlerIndex } from "#app/battle";
|
|
|
|
import { MoveResult } from "#app/field/pokemon";
|
2024-08-13 13:47:32 -07:00
|
|
|
|
2024-09-20 14:05:45 -07:00
|
|
|
|
2024-08-13 13:47:32 -07:00
|
|
|
describe("Moves - Quick Guard", () => {
|
|
|
|
let phaserGame: Phaser.Game;
|
|
|
|
let game: GameManager;
|
|
|
|
|
|
|
|
beforeAll(() => {
|
|
|
|
phaserGame = new Phaser.Game({
|
|
|
|
type: Phaser.HEADLESS,
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
afterEach(() => {
|
|
|
|
game.phaseInterceptor.restoreOg();
|
|
|
|
});
|
|
|
|
|
|
|
|
beforeEach(() => {
|
|
|
|
game = new GameManager(phaserGame);
|
|
|
|
|
|
|
|
game.override.battleType("double");
|
|
|
|
|
2024-10-04 13:08:31 +08:00
|
|
|
game.override.moveset([ Moves.QUICK_GUARD, Moves.SPLASH, Moves.FOLLOW_ME ]);
|
2024-08-13 13:47:32 -07:00
|
|
|
|
|
|
|
game.override.enemySpecies(Species.SNORLAX);
|
2024-10-04 13:08:31 +08:00
|
|
|
game.override.enemyMoveset([ Moves.QUICK_ATTACK ]);
|
2024-08-13 13:47:32 -07:00
|
|
|
game.override.enemyAbility(Abilities.INSOMNIA);
|
|
|
|
|
|
|
|
game.override.startingLevel(100);
|
|
|
|
game.override.enemyLevel(100);
|
|
|
|
});
|
|
|
|
|
|
|
|
test(
|
|
|
|
"should protect the user and allies from priority moves",
|
|
|
|
async () => {
|
2024-10-04 13:08:31 +08:00
|
|
|
await game.classicMode.startBattle([ Species.CHARIZARD, Species.BLASTOISE ]);
|
2024-08-13 13:47:32 -07:00
|
|
|
|
2024-09-05 12:07:04 -07:00
|
|
|
const playerPokemon = game.scene.getPlayerField();
|
2024-08-13 13:47:32 -07:00
|
|
|
|
2024-08-22 06:49:33 -07:00
|
|
|
game.move.select(Moves.QUICK_GUARD);
|
|
|
|
game.move.select(Moves.SPLASH, 1);
|
2024-08-13 13:47:32 -07:00
|
|
|
|
2024-09-05 12:07:04 -07:00
|
|
|
await game.phaseInterceptor.to("BerryPhase", false);
|
2024-08-13 13:47:32 -07:00
|
|
|
|
2024-09-05 12:07:04 -07:00
|
|
|
playerPokemon.forEach(p => expect(p.hp).toBe(p.getMaxHp()));
|
2024-09-20 14:05:45 -07:00
|
|
|
}
|
2024-08-13 13:47:32 -07:00
|
|
|
);
|
|
|
|
|
|
|
|
test(
|
|
|
|
"should protect the user and allies from Prankster-boosted moves",
|
|
|
|
async () => {
|
|
|
|
game.override.enemyAbility(Abilities.PRANKSTER);
|
2024-10-04 13:08:31 +08:00
|
|
|
game.override.enemyMoveset([ Moves.GROWL ]);
|
2024-08-13 13:47:32 -07:00
|
|
|
|
2024-10-04 13:08:31 +08:00
|
|
|
await game.classicMode.startBattle([ Species.CHARIZARD, Species.BLASTOISE ]);
|
2024-08-13 13:47:32 -07:00
|
|
|
|
2024-09-05 12:07:04 -07:00
|
|
|
const playerPokemon = game.scene.getPlayerField();
|
2024-08-13 13:47:32 -07:00
|
|
|
|
2024-08-22 06:49:33 -07:00
|
|
|
game.move.select(Moves.QUICK_GUARD);
|
|
|
|
game.move.select(Moves.SPLASH, 1);
|
2024-08-13 13:47:32 -07:00
|
|
|
|
2024-09-05 12:07:04 -07:00
|
|
|
await game.phaseInterceptor.to("BerryPhase", false);
|
2024-08-13 13:47:32 -07:00
|
|
|
|
2024-09-05 12:07:04 -07:00
|
|
|
playerPokemon.forEach(p => expect(p.getStatStage(Stat.ATK)).toBe(0));
|
2024-09-20 14:05:45 -07:00
|
|
|
}
|
2024-08-13 13:47:32 -07:00
|
|
|
);
|
|
|
|
|
|
|
|
test(
|
|
|
|
"should stop subsequent hits of a multi-hit priority move",
|
|
|
|
async () => {
|
2024-10-04 13:08:31 +08:00
|
|
|
game.override.enemyMoveset([ Moves.WATER_SHURIKEN ]);
|
2024-08-13 13:47:32 -07:00
|
|
|
|
2024-10-04 13:08:31 +08:00
|
|
|
await game.classicMode.startBattle([ Species.CHARIZARD, Species.BLASTOISE ]);
|
2024-08-13 13:47:32 -07:00
|
|
|
|
2024-09-05 12:07:04 -07:00
|
|
|
const playerPokemon = game.scene.getPlayerField();
|
2024-08-13 13:47:32 -07:00
|
|
|
const enemyPokemon = game.scene.getEnemyField();
|
|
|
|
|
2024-08-22 06:49:33 -07:00
|
|
|
game.move.select(Moves.QUICK_GUARD);
|
|
|
|
game.move.select(Moves.FOLLOW_ME, 1);
|
2024-08-13 13:47:32 -07:00
|
|
|
|
2024-09-05 12:07:04 -07:00
|
|
|
await game.phaseInterceptor.to("BerryPhase", false);
|
2024-08-13 13:47:32 -07:00
|
|
|
|
2024-09-05 12:07:04 -07:00
|
|
|
playerPokemon.forEach(p => expect(p.hp).toBe(p.getMaxHp()));
|
2024-08-13 13:47:32 -07:00
|
|
|
enemyPokemon.forEach(p => expect(p.turnData.hitCount).toBe(1));
|
|
|
|
}
|
|
|
|
);
|
2024-09-05 12:07:04 -07:00
|
|
|
|
|
|
|
test(
|
|
|
|
"should fail if the user is the last to move in the turn",
|
|
|
|
async () => {
|
|
|
|
game.override.battleType("single");
|
2024-10-04 13:08:31 +08:00
|
|
|
game.override.enemyMoveset([ Moves.QUICK_GUARD ]);
|
2024-09-05 12:07:04 -07:00
|
|
|
|
2024-10-04 13:08:31 +08:00
|
|
|
await game.classicMode.startBattle([ Species.CHARIZARD ]);
|
2024-09-05 12:07:04 -07:00
|
|
|
|
|
|
|
const playerPokemon = game.scene.getPlayerPokemon()!;
|
|
|
|
const enemyPokemon = game.scene.getEnemyPokemon()!;
|
|
|
|
|
|
|
|
game.move.select(Moves.QUICK_GUARD);
|
|
|
|
|
2024-10-04 13:08:31 +08:00
|
|
|
await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]);
|
2024-09-05 12:07:04 -07:00
|
|
|
|
|
|
|
await game.phaseInterceptor.to("BerryPhase", false);
|
|
|
|
|
|
|
|
expect(enemyPokemon.getLastXMoves()[0].result).toBe(MoveResult.SUCCESS);
|
|
|
|
expect(playerPokemon.getLastXMoves()[0].result).toBe(MoveResult.FAIL);
|
2024-09-20 14:05:45 -07:00
|
|
|
}
|
2024-09-05 12:07:04 -07:00
|
|
|
);
|
2024-08-13 13:47:32 -07:00
|
|
|
});
|