2024-09-03 09:14:45 -04:00
|
|
|
import { GameModes } from "#app/game-mode";
|
2024-09-26 04:39:59 -04:00
|
|
|
import OptionSelectUiHandler from "#app/ui/settings/option-select-ui-handler";
|
|
|
|
import { Mode } from "#app/ui/ui";
|
|
|
|
import { Biome } from "#enums/biome";
|
|
|
|
import { Button } from "#enums/buttons";
|
|
|
|
import { Moves } from "#enums/moves";
|
|
|
|
import { Species } from "#enums/species";
|
2024-09-03 09:14:45 -04:00
|
|
|
import GameManager from "#test/utils/gameManager";
|
2024-09-26 04:39:59 -04:00
|
|
|
import { MockClock } from "#test/utils/mocks/mockClock";
|
2024-09-03 09:14:45 -04:00
|
|
|
import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";
|
|
|
|
|
|
|
|
describe("Reload", () => {
|
|
|
|
let phaserGame: Phaser.Game;
|
|
|
|
let game: GameManager;
|
|
|
|
|
|
|
|
beforeAll(() => {
|
|
|
|
phaserGame = new Phaser.Game({
|
|
|
|
type: Phaser.HEADLESS,
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
afterEach(() => {
|
|
|
|
game.phaseInterceptor.restoreOg();
|
|
|
|
});
|
|
|
|
|
|
|
|
beforeEach(() => {
|
|
|
|
game = new GameManager(phaserGame);
|
|
|
|
});
|
|
|
|
|
|
|
|
it("should not have RNG inconsistencies in a Classic run", async () => {
|
|
|
|
await game.classicMode.startBattle();
|
|
|
|
|
|
|
|
const preReloadRngState = Phaser.Math.RND.state();
|
|
|
|
|
|
|
|
await game.reload.reloadSession();
|
|
|
|
|
|
|
|
const postReloadRngState = Phaser.Math.RND.state();
|
|
|
|
|
|
|
|
expect(preReloadRngState).toBe(postReloadRngState);
|
|
|
|
}, 20000);
|
|
|
|
|
2024-09-23 12:32:07 -07:00
|
|
|
it("should not have RNG inconsistencies after a biome switch", async () => {
|
2024-09-03 09:14:45 -04:00
|
|
|
game.override
|
|
|
|
.startingWave(10)
|
|
|
|
.battleType("single")
|
2024-09-16 15:30:42 -04:00
|
|
|
.startingLevel(100) // Avoid levelling up
|
2024-09-03 09:14:45 -04:00
|
|
|
.disableTrainerWaves()
|
2024-10-04 10:42:20 -04:00
|
|
|
.moveset([ Moves.SPLASH ])
|
2024-09-09 09:55:11 -07:00
|
|
|
.enemyMoveset(Moves.SPLASH);
|
2024-09-03 09:14:45 -04:00
|
|
|
await game.dailyMode.startBattle();
|
|
|
|
|
2024-09-16 15:30:42 -04:00
|
|
|
// Transition from Wave 10 to Wave 11 in order to trigger biome switch
|
2024-10-04 10:42:20 -04:00
|
|
|
game.move.select(Moves.SPLASH);
|
2024-09-03 09:14:45 -04:00
|
|
|
await game.doKillOpponents();
|
2024-09-26 04:39:59 -04:00
|
|
|
game.onNextPrompt("SelectBiomePhase", Mode.OPTION_SELECT, () => {
|
|
|
|
(game.scene.time as MockClock).overrideDelay = null;
|
|
|
|
const optionSelectUiHandler = game.scene.ui.getHandler() as OptionSelectUiHandler;
|
|
|
|
game.scene.time.delayedCall(1010, () => optionSelectUiHandler.processInput(Button.ACTION));
|
|
|
|
game.endPhase();
|
|
|
|
(game.scene.time as MockClock).overrideDelay = 1;
|
|
|
|
});
|
2024-09-03 09:14:45 -04:00
|
|
|
await game.toNextWave();
|
|
|
|
expect(game.phaseInterceptor.log).toContain("NewBiomeEncounterPhase");
|
|
|
|
|
|
|
|
const preReloadRngState = Phaser.Math.RND.state();
|
|
|
|
|
|
|
|
await game.reload.reloadSession();
|
|
|
|
|
|
|
|
const postReloadRngState = Phaser.Math.RND.state();
|
|
|
|
|
|
|
|
expect(preReloadRngState).toBe(postReloadRngState);
|
|
|
|
}, 20000);
|
|
|
|
|
2024-09-16 15:30:42 -04:00
|
|
|
it("should not have weather inconsistencies after a biome switch", async () => {
|
|
|
|
game.override
|
|
|
|
.startingWave(10)
|
|
|
|
.startingBiome(Biome.ICE_CAVE) // Will lead to Snowy Forest with randomly generated weather
|
|
|
|
.battleType("single")
|
|
|
|
.startingLevel(100) // Avoid levelling up
|
|
|
|
.disableTrainerWaves()
|
2024-10-04 10:42:20 -04:00
|
|
|
.moveset([ Moves.SPLASH ])
|
2024-09-16 15:30:42 -04:00
|
|
|
.enemyMoveset(Moves.SPLASH);
|
|
|
|
await game.classicMode.startBattle(); // Apparently daily mode would override the biome
|
|
|
|
|
|
|
|
// Transition from Wave 10 to Wave 11 in order to trigger biome switch
|
2024-10-04 10:42:20 -04:00
|
|
|
game.move.select(Moves.SPLASH);
|
2024-09-16 15:30:42 -04:00
|
|
|
await game.doKillOpponents();
|
|
|
|
await game.toNextWave();
|
|
|
|
expect(game.phaseInterceptor.log).toContain("NewBiomeEncounterPhase");
|
|
|
|
|
|
|
|
const preReloadWeather = game.scene.arena.weather;
|
|
|
|
|
|
|
|
await game.reload.reloadSession();
|
|
|
|
|
|
|
|
const postReloadWeather = game.scene.arena.weather;
|
|
|
|
|
|
|
|
expect(postReloadWeather).toStrictEqual(preReloadWeather);
|
|
|
|
}, 20000);
|
|
|
|
|
2024-09-03 09:14:45 -04:00
|
|
|
it("should not have RNG inconsistencies at a Daily run wild Pokemon fight", async () => {
|
|
|
|
await game.dailyMode.startBattle();
|
|
|
|
|
|
|
|
const preReloadRngState = Phaser.Math.RND.state();
|
|
|
|
|
|
|
|
await game.reload.reloadSession();
|
|
|
|
|
|
|
|
const postReloadRngState = Phaser.Math.RND.state();
|
|
|
|
|
|
|
|
expect(preReloadRngState).toBe(postReloadRngState);
|
|
|
|
}, 20000);
|
|
|
|
|
|
|
|
it("should not have RNG inconsistencies at a Daily run double battle", async () => {
|
|
|
|
game.override
|
|
|
|
.battleType("double");
|
|
|
|
await game.dailyMode.startBattle();
|
|
|
|
|
|
|
|
const preReloadRngState = Phaser.Math.RND.state();
|
|
|
|
|
|
|
|
await game.reload.reloadSession();
|
|
|
|
|
|
|
|
const postReloadRngState = Phaser.Math.RND.state();
|
|
|
|
|
|
|
|
expect(preReloadRngState).toBe(postReloadRngState);
|
|
|
|
}, 20000);
|
|
|
|
|
|
|
|
it("should not have RNG inconsistencies at a Daily run Gym Leader fight", async () => {
|
|
|
|
game.override
|
|
|
|
.battleType("single")
|
|
|
|
.startingWave(40);
|
|
|
|
await game.dailyMode.startBattle();
|
|
|
|
|
|
|
|
const preReloadRngState = Phaser.Math.RND.state();
|
|
|
|
|
|
|
|
await game.reload.reloadSession();
|
|
|
|
|
|
|
|
const postReloadRngState = Phaser.Math.RND.state();
|
|
|
|
|
|
|
|
expect(preReloadRngState).toBe(postReloadRngState);
|
|
|
|
}, 20000);
|
|
|
|
|
|
|
|
it("should not have RNG inconsistencies at a Daily run regular trainer fight", async () => {
|
|
|
|
game.override
|
|
|
|
.battleType("single")
|
|
|
|
.startingWave(45);
|
|
|
|
await game.dailyMode.startBattle();
|
|
|
|
|
|
|
|
const preReloadRngState = Phaser.Math.RND.state();
|
|
|
|
|
|
|
|
await game.reload.reloadSession();
|
|
|
|
|
|
|
|
const postReloadRngState = Phaser.Math.RND.state();
|
|
|
|
|
|
|
|
expect(preReloadRngState).toBe(postReloadRngState);
|
|
|
|
}, 20000);
|
|
|
|
|
|
|
|
it("should not have RNG inconsistencies at a Daily run wave 50 Boss fight", async () => {
|
|
|
|
game.override
|
|
|
|
.battleType("single")
|
|
|
|
.startingWave(50);
|
2024-10-04 13:08:31 +08:00
|
|
|
await game.runToFinalBossEncounter([ Species.BULBASAUR ], GameModes.DAILY);
|
2024-09-03 09:14:45 -04:00
|
|
|
|
|
|
|
const preReloadRngState = Phaser.Math.RND.state();
|
|
|
|
|
|
|
|
await game.reload.reloadSession();
|
|
|
|
|
|
|
|
const postReloadRngState = Phaser.Math.RND.state();
|
|
|
|
|
|
|
|
expect(preReloadRngState).toBe(postReloadRngState);
|
|
|
|
}, 20000);
|
|
|
|
});
|