Commit for testing

This commit is contained in:
RedstonewolfX 2024-09-24 18:02:47 -04:00
parent e706aadcd7
commit 97542cefd8
3 changed files with 14 additions and 53 deletions

View File

@ -2448,7 +2448,11 @@ export class ModifierTypeOption {
*/ */
export function getPartyLuckValue(party: Pokemon[]): integer { export function getPartyLuckValue(party: Pokemon[]): integer {
if (party[0].scene.gameMode.isDaily) { if (party[0].scene.gameMode.isDaily) {
return 0; let DailyLuck: integer = 0;
party[0].scene.executeWithSeedOffset(() => {
DailyLuck = Utils.randSeedInt(15); // Random number between 0 and 14
}, 0, party[0].scene.seed);
return DailyLuck;
} }
const luck = Phaser.Math.Clamp(party.map(p => p.isAllowedInBattle() ? (p.scene.gameMode.isDaily ? 0 : p.getLuck()) : 0) const luck = Phaser.Math.Clamp(party.map(p => p.isAllowedInBattle() ? (p.scene.gameMode.isDaily ? 0 : p.getLuck()) : 0)
.reduce((total: integer, value: integer) => total += value, 0), 0, 14); .reduce((total: integer, value: integer) => total += value, 0), 0, 14);

View File

@ -1,12 +1,10 @@
import { MapModifier } from "#app/modifier/modifier"; import { MapModifier } from "#app/modifier/modifier";
import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";
import GameManager from "./utils/gameManager"; import GameManager from "./utils/gameManager";
import { Moves } from "#app/enums/moves"; import { Moves } from "#app/enums/moves";
import { getPartyLuckValue } from "#app/modifier/modifier-type";
import { Biome } from "#app/enums/biome"; import { Biome } from "#app/enums/biome";
import { Mode } from "#app/ui/ui"; import { Mode } from "#app/ui/ui";
import ModifierSelectUiHandler from "#app/ui/modifier-select-ui-handler"; import ModifierSelectUiHandler from "#app/ui/modifier-select-ui-handler";
import { Species } from "#app/enums/species";
//const TIMEOUT = 20 * 1000; //const TIMEOUT = 20 * 1000;
@ -62,8 +60,9 @@ describe("Shop modifications", async () => {
.disableTrainerWaves() .disableTrainerWaves()
.moveset([Moves.KOWTOW_CLEAVE]) .moveset([Moves.KOWTOW_CLEAVE])
.enemyMoveset(Moves.SPLASH); .enemyMoveset(Moves.SPLASH);
game.modifiers.addCheck("EVIOLITE"); game.modifiers
game.modifiers.addCheck("MINI_BLACK_HOLE"); .addCheck("EVIOLITE")
.addCheck("MINI_BLACK_HOLE");
}); });
afterEach(() => { afterEach(() => {
@ -99,48 +98,3 @@ describe("Shop modifications", async () => {
}); });
}); });
}); });
describe("Luck 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);
});
afterEach(() => {
game.phaseInterceptor.restoreOg();
});
it("should apply luck in Classic Mode", async () => {
await game.classicMode.startBattle([Species.PIKACHU]);
const party = game.scene.getParty();
vi.spyOn(party[0], "getLuck").mockReturnValue(3);
expect(party[0].getLuck()).toBeGreaterThan(0);
expect(getPartyLuckValue(party)).toBeGreaterThan(0);
});
it("should not apply luck in Daily Run", async () => {
await game.dailyMode.startBattle();
const party = game.scene.getParty();
vi.spyOn(party[0], "getLuck").mockReturnValue(3);
expect(party[0].getLuck()).toBeGreaterThan(0);
expect(getPartyLuckValue(party)).toBe(0);
});
});
//*/

View File

@ -8,9 +8,11 @@ export class ModifierHelper extends GameManagerHelper {
* *
* Note that all modifiers are updated during the start of `SelectModifierPhase`. * Note that all modifiers are updated during the start of `SelectModifierPhase`.
* @param modifier The Modifier to add. * @param modifier The Modifier to add.
* @returns `this`
*/ */
addCheck(modifier: ModifierTypeKeys) { addCheck(modifier: ModifierTypeKeys): this {
itemPoolChecks.set(modifier, undefined); itemPoolChecks.set(modifier, undefined);
return this;
} }
checkHasRun(modifier: ModifierTypeKeys): boolean { checkHasRun(modifier: ModifierTypeKeys): boolean {
@ -51,9 +53,10 @@ export class ModifierHelper extends GameManagerHelper {
return this; return this;
} }
/** Removes all modifier checks. */ /** Removes all modifier checks. @returns `this` */
clearChecks() { clearChecks() {
itemPoolChecks.clear(); itemPoolChecks.clear();
return this;
} }
private log(...params: any[]) { private log(...params: any[]) {