2024-08-13 13:47:32 -07:00
|
|
|
import Phaser from "phaser";
|
|
|
|
import { afterEach, beforeAll, beforeEach, describe, expect, test } from "vitest";
|
|
|
|
import GameManager from "../utils/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
|
|
|
|
|
|
|
const TIMEOUT = 20 * 1000;
|
|
|
|
|
|
|
|
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");
|
|
|
|
|
|
|
|
game.override.moveset([Moves.QUICK_GUARD, Moves.SPLASH, Moves.FOLLOW_ME]);
|
|
|
|
|
|
|
|
game.override.enemySpecies(Species.SNORLAX);
|
2024-09-09 09:55:11 -07: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-09-05 12:07:04 -07: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-08-13 13:47:32 -07:00
|
|
|
}, TIMEOUT
|
|
|
|
);
|
|
|
|
|
|
|
|
test(
|
|
|
|
"should protect the user and allies from Prankster-boosted moves",
|
|
|
|
async () => {
|
|
|
|
game.override.enemyAbility(Abilities.PRANKSTER);
|
2024-09-09 09:55:11 -07:00
|
|
|
game.override.enemyMoveset([Moves.GROWL]);
|
2024-08-13 13:47:32 -07:00
|
|
|
|
2024-09-05 12:07:04 -07: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-08-13 13:47:32 -07:00
|
|
|
}, TIMEOUT
|
|
|
|
);
|
|
|
|
|
|
|
|
test(
|
|
|
|
"should stop subsequent hits of a multi-hit priority move",
|
|
|
|
async () => {
|
2024-09-09 09:55:11 -07:00
|
|
|
game.override.enemyMoveset([Moves.WATER_SHURIKEN]);
|
2024-08-13 13:47:32 -07:00
|
|
|
|
2024-09-05 12:07:04 -07: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-09-09 09:55:11 -07:00
|
|
|
game.override.enemyMoveset([Moves.QUICK_GUARD]);
|
2024-09-05 12:07:04 -07:00
|
|
|
|
|
|
|
await game.classicMode.startBattle([Species.CHARIZARD]);
|
|
|
|
|
|
|
|
const playerPokemon = game.scene.getPlayerPokemon()!;
|
|
|
|
const enemyPokemon = game.scene.getEnemyPokemon()!;
|
|
|
|
|
|
|
|
game.move.select(Moves.QUICK_GUARD);
|
|
|
|
|
|
|
|
await game.setTurnOrder([BattlerIndex.ENEMY, BattlerIndex.PLAYER]);
|
|
|
|
|
|
|
|
await game.phaseInterceptor.to("BerryPhase", false);
|
|
|
|
|
|
|
|
expect(enemyPokemon.getLastXMoves()[0].result).toBe(MoveResult.SUCCESS);
|
|
|
|
expect(playerPokemon.getLastXMoves()[0].result).toBe(MoveResult.FAIL);
|
|
|
|
}, TIMEOUT
|
|
|
|
);
|
2024-08-13 13:47:32 -07:00
|
|
|
});
|