Hopefully fixed tests since we use Phaser.Math.RND.frac

This commit is contained in:
Bertie690 2025-05-04 09:39:36 -04:00
parent 37e98e3c7d
commit 0eac761e72
5 changed files with 10 additions and 14 deletions

View File

@ -160,7 +160,7 @@ describe("Abilities - Harvest", () => {
// ate 1 berry and recovered it
expect(regieleki.battleData.berriesEaten).toEqual([]);
expect(getPlayerBerries()).toEqual([expect.objectContaining({ berryType: BerryType.PETAYA, stackCount: 1 })]);
expectBerriesContaining({ name: "BERRY", type: BerryType.PETAYA, count: 1 });
expect(game.scene.getPlayerPokemon()?.getStatStage(Stat.SPATK)).toBe(1);
// heal up so harvest doesn't proc and kill enemy

View File

@ -9,6 +9,7 @@ import { StatusEffect } from "#enums/status-effect";
import GameManager from "#test/testUtils/gameManager";
import Phaser from "phaser";
import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
import { randSeedFloat } from "#app/utils/common";
describe("Double Battles", () => {
const DOUBLE_CHANCE = 8; // Normal chance of double battle is 1/8
@ -62,9 +63,7 @@ describe("Double Battles", () => {
let doubleCount = 0;
let singleCount = 0;
vi.spyOn(Phaser.Math.RND, "realInRange").mockImplementation((min: number, max: number) => {
return rngSweepProgress * (max - min) + min;
});
vi.fn(randSeedFloat).mockImplementation(() => rngSweepProgress);
game.override
.enemyMoveset(Moves.SPLASH)

View File

@ -1,6 +1,7 @@
import { Egg } from "#app/data/egg";
import { EggSourceType } from "#app/enums/egg-source-types";
import { EggTier } from "#app/enums/egg-type";
import { randSeedFloat } from "#app/utils/common";
import { Species } from "#enums/species";
import GameManager from "#test/testUtils/gameManager";
import Phaser from "phaser";
@ -9,7 +10,7 @@ import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vite
describe("Manaphy Eggs", () => {
let phaserGame: Phaser.Game;
let game: GameManager;
const EGG_HATCH_COUNT: number = 48;
const EGG_HATCH_COUNT = 48;
let rngSweepProgress = 0;
beforeAll(() => {
@ -33,9 +34,7 @@ describe("Manaphy Eggs", () => {
* possible RNG outcomes. This will let us quickly and consistently find
* the probability of each RNG outcome.
*/
vi.spyOn(Phaser.Math.RND, "realInRange").mockImplementation((min: number, max: number) => {
return rngSweepProgress * (max - min) + min;
});
vi.fn(randSeedFloat).mockImplementation(() => rngSweepProgress);
});
it("should have correct Manaphy rates and Rare Egg Move rates, from the egg gacha", () => {

View File

@ -20,6 +20,7 @@ import {
} from "#app/data/mystery-encounters/encounters/safari-zone-encounter";
import * as EncounterPhaseUtils from "#app/data/mystery-encounters/utils/encounter-phase-utils";
import { NON_LEGEND_PARADOX_POKEMON } from "#app/data/balance/special-species-groups";
import { randSeedFloat } from "#app/utils/common";
const namespace = "mysteryEncounters/safariZone";
const defaultParty = [Species.LAPRAS, Species.GENGAR, Species.ABRA];
@ -134,9 +135,7 @@ describe("Safari Zone - Mystery Encounter", () => {
const NUM_ROLLS = 2000; // As long as this is greater than total number of species, this should cover all possible RNG rolls
let rngSweepProgress = 0; // Will simulate full range of RNG rolls by steadily increasing from 0 to 1
vi.spyOn(Phaser.Math.RND, "realInRange").mockImplementation((min: number, max: number) => {
return rngSweepProgress * (max - min) + min;
});
vi.fn(randSeedFloat).mockImplementation(() => rngSweepProgress);
vi.spyOn(Phaser.Math.RND, "shuffle").mockImplementation((arr: any[]) => arr);
for (let i = 0; i < NUM_ROLLS; i++) {

View File

@ -21,6 +21,7 @@ import { MysteryEncounterTier } from "#enums/mystery-encounter-tier";
import { initSceneWithoutEncounterPhase } from "#test/testUtils/gameManagerUtils";
import { MysteryEncounterPhase } from "#app/phases/mystery-encounter-phases";
import { NON_LEGEND_PARADOX_POKEMON } from "#app/data/balance/special-species-groups";
import { randSeedFloat } from "#app/utils/common";
const namespace = "mysteryEncounters/thePokemonSalesman";
const defaultParty = [Species.LAPRAS, Species.GENGAR, Species.ABRA];
@ -195,9 +196,7 @@ describe("The Pokemon Salesman - Mystery Encounter", () => {
const NUM_ROLLS = 2000; // As long as this is greater than total number of species, this should cover all possible RNG rolls
let rngSweepProgress = 0; // Will simulate full range of RNG rolls by steadily increasing from 0 to 1
vi.spyOn(Phaser.Math.RND, "realInRange").mockImplementation((min: number, max: number) => {
return rngSweepProgress * (max - min) + min;
});
vi.fn(randSeedFloat).mockImplementation(() => rngSweepProgress);
vi.spyOn(Phaser.Math.RND, "shuffle").mockImplementation((arr: any[]) => arr);
for (let i = 0; i < NUM_ROLLS; i++) {