mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-03-09 11:31:49 +00:00
* added tests for zen mode - change form in battle * added tests to run some battle against trainer/rival & boss * added a test with a method to kill a pokemon * added an override in the clock mocked to reduce the time of fainting pokemon and thus reducing test time from 5s to less than 1s * added some more tests + doAttack, doKillOpponents, toNextWave, toNextTurn helper * added some more tests + doAttack, doKillOpponents, toNextWave, toNextTurn helper + fix some tests
138 lines
5.2 KiB
TypeScript
138 lines
5.2 KiB
TypeScript
import {afterEach, beforeAll, beforeEach, describe, expect, it, vi} from "vitest";
|
|
import {Mode} from "#app/ui/ui";
|
|
import {Species} from "#app/data/enums/species";
|
|
import * as overrides from "../../overrides";
|
|
import {
|
|
CommandPhase,
|
|
} from "#app/phases";
|
|
import {Moves} from "#app/data/enums/moves";
|
|
import GameManager from "#app/test/utils/gameManager";
|
|
import Phaser from "phaser";
|
|
import {Abilities} from "#app/data/enums/abilities";
|
|
|
|
describe("Test Battle Phase", () => {
|
|
let phaserGame: Phaser.Game;
|
|
let game: GameManager;
|
|
|
|
beforeAll(() => {
|
|
phaserGame = new Phaser.Game({
|
|
type: Phaser.HEADLESS,
|
|
});
|
|
});
|
|
|
|
afterEach(() => {
|
|
game.phaseInterceptor.restoreOg();
|
|
});
|
|
|
|
beforeEach(() => {
|
|
game = new GameManager(phaserGame);
|
|
vi.spyOn(overrides, "OPP_SPECIES_OVERRIDE", "get").mockReturnValue(Species.RATTATA);
|
|
vi.spyOn(overrides, "STARTING_LEVEL_OVERRIDE", "get").mockReturnValue(2000);
|
|
vi.spyOn(overrides, "MOVESET_OVERRIDE", "get").mockReturnValue([Moves.TACKLE]);
|
|
vi.spyOn(overrides, "OPP_ABILITY_OVERRIDE", "get").mockReturnValue(Abilities.HYDRATION);
|
|
vi.spyOn(overrides, "ABILITY_OVERRIDE", "get").mockReturnValue(Abilities.HYDRATION);
|
|
vi.spyOn(overrides, "OPP_MOVESET_OVERRIDE", "get").mockReturnValue([Moves.TACKLE, Moves.TACKLE, Moves.TACKLE, Moves.TACKLE]);
|
|
});
|
|
|
|
it("startBattle 2vs1 boss", async() => {
|
|
vi.spyOn(overrides, "SINGLE_BATTLE_OVERRIDE", "get").mockReturnValue(true);
|
|
vi.spyOn(overrides, "STARTING_WAVE_OVERRIDE", "get").mockReturnValue(10);
|
|
await game.startBattle([
|
|
Species.BLASTOISE,
|
|
Species.CHARIZARD,
|
|
]);
|
|
expect(game.scene.ui?.getMode()).toBe(Mode.COMMAND);
|
|
expect(game.scene.getCurrentPhase().constructor.name).toBe(CommandPhase.name);
|
|
}, 20000);
|
|
|
|
it("startBattle 2vs2 boss", async() => {
|
|
vi.spyOn(overrides, "DOUBLE_BATTLE_OVERRIDE", "get").mockReturnValue(true);
|
|
vi.spyOn(overrides, "STARTING_WAVE_OVERRIDE", "get").mockReturnValue(10);
|
|
await game.startBattle([
|
|
Species.BLASTOISE,
|
|
Species.CHARIZARD,
|
|
]);
|
|
expect(game.scene.ui?.getMode()).toBe(Mode.COMMAND);
|
|
expect(game.scene.getCurrentPhase().constructor.name).toBe(CommandPhase.name);
|
|
}, 20000);
|
|
|
|
it("startBattle 2vs2 trainer", async() => {
|
|
vi.spyOn(overrides, "DOUBLE_BATTLE_OVERRIDE", "get").mockReturnValue(true);
|
|
vi.spyOn(overrides, "STARTING_WAVE_OVERRIDE", "get").mockReturnValue(5);
|
|
await game.startBattle([
|
|
Species.BLASTOISE,
|
|
Species.CHARIZARD,
|
|
]);
|
|
expect(game.scene.ui?.getMode()).toBe(Mode.COMMAND);
|
|
expect(game.scene.getCurrentPhase().constructor.name).toBe(CommandPhase.name);
|
|
}, 20000);
|
|
|
|
it("startBattle 2vs1 trainer", async() => {
|
|
vi.spyOn(overrides, "SINGLE_BATTLE_OVERRIDE", "get").mockReturnValue(true);
|
|
vi.spyOn(overrides, "STARTING_WAVE_OVERRIDE", "get").mockReturnValue(5);
|
|
await game.startBattle([
|
|
Species.BLASTOISE,
|
|
Species.CHARIZARD,
|
|
]);
|
|
expect(game.scene.ui?.getMode()).toBe(Mode.COMMAND);
|
|
expect(game.scene.getCurrentPhase().constructor.name).toBe(CommandPhase.name);
|
|
}, 20000);
|
|
|
|
it("startBattle 2vs1 rival", async() => {
|
|
vi.spyOn(overrides, "SINGLE_BATTLE_OVERRIDE", "get").mockReturnValue(true);
|
|
vi.spyOn(overrides, "STARTING_WAVE_OVERRIDE", "get").mockReturnValue(8);
|
|
await game.startBattle([
|
|
Species.BLASTOISE,
|
|
Species.CHARIZARD,
|
|
]);
|
|
expect(game.scene.ui?.getMode()).toBe(Mode.COMMAND);
|
|
expect(game.scene.getCurrentPhase().constructor.name).toBe(CommandPhase.name);
|
|
}, 20000);
|
|
|
|
it("startBattle 2vs2 rival", async() => {
|
|
vi.spyOn(overrides, "DOUBLE_BATTLE_OVERRIDE", "get").mockReturnValue(true);
|
|
vi.spyOn(overrides, "STARTING_WAVE_OVERRIDE", "get").mockReturnValue(8);
|
|
await game.startBattle([
|
|
Species.BLASTOISE,
|
|
Species.CHARIZARD,
|
|
]);
|
|
expect(game.scene.ui?.getMode()).toBe(Mode.COMMAND);
|
|
expect(game.scene.getCurrentPhase().constructor.name).toBe(CommandPhase.name);
|
|
}, 20000);
|
|
|
|
it("startBattle 1vs1 trainer", async() => {
|
|
vi.spyOn(overrides, "SINGLE_BATTLE_OVERRIDE", "get").mockReturnValue(true);
|
|
vi.spyOn(overrides, "STARTING_WAVE_OVERRIDE", "get").mockReturnValue(5);
|
|
await game.startBattle([
|
|
Species.BLASTOISE,
|
|
]);
|
|
expect(game.scene.ui?.getMode()).toBe(Mode.COMMAND);
|
|
expect(game.scene.getCurrentPhase().constructor.name).toBe(CommandPhase.name);
|
|
}, 20000);
|
|
|
|
it("startBattle 2vs2 trainer", async() => {
|
|
vi.spyOn(overrides, "DOUBLE_BATTLE_OVERRIDE", "get").mockReturnValue(true);
|
|
vi.spyOn(overrides, "STARTING_WAVE_OVERRIDE", "get").mockReturnValue(5);
|
|
await game.startBattle([
|
|
Species.BLASTOISE,
|
|
Species.CHARIZARD,
|
|
]);
|
|
expect(game.scene.ui?.getMode()).toBe(Mode.COMMAND);
|
|
expect(game.scene.getCurrentPhase().constructor.name).toBe(CommandPhase.name);
|
|
}, 20000);
|
|
|
|
it("startBattle 4vs2 trainer", async() => {
|
|
vi.spyOn(overrides, "DOUBLE_BATTLE_OVERRIDE", "get").mockReturnValue(true);
|
|
vi.spyOn(overrides, "STARTING_WAVE_OVERRIDE", "get").mockReturnValue(5);
|
|
await game.startBattle([
|
|
Species.BLASTOISE,
|
|
Species.CHARIZARD,
|
|
Species.DARKRAI,
|
|
Species.GABITE,
|
|
]);
|
|
expect(game.scene.ui?.getMode()).toBe(Mode.COMMAND);
|
|
expect(game.scene.getCurrentPhase().constructor.name).toBe(CommandPhase.name);
|
|
}, 20000);
|
|
});
|
|
|