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 ];
export let poolHasEviolite: boolean = false;
export let poolHasBlackHole: boolean = false;
export const itemPoolChecks: Map<ModifierTypeKeys, boolean> = new Map();
export function regenerateModifierPoolThresholds(party: Pokemon[], poolType: ModifierPoolType, rerollCount: integer = 0) {
const pool = getModifierPoolForType(poolType);
poolHasEviolite = false;
poolHasBlackHole = false;
itemPoolChecks.forEach((v, k) => {
itemPoolChecks.set(k, false);
});
const ignoredIndexes = {};
const modifierTableData = {};
@ -1943,11 +1943,8 @@ export function regenerateModifierPoolThresholds(party: Pokemon[], poolType: Mod
ignoredIndexes[t].push(i++);
return total;
}
if (modifierType.modifierType.id === "EVIOLITE") {
poolHasEviolite = true;
}
if (modifierType.modifierType.id === "MINI_BLACK_HOLE") {
poolHasBlackHole = true;
if (itemPoolChecks.has(modifierType.modifierType.id as ModifierTypeKeys)) {
itemPoolChecks.set(modifierType.modifierType.id as ModifierTypeKeys, true);
}
thresholds.set(total, i++);
return total;

View File

@ -1,9 +1,9 @@
import { Abilities } from "#app/enums/abilities";
import { Moves } from "#app/enums/moves";
import { MapModifier } from "#app/modifier/modifier";
import { poolHasBlackHole, poolHasEviolite } from "#app/modifier/modifier-type";
import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";
import GameManager from "./utils/gameManager";
import { itemPoolChecks } from "#app/modifier/modifier-type";
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 () => {
await game.classicMode.startBattle();
itemPoolChecks.set("EVIOLITE", false);
itemPoolChecks.set("MINI_BLACK_HOLE", false);
game.move.select(Moves.SURF);
await game.phaseInterceptor.to("SelectModifierPhase", false);
expect(poolHasEviolite).toBeFalsy();
expect(poolHasBlackHole).toBeFalsy();
expect(itemPoolChecks.get("EVIOLITE")).toBeFalsy();
expect(itemPoolChecks.get("MINI_BLACK_HOLE")).toBeFalsy();
itemPoolChecks.clear();
}, TIMEOUT);
it("should allow Eviolite and Mini Black Hole in shop when in Daily Run", async () => {
await game.dailyMode.startBattle();
itemPoolChecks.set("EVIOLITE", false);
itemPoolChecks.set("MINI_BLACK_HOLE", false);
game.move.select(Moves.SURF);
await game.phaseInterceptor.to("SelectModifierPhase", false);
expect(poolHasEviolite).toBeTruthy();
expect(poolHasBlackHole).toBeTruthy();
expect(itemPoolChecks.get("EVIOLITE")).toBeTruthy();
expect(itemPoolChecks.get("MINI_BLACK_HOLE")).toBeTruthy();
itemPoolChecks.clear();
}, 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 * as Utils from "../utils";
import GameManager from "./utils/gameManager";
import { getPartyLuckValue } from "#app/modifier/modifier-type";
describe("game-mode", () => {
let phaserGame: Phaser.Game;
let game: GameManager;
@ -41,22 +42,39 @@ describe("game-mode", () => {
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 () => {
let classicGameMode: GameMode;
let dailyGameMode: GameMode;
beforeAll(() => {
phaserGame = new Phaser.Game({
type: Phaser.HEADLESS,
});
});
afterEach(() => {
game.phaseInterceptor.restoreOg();
});
beforeEach(() => {
game = new GameManager(phaserGame);
classicGameMode = getGameMode(GameModes.CLASSIC);
dailyGameMode = getGameMode(GameModes.DAILY);
});
const party = game.scene.getParty();
const oldmode = game.scene.gameMode;
game.scene.gameMode = classicGameMode!;
expect(getPartyLuckValue(party)).toBe(3);
game.scene.gameMode = dailyGameMode!;
expect(getPartyLuckValue(party)).toBe(0);
game.scene.gameMode = oldmode;
})
*/
it("does not apply luck in Daily Runs", () => {
game.override
.shinyLevel(true, 2);
const party = game.scene.getParty();
const oldmode = game.scene.gameMode;
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 { vi } from "vitest";
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
@ -316,6 +317,27 @@ export class OverridesHelper extends GameManagerHelper {
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
* @param healthSegments the number of segments to give