I forgot what desc I wrote this morning but here you go

Still working on this, but will submit now to show my work
This commit is contained in:
RedstonewolfX 2024-09-12 19:35:04 -04:00
parent 8fdce2405c
commit 0114d795a5
4 changed files with 74 additions and 27 deletions

View File

@ -1900,13 +1900,13 @@ export function getModifierPoolForType(poolType: ModifierPoolType): ModifierPool
} }
const tierWeights = [ 768 / 1024, 195 / 1024, 48 / 1024, 12 / 1024, 1 / 1024 ]; const tierWeights = [ 768 / 1024, 195 / 1024, 48 / 1024, 12 / 1024, 1 / 1024 ];
export let poolHasEviolite: boolean = false; export const itemPoolChecks: Map<ModifierTypeKeys, boolean> = new Map();
export let poolHasBlackHole: boolean = false;
export function regenerateModifierPoolThresholds(party: Pokemon[], poolType: ModifierPoolType, rerollCount: integer = 0) { export function regenerateModifierPoolThresholds(party: Pokemon[], poolType: ModifierPoolType, rerollCount: integer = 0) {
const pool = getModifierPoolForType(poolType); const pool = getModifierPoolForType(poolType);
poolHasEviolite = false; itemPoolChecks.forEach((v, k) => {
poolHasBlackHole = false; itemPoolChecks.set(k, false);
});
const ignoredIndexes = {}; const ignoredIndexes = {};
const modifierTableData = {}; const modifierTableData = {};
@ -1943,11 +1943,8 @@ export function regenerateModifierPoolThresholds(party: Pokemon[], poolType: Mod
ignoredIndexes[t].push(i++); ignoredIndexes[t].push(i++);
return total; return total;
} }
if (modifierType.modifierType.id === "EVIOLITE") { if (itemPoolChecks.has(modifierType.modifierType.id as ModifierTypeKeys)) {
poolHasEviolite = true; itemPoolChecks.set(modifierType.modifierType.id as ModifierTypeKeys, true);
}
if (modifierType.modifierType.id === "MINI_BLACK_HOLE") {
poolHasBlackHole = true;
} }
thresholds.set(total, i++); thresholds.set(total, i++);
return total; return total;

View File

@ -1,9 +1,9 @@
import { Abilities } from "#app/enums/abilities"; import { Abilities } from "#app/enums/abilities";
import { Moves } from "#app/enums/moves"; import { Moves } from "#app/enums/moves";
import { MapModifier } from "#app/modifier/modifier"; import { MapModifier } from "#app/modifier/modifier";
import { poolHasBlackHole, poolHasEviolite } from "#app/modifier/modifier-type";
import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";
import GameManager from "./utils/gameManager"; import GameManager from "./utils/gameManager";
import { itemPoolChecks } from "#app/modifier/modifier-type";
const TIMEOUT = 20 * 1000; const TIMEOUT = 20 * 1000;
@ -64,18 +64,28 @@ describe("Shop modifications", async () => {
it("should only allow Mini Black Hole and Eviolite outside of Daily if unlocked", async () => { it("should only allow Mini Black Hole and Eviolite outside of Daily if unlocked", async () => {
await game.classicMode.startBattle(); await game.classicMode.startBattle();
itemPoolChecks.set("EVIOLITE", false);
itemPoolChecks.set("MINI_BLACK_HOLE", false);
game.move.select(Moves.SURF); game.move.select(Moves.SURF);
await game.phaseInterceptor.to("SelectModifierPhase", false); await game.phaseInterceptor.to("SelectModifierPhase", false);
expect(poolHasEviolite).toBeFalsy(); expect(itemPoolChecks.get("EVIOLITE")).toBeFalsy();
expect(poolHasBlackHole).toBeFalsy(); expect(itemPoolChecks.get("MINI_BLACK_HOLE")).toBeFalsy();
itemPoolChecks.clear();
}, TIMEOUT); }, TIMEOUT);
it("should allow Eviolite and Mini Black Hole in shop when in Daily Run", async () => { it("should allow Eviolite and Mini Black Hole in shop when in Daily Run", async () => {
await game.dailyMode.startBattle(); await game.dailyMode.startBattle();
itemPoolChecks.set("EVIOLITE", false);
itemPoolChecks.set("MINI_BLACK_HOLE", false);
game.move.select(Moves.SURF); game.move.select(Moves.SURF);
await game.phaseInterceptor.to("SelectModifierPhase", false); await game.phaseInterceptor.to("SelectModifierPhase", false);
expect(poolHasEviolite).toBeTruthy(); expect(itemPoolChecks.get("EVIOLITE")).toBeTruthy();
expect(poolHasBlackHole).toBeTruthy(); expect(itemPoolChecks.get("MINI_BLACK_HOLE")).toBeTruthy();
itemPoolChecks.clear();
}, TIMEOUT); }, TIMEOUT);
}); });

