mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2024-11-27 01:06:09 +00:00
fix unit tests
This commit is contained in:
parent
7b35efe95e
commit
cf43589260
@ -118,9 +118,9 @@ export const EGG_GACHA_PULL_COUNT_OVERRIDE: number = 0;
|
||||
*/
|
||||
|
||||
// 1 to 256, set to null to ignore
|
||||
export const MYSTERY_ENCOUNTER_RATE_OVERRIDE: number = 256;
|
||||
export const MYSTERY_ENCOUNTER_RATE_OVERRIDE: number = null;
|
||||
export const MYSTERY_ENCOUNTER_TIER_OVERRIDE: MysteryEncounterTier = null;
|
||||
export const MYSTERY_ENCOUNTER_OVERRIDE: MysteryEncounterType = MysteryEncounterType.SHADY_VITAMIN_DEALER;
|
||||
export const MYSTERY_ENCOUNTER_OVERRIDE: MysteryEncounterType = null;
|
||||
|
||||
/**
|
||||
* MODIFIER / ITEM OVERRIDES
|
||||
|
@ -67,7 +67,7 @@ import { TrainerType } from "#enums/trainer-type";
|
||||
import { BattlePhase } from "#app/phases/battle-phase";
|
||||
import { MysteryEncounterVariant } from "#app/data/mystery-encounter";
|
||||
import { MysteryEncounterPhase } from "#app/phases/mystery-encounter-phase";
|
||||
import { handleMysteryEncounterVictory } from "#app/data/mystery-encounters/mystery-encounter-utils";
|
||||
import { getTextWithEncounterDialogueTokensAndColor, handleMysteryEncounterVictory } from "#app/data/mystery-encounters/mystery-encounter-utils";
|
||||
import { SelectModifierPhase } from "#app/phases/select-modifier-phase";
|
||||
|
||||
const { t } = i18next;
|
||||
@ -1081,12 +1081,12 @@ export class EncounterPhase extends BattlePhase {
|
||||
const showNextDialogue = () => {
|
||||
const nextAction = i === introDialogue.length - 1 ? doShowEncounterOptions : showNextDialogue;
|
||||
const dialogue = introDialogue[i];
|
||||
const title = dialogue.speaker;
|
||||
const text = dialogue.text;
|
||||
const title = getTextWithEncounterDialogueTokensAndColor(this.scene, dialogue.speaker);
|
||||
const text = getTextWithEncounterDialogueTokensAndColor(this.scene, dialogue.text);
|
||||
if (title) {
|
||||
this.scene.ui.showDialogue(i18next.t(text), i18next.t(title), null, nextAction, 0, i === 0 ? 750 : 0);
|
||||
this.scene.ui.showDialogue(text, title, null, nextAction, 0, i === 0 ? 750 : 0);
|
||||
} else {
|
||||
this.scene.ui.showText(i18next.t(text), null, nextAction, i === 0 ? 750 : 0, true);
|
||||
this.scene.ui.showText(text, null, nextAction, i === 0 ? 750 : 0, true);
|
||||
}
|
||||
i++;
|
||||
};
|
||||
|
@ -4,6 +4,7 @@ import GameManager from "#app/test/utils/gameManager";
|
||||
import Phaser from "phaser";
|
||||
import {Species} from "#enums/species";
|
||||
import {MysteryEncounterPhase} from "#app/phases/mystery-encounter-phase";
|
||||
import {MysteryEncounterType} from "#enums/mystery-encounter-type";
|
||||
|
||||
describe("Mystery Encounters", () => {
|
||||
let phaserGame: Phaser.Game;
|
||||
@ -23,6 +24,14 @@ describe("Mystery Encounters", () => {
|
||||
game = new GameManager(phaserGame);
|
||||
vi.spyOn(overrides, "MYSTERY_ENCOUNTER_RATE_OVERRIDE", "get").mockReturnValue(256);
|
||||
vi.spyOn(overrides, "STARTING_WAVE_OVERRIDE", "get").mockReturnValue(11);
|
||||
vi.spyOn(overrides, "MYSTERY_ENCOUNTER_OVERRIDE", "get").mockReturnValue(MysteryEncounterType.MYSTERIOUS_CHALLENGERS);
|
||||
|
||||
// Seed guarantees wild encounter to be replaced by ME
|
||||
vi.spyOn(game.scene, "resetSeed").mockImplementation(() => {
|
||||
game.scene.waveSeed = "test";
|
||||
Phaser.Math.RND.sow([ game.scene.waveSeed ]);
|
||||
game.scene.rngCounter = 0;
|
||||
});
|
||||
});
|
||||
|
||||
it("Spawns a mystery encounter", async() => {
|
||||
|
@ -28,6 +28,14 @@ describe("Mystery Encounter Phases", () => {
|
||||
game = new GameManager(phaserGame);
|
||||
vi.spyOn(overrides, "MYSTERY_ENCOUNTER_RATE_OVERRIDE", "get").mockReturnValue(256);
|
||||
vi.spyOn(overrides, "STARTING_WAVE_OVERRIDE", "get").mockReturnValue(11);
|
||||
vi.spyOn(overrides, "MYSTERY_ENCOUNTER_OVERRIDE", "get").mockReturnValue(MysteryEncounterType.MYSTERIOUS_CHALLENGERS);
|
||||
|
||||
// Seed guarantees wild encounter to be replaced by ME
|
||||
vi.spyOn(game.scene, "resetSeed").mockImplementation(() => {
|
||||
game.scene.waveSeed = "test";
|
||||
Phaser.Math.RND.sow([ game.scene.waveSeed ]);
|
||||
game.scene.rngCounter = 0;
|
||||
});
|
||||
});
|
||||
|
||||
describe("MysteryEncounterPhase", () => {
|
||||
@ -42,7 +50,6 @@ describe("Mystery Encounter Phases", () => {
|
||||
});
|
||||
|
||||
it("Runs MysteryEncounterPhase", async() => {
|
||||
vi.spyOn(overrides, "MYSTERY_ENCOUNTER_OVERRIDE", "get").mockReturnValue(MysteryEncounterType.MYSTERIOUS_CHALLENGERS);
|
||||
await game.runToMysteryEncounter([
|
||||
Species.CHARIZARD,
|
||||
Species.VOLCARONA
|
||||
@ -61,7 +68,6 @@ describe("Mystery Encounter Phases", () => {
|
||||
});
|
||||
|
||||
it("Selects an option for MysteryEncounterPhase", async() => {
|
||||
vi.spyOn(overrides, "MYSTERY_ENCOUNTER_OVERRIDE", "get").mockReturnValue(MysteryEncounterType.MYSTERIOUS_CHALLENGERS);
|
||||
const dialogueSpy = vi.spyOn(game.scene.ui, "showDialogue");
|
||||
const messageSpy = vi.spyOn(game.scene.ui, "showText");
|
||||
await game.runToMysteryEncounter([
|
||||
@ -74,7 +80,7 @@ describe("Mystery Encounter Phases", () => {
|
||||
const handler = game.scene.ui.getHandler() as MysteryEncounterUiHandler;
|
||||
handler.unblockInput();
|
||||
handler.processInput(Button.ACTION);
|
||||
});
|
||||
}, () => !game.isCurrentPhase(MysteryEncounterPhase));
|
||||
await game.phaseInterceptor.run(MysteryEncounterPhase);
|
||||
|
||||
// After option selected
|
||||
@ -83,7 +89,7 @@ describe("Mystery Encounter Phases", () => {
|
||||
expect(dialogueSpy).toHaveBeenCalledTimes(1);
|
||||
expect(messageSpy).toHaveBeenCalledTimes(2);
|
||||
expect(dialogueSpy).toHaveBeenCalledWith("What's this?", "???", null, expect.any(Function));
|
||||
expect(messageSpy).toHaveBeenCalledWith("Mysterious challengers have appeared!", null, expect.any(Function), 750, true);
|
||||
expect(messageSpy).toHaveBeenCalledWith("[color=#f8f8f8][shadow=#6b5a73]Mysterious challengers have appeared![/color][/shadow]", null, expect.any(Function), 750, true);
|
||||
expect(messageSpy).toHaveBeenCalledWith("[color=#f8f8f8][shadow=#6b5a73]The trainer steps forward...[/color][/shadow]", null, expect.any(Function), 750, true);
|
||||
});
|
||||
});
|
||||
|
@ -34,6 +34,7 @@ import { Button } from "#enums/buttons";
|
||||
import { BattlerIndex } from "#app/battle.js";
|
||||
import TargetSelectUiHandler from "#app/ui/target-select-ui-handler.js";
|
||||
import BattleMessageUiHandler from "#app/ui/battle-message-ui-handler";
|
||||
import {MysteryEncounterPhase} from "#app/phases/mystery-encounter-phase";
|
||||
|
||||
/**
|
||||
* Class to manage the game state and transitions between phases.
|
||||
@ -152,12 +153,12 @@ export default class GameManager {
|
||||
const selectStarterPhase = new SelectStarterPhase(this.scene);
|
||||
this.scene.pushPhase(new EncounterPhase(this.scene, false));
|
||||
selectStarterPhase.initBattle(starters);
|
||||
});
|
||||
}, () => this.isCurrentPhase(EncounterPhase));
|
||||
|
||||
this.onNextPrompt("EncounterPhase", Mode.MESSAGE, () => {
|
||||
const handler = this.scene.ui.getHandler() as BattleMessageUiHandler;
|
||||
handler.processInput(Button.ACTION);
|
||||
}, null, true);
|
||||
}, () => this.isCurrentPhase(MysteryEncounterPhase), true);
|
||||
|
||||
await this.phaseInterceptor.run(EncounterPhase);
|
||||
}
|
||||
|
@ -290,7 +290,8 @@ export default class PhaseInterceptor {
|
||||
* @param phase - The phase to start.
|
||||
*/
|
||||
setMode(mode: Mode, ...args: any[]): Promise<void> {
|
||||
const currentPhase = this.scene.getCurrentPhase();
|
||||
const currentPhase = this.
|
||||
scene.getCurrentPhase();
|
||||
const instance = this.scene.ui;
|
||||
console.log("setMode", mode, args);
|
||||
const ret = this.originalSetMode.apply(instance, [mode, ...args]);
|
||||
|
Loading…
Reference in New Issue
Block a user