mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-10-14 00:57:14 +02:00
* Rename `Abilities` to `AbilityId` * Rename `abilities.ts` to `ability-id.ts` * Rename `Moves` to `MoveId` * Rename `moves.ts` to `move-id.ts` * Rename `Species` to `SpeciesId` * Rename `species.ts` to `species-id.ts` * Rename `Biome` to `BiomeId` * Rename `biome.ts` to `biome-id.ts` * Replace `Abilities` with `AbilityId` in comments * Replace `Biome` with `BiomeId` in comments * Replace `Moves` with `MoveId` in comments * Replace `Species` with `SpeciesId` in comments
78 lines
3.0 KiB
TypeScript
78 lines
3.0 KiB
TypeScript
import { BiomeId } from "#enums/biome-id";
|
|
import { AbilityId } from "#enums/ability-id";
|
|
import { MoveId } from "#enums/move-id";
|
|
import { SpeciesId } from "#enums/species-id";
|
|
import GameManager from "#test/testUtils/gameManager";
|
|
import Phaser from "phaser";
|
|
import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
|
|
import { achvs } from "#app/system/achv";
|
|
import { Unlockables } from "#app/system/unlockables";
|
|
|
|
describe("Game Over 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);
|
|
game.override
|
|
.moveset([MoveId.MEMENTO, MoveId.ICE_BEAM, MoveId.SPLASH])
|
|
.ability(AbilityId.BALL_FETCH)
|
|
.battleStyle("single")
|
|
.disableCrits()
|
|
.enemyAbility(AbilityId.BALL_FETCH)
|
|
.enemyMoveset(MoveId.SPLASH)
|
|
.startingWave(200)
|
|
.startingBiome(BiomeId.END)
|
|
.startingLevel(10000);
|
|
});
|
|
|
|
it("winning a run should give rewards", async () => {
|
|
await game.classicMode.startBattle([SpeciesId.BULBASAUR]);
|
|
vi.spyOn(game.scene, "validateAchv");
|
|
|
|
// Note: `game.doKillOpponents()` does not properly handle final boss
|
|
// Final boss phase 1
|
|
game.move.select(MoveId.ICE_BEAM);
|
|
await game.toNextTurn();
|
|
|
|
// Final boss phase 2
|
|
game.move.select(MoveId.ICE_BEAM);
|
|
await game.phaseInterceptor.to("PostGameOverPhase", false);
|
|
|
|
// The game refused to actually give the vouchers during tests,
|
|
// so the best we can do is to check that their reward phases occurred.
|
|
expect(game.phaseInterceptor.log.includes("GameOverPhase")).toBe(true);
|
|
expect(game.phaseInterceptor.log.includes("UnlockPhase")).toBe(true);
|
|
expect(game.phaseInterceptor.log.includes("RibbonModifierRewardPhase")).toBe(true);
|
|
expect(game.scene.gameData.unlocks[Unlockables.ENDLESS_MODE]).toBe(true);
|
|
expect(game.scene.validateAchv).toHaveBeenCalledWith(achvs.CLASSIC_VICTORY);
|
|
expect(game.scene.gameData.achvUnlocks[achvs.CLASSIC_VICTORY.id]).toBeTruthy();
|
|
});
|
|
|
|
it("losing a run should not give rewards", async () => {
|
|
await game.classicMode.startBattle([SpeciesId.BULBASAUR]);
|
|
vi.spyOn(game.scene, "validateAchv");
|
|
|
|
game.move.select(MoveId.MEMENTO);
|
|
await game.phaseInterceptor.to("PostGameOverPhase", false);
|
|
|
|
expect(game.phaseInterceptor.log.includes("GameOverPhase")).toBe(true);
|
|
expect(game.phaseInterceptor.log.includes("UnlockPhase")).toBe(false);
|
|
expect(game.phaseInterceptor.log.includes("RibbonModifierRewardPhase")).toBe(false);
|
|
expect(game.phaseInterceptor.log.includes("GameOverModifierRewardPhase")).toBe(false);
|
|
expect(game.scene.gameData.unlocks[Unlockables.ENDLESS_MODE]).toBe(false);
|
|
expect(game.scene.validateAchv).not.toHaveBeenCalledWith(achvs.CLASSIC_VICTORY);
|
|
expect(game.scene.gameData.achvUnlocks[achvs.CLASSIC_VICTORY.id]).toBeFalsy();
|
|
});
|
|
});
|