View File

@ -2,6 +2,7 @@ import { GameMode, GameModes, getGameMode } from "#app/game-mode";
import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
import * as Utils from "../utils"; import * as Utils from "../utils";
import GameManager from "./utils/gameManager"; import GameManager from "./utils/gameManager";
import { getPartyLuckValue } from "#app/modifier/modifier-type";
describe("game-mode", () => { describe("game-mode", () => {
let phaserGame: Phaser.Game; let phaserGame: Phaser.Game;
let game: GameManager; let game: GameManager;
@ -41,22 +42,39 @@ describe("game-mode", () => {
expect(classicGameMode.isWaveTrainer(19, arena)).toBeFalsy(); expect(classicGameMode.isWaveTrainer(19, arena)).toBeFalsy();
}); });
}); });
/* //*
Need to figure out how to override my party members' luck to calculate this //Need to figure out how to override my party members' luck to calculate this
describe("Luck Check", async () => { describe("Luck Check", async () => {
let classicGameMode: GameMode; let classicGameMode: GameMode;
let dailyGameMode: GameMode; let dailyGameMode: GameMode;
beforeAll(() => {
phaserGame = new Phaser.Game({
type: Phaser.HEADLESS,
});
});
afterEach(() => {
game.phaseInterceptor.restoreOg();
});
beforeEach(() => { beforeEach(() => {
game = new GameManager(phaserGame);
classicGameMode = getGameMode(GameModes.CLASSIC); classicGameMode = getGameMode(GameModes.CLASSIC);
dailyGameMode = getGameMode(GameModes.DAILY); dailyGameMode = getGameMode(GameModes.DAILY);
}); });
const party = game.scene.getParty();
const oldmode = game.scene.gameMode; it("does not apply luck in Daily Runs", () => {
game.scene.gameMode = classicGameMode!; game.override
expect(getPartyLuckValue(party)).toBe(3); .shinyLevel(true, 2);
game.scene.gameMode = dailyGameMode!; const party = game.scene.getParty();
expect(getPartyLuckValue(party)).toBe(0); const oldmode = game.scene.gameMode;
game.scene.gameMode = oldmode; game.scene.gameMode = classicGameMode!;
}) expect(getPartyLuckValue(party)).toBe(3);
*/ game.scene.gameMode = dailyGameMode!;
expect(getPartyLuckValue(party)).toBe(0);
game.scene.gameMode = oldmode;
});
});
//*/
}); });

View File

@ -10,7 +10,8 @@ import { ModifierOverride } from "#app/modifier/modifier-type";
import Overrides from "#app/overrides"; import Overrides from "#app/overrides";
import { vi } from "vitest"; import { vi } from "vitest";
import { GameManagerHelper } from "./gameManagerHelper"; import { GameManagerHelper } from "./gameManagerHelper";
import { Unlockables } from "#app/system/unlockables.js"; import { Unlockables } from "#app/system/unlockables";
import { Variant } from "#app/data/variant";
/** /**
* Helper to handle overrides in tests * Helper to handle overrides in tests
@ -304,7 +305,7 @@ export class OverridesHelper extends GameManagerHelper {
this.log("Temporarily unlocked the following content: ", unlockable); this.log("Temporarily unlocked the following content: ", unlockable);
return this; return this;
} }
/** /**
* Override the items rolled at the end of a battle * Override the items rolled at the end of a battle
* @param items the items to be rolled * @param items the items to be rolled
@ -316,6 +317,27 @@ export class OverridesHelper extends GameManagerHelper {
return this; return this;
} }
/**
* Override player shininess
* @param shininess Whether the player's Pokemon should be shiny.
* @param variant The player's shiny variant.
*/
shinyLevel(shininess?: boolean, variant?: Variant): this {
if (shininess !== undefined) {
vi.spyOn(Overrides, "SHINY_OVERRIDE", "get").mockReturnValue(shininess);
}
if (variant !== undefined) {
vi.spyOn(Overrides, "VARIANT_OVERRIDE", "get").mockReturnValue(variant);
}
if (shininess !== undefined) {
this.log(`Set player Pokemon as ${shininess ? "" : "not "}shiny!`);
}
if (variant !== undefined) {
this.log(`Set player Pokemon's shiny variant to ${variant}!`);
}
return this;
}
/** /**
* Override the enemy (Pokemon) to have the given amount of health segments * Override the enemy (Pokemon) to have the given amount of health segments
* @param healthSegments the number of segments to give * @param healthSegments the number of segments to give