import { MapModifier } from "#app/modifier/modifier"; import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; import GameManager from "./utils/gameManager"; import { Moves } from "#app/enums/moves"; import { Biome } from "#app/enums/biome"; import { Mode } from "#app/ui/ui"; import ModifierSelectUiHandler from "#app/ui/modifier-select-ui-handler"; //const TIMEOUT = 20 * 1000; describe("Daily Mode", () => { let phaserGame: Phaser.Game; let game: GameManager; beforeAll(() => { phaserGame = new Phaser.Game({ type: Phaser.HEADLESS, }); }); beforeEach(() => { game = new GameManager(phaserGame); }); afterEach(() => { game.phaseInterceptor.restoreOg(); }); it("should initialize properly", async () => { await game.dailyMode.runToSummon(); const party = game.scene.getParty(); expect(party).toHaveLength(3); party.forEach(pkm => { expect(pkm.level).toBe(20); expect(pkm.moveset.length).toBeGreaterThan(0); }); expect(game.scene.getModifiers(MapModifier).length).toBeGreaterThan(0); }); }); describe("Shop modifications", async () => { let phaserGame: Phaser.Game; let game: GameManager; beforeAll(() => { phaserGame = new Phaser.Game({ type: Phaser.HEADLESS, }); }); beforeEach(() => { game = new GameManager(phaserGame); game.override .startingWave(9) .startingBiome(Biome.ICE_CAVE) // Will lead to Snowy Forest with randomly generated weather .battleType("single") .startingLevel(100) // Avoid levelling up .enemyLevel(1000) // Avoid opponent dying before game.doKillOpponents() .disableTrainerWaves() .moveset([Moves.KOWTOW_CLEAVE]) .enemyMoveset(Moves.SPLASH); game.modifiers .addCheck("EVIOLITE") .addCheck("MINI_BLACK_HOLE"); }); afterEach(() => { game.phaseInterceptor.restoreOg(); game.modifiers.clearChecks(); }); it("should not have Eviolite and Mini Black Hole available in Classic if not unlocked", async () => { await game.classicMode.startBattle(); game.move.select(Moves.KOWTOW_CLEAVE); await game.phaseInterceptor.to("DamagePhase"); await game.doKillOpponents(); await game.phaseInterceptor.to("BattleEndPhase"); game.onNextPrompt("SelectModifierPhase", Mode.MODIFIER_SELECT, () => { expect(game.scene.ui.getHandler()).toBeInstanceOf(ModifierSelectUiHandler); game.modifiers .testCheck("EVIOLITE", false) .testCheck("MINI_BLACK_HOLE", false); }); }); it("should have Eviolite and Mini Black Hole available in Daily", async () => { await game.dailyMode.startBattle(); game.move.select(Moves.KOWTOW_CLEAVE); await game.phaseInterceptor.to("DamagePhase"); await game.doKillOpponents(); await game.phaseInterceptor.to("BattleEndPhase"); game.onNextPrompt("SelectModifierPhase", Mode.MODIFIER_SELECT, () => { expect(game.scene.ui.getHandler()).toBeInstanceOf(ModifierSelectUiHandler); game.modifiers .testCheck("EVIOLITE", true) .testCheck("MINI_BLACK_HOLE", true); }); }); });