mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-01-30 04:37:14 +00:00
f180b6070e
* add: i18n backend support the backend is being supported by using msw which will import the correct file from the local locales folder * fix: tests to no longer rely on static i18n keys * Update src/test/mystery-encounter/encounters/teleporting-hijinks-encounter.test.ts Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com> * Update src/test/mystery-encounter/encounters/teleporting-hijinks-encounter.test.ts Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com> * Update src/test/ui/type-hints.test.ts Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com> * Update src/test/mystery-encounter/encounters/a-trainers-test-encounter.test.ts Co-authored-by: MokaStitcher <54149968+MokaStitcher@users.noreply.github.com> * Fix typos Co-authored-by: Adrian T. <68144167+torranx@users.noreply.github.com> * Fix linting * update locales submodule update reference to `56eeb809eb5a2de40cfc5bc6128a78bef14deea9` (from `3ccef8472dd7cc7c362538489954cb8fdad27e5f`) --------- Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com> Co-authored-by: MokaStitcher <54149968+MokaStitcher@users.noreply.github.com> Co-authored-by: Adrian T. <68144167+torranx@users.noreply.github.com>
157 lines
4.9 KiB
TypeScript
157 lines
4.9 KiB
TypeScript
import { afterEach, beforeAll, beforeEach, expect, describe, it, vi } from "vitest";
|
|
import GameManager from "#app/test/utils/gameManager";
|
|
import Phaser from "phaser";
|
|
import { Species } from "#enums/species";
|
|
import { MysteryEncounterOptionSelectedPhase, MysteryEncounterPhase } from "#app/phases/mystery-encounter-phases";
|
|
import { Mode } from "#app/ui/ui";
|
|
import { Button } from "#enums/buttons";
|
|
import MysteryEncounterUiHandler from "#app/ui/mystery-encounter-ui-handler";
|
|
import { MysteryEncounterType } from "#enums/mystery-encounter-type";
|
|
import MessageUiHandler from "#app/ui/message-ui-handler";
|
|
import { MysteryEncounterTier } from "#enums/mystery-encounter-tier";
|
|
import i18next from "i18next";
|
|
|
|
describe("Mystery Encounter Phases", () => {
|
|
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.startingWave(11);
|
|
game.override.mysteryEncounterChance(100);
|
|
// Seed guarantees wild encounter to be replaced by ME
|
|
game.override.seed("test");
|
|
});
|
|
|
|
describe("MysteryEncounterPhase", () => {
|
|
it("Runs to MysteryEncounterPhase", async() => {
|
|
await game.runToMysteryEncounter(MysteryEncounterType.MYSTERIOUS_CHALLENGERS, [ Species.CHARIZARD, Species.VOLCARONA ]);
|
|
|
|
await game.phaseInterceptor.to(MysteryEncounterPhase, false);
|
|
expect(game.scene.getCurrentPhase()?.constructor.name).toBe(MysteryEncounterPhase.name);
|
|
});
|
|
|
|
it("Runs MysteryEncounterPhase", async() => {
|
|
await game.runToMysteryEncounter(MysteryEncounterType.MYSTERIOUS_CHALLENGERS, [ Species.CHARIZARD, Species.VOLCARONA ]);
|
|
|
|
game.onNextPrompt("MysteryEncounterPhase", Mode.MYSTERY_ENCOUNTER, () => {
|
|
// End phase early for test
|
|
game.phaseInterceptor.superEndPhase();
|
|
});
|
|
await game.phaseInterceptor.run(MysteryEncounterPhase);
|
|
|
|
expect(game.scene.mysteryEncounterSaveData.encounteredEvents.length).toBeGreaterThan(0);
|
|
expect(game.scene.mysteryEncounterSaveData.encounteredEvents[0].type).toEqual(MysteryEncounterType.MYSTERIOUS_CHALLENGERS);
|
|
expect(game.scene.mysteryEncounterSaveData.encounteredEvents[0].tier).toEqual(MysteryEncounterTier.GREAT);
|
|
expect(game.scene.ui.getMode()).toBe(Mode.MYSTERY_ENCOUNTER);
|
|
});
|
|
|
|
it("Selects an option for MysteryEncounterPhase", async() => {
|
|
const { ui } = game.scene;
|
|
vi.spyOn(ui, "showDialogue");
|
|
vi.spyOn(ui, "showText");
|
|
await game.runToMysteryEncounter(MysteryEncounterType.MYSTERIOUS_CHALLENGERS, [ Species.CHARIZARD, Species.VOLCARONA ]);
|
|
|
|
game.onNextPrompt("MysteryEncounterPhase", Mode.MESSAGE, () => {
|
|
const handler = game.scene.ui.getHandler() as MessageUiHandler;
|
|
handler.processInput(Button.ACTION);
|
|
});
|
|
|
|
await game.phaseInterceptor.run(MysteryEncounterPhase);
|
|
|
|
// Select option 1 for encounter
|
|
const handler = game.scene.ui.getHandler() as MysteryEncounterUiHandler;
|
|
handler.unblockInput();
|
|
handler.processInput(Button.ACTION);
|
|
|
|
// Waitfor required so that option select messages and preOptionPhase logic are handled
|
|
await vi.waitFor(() => expect(game.scene.getCurrentPhase()?.constructor.name).toBe(MysteryEncounterOptionSelectedPhase.name));
|
|
expect(ui.getMode()).toBe(Mode.MESSAGE);
|
|
expect(ui.showDialogue).toHaveBeenCalledTimes(1);
|
|
expect(ui.showText).toHaveBeenCalledTimes(2);
|
|
expect(ui.showDialogue).toHaveBeenCalledWith(i18next.t("battle:mysteryEncounterAppeared"), "???", null, expect.any(Function));
|
|
expect(ui.showText).toHaveBeenCalledWith(i18next.t("mysteryEncounters/mysteriousChallengers:intro"), null, expect.any(Function), 750, true);
|
|
expect(ui.showText).toHaveBeenCalledWith(i18next.t("mysteryEncounters/mysteriousChallengers:option.selected"), null, expect.any(Function), 300, true);
|
|
});
|
|
});
|
|
|
|
describe("MysteryEncounterOptionSelectedPhase", () => {
|
|
it("runs phase", () => {
|
|
|
|
});
|
|
|
|
it("handles onOptionSelect execution", () => {
|
|
|
|
});
|
|
|
|
it("hides intro visuals", () => {
|
|
|
|
});
|
|
|
|
it("does not hide intro visuals if option disabled", () => {
|
|
|
|
});
|
|
});
|
|
|
|
describe("MysteryEncounterBattlePhase", () => {
|
|
it("runs phase", () => {
|
|
|
|
});
|
|
|
|
it("handles TRAINER_BATTLE variant", () => {
|
|
|
|
});
|
|
|
|
it("handles BOSS_BATTLE variant", () => {
|
|
|
|
});
|
|
|
|
it("handles WILD_BATTLE variant", () => {
|
|
|
|
});
|
|
|
|
it("handles double battle", () => {
|
|
|
|
});
|
|
});
|
|
|
|
describe("MysteryEncounterRewardsPhase", () => {
|
|
it("runs phase", () => {
|
|
|
|
});
|
|
|
|
it("handles doEncounterRewards", () => {
|
|
|
|
});
|
|
|
|
it("handles heal phase if enabled", () => {
|
|
|
|
});
|
|
});
|
|
|
|
describe("PostMysteryEncounterPhase", () => {
|
|
it("runs phase", () => {
|
|
|
|
});
|
|
|
|
it("handles onPostOptionSelect execution", () => {
|
|
|
|
});
|
|
|
|
it("runs to next EncounterPhase", () => {
|
|
|
|
});
|
|
});
|
|
});
|
|
|