It's over

This commit is contained in:
RedstonewolfX 2024-09-19 10:36:56 -04:00
parent 0b94a3b849
commit cc2d9c0e03
4 changed files with 22 additions and 16 deletions

View File

@ -5,7 +5,6 @@ import { PlayerPokemon } from "../field/pokemon";
import { Starter } from "../ui/starter-select-ui-handler";
import * as Utils from "../utils";
import PokemonSpecies, { PokemonSpeciesForm, getPokemonSpecies, getPokemonSpeciesForm, speciesStarters } from "./pokemon-species";
import Overrides from "#app/overrides";
export interface DailyRunConfig {
seed: integer;
@ -62,7 +61,7 @@ export function getDailyRunStarters(scene: BattleScene, seed: string): Starter[]
function getDailyRunStarter(scene: BattleScene, starterSpeciesForm: PokemonSpeciesForm, startingLevel: integer): Starter {
const starterSpecies = starterSpeciesForm instanceof PokemonSpecies ? starterSpeciesForm : getPokemonSpecies(starterSpeciesForm.speciesId);
const formIndex = starterSpeciesForm instanceof PokemonSpecies ? undefined : starterSpeciesForm.formIndex;
const pokemon = new PlayerPokemon(scene, starterSpecies, startingLevel, undefined, formIndex, undefined, Overrides.SHINY_OVERRIDE ? Overrides.SHINY_OVERRIDE : undefined, Overrides.VARIANT_OVERRIDE ? Overrides.VARIANT_OVERRIDE : undefined, undefined, undefined, undefined);
const pokemon = new PlayerPokemon(scene, starterSpecies, startingLevel, undefined, formIndex, undefined, undefined, undefined, undefined, undefined, undefined);
const starter: Starter = {
species: starterSpecies,
dexAttr: pokemon.getDexAttr(),

View File

@ -1970,6 +1970,15 @@ export function getModifierPoolForType(poolType: ModifierPoolType): ModifierPool
}
const tierWeights = [ 768 / 1024, 195 / 1024, 48 / 1024, 12 / 1024, 1 / 1024 ];
/**
* Allows a unit test to check if an item exists in the Modifier Pool. Checks the pool directly, rather than attempting to reroll for the item.
* `set` a key to `false` to create a check for it. (I.E. `itemPoolChecks.set("RARE_CANDY", false)`)
*
*
* Within the SelectModifierPhase (`GameManager.onNextPrompt("SelectModifierPhase", Mode.MODIFIER_SELECT, () => {})`), you can `expect` these values.
*
* (I.E. `expect(itemPoolChecks.get("RARE_CANDY")).toBeTruthy()` checks whether Rare Candy can be offered to the player)
*/
export const itemPoolChecks: Map<ModifierTypeKeys, boolean> = new Map();
export function regenerateModifierPoolThresholds(party: Pokemon[], poolType: ModifierPoolType, rerollCount: integer = 0) {

View File

@ -1,5 +1,5 @@
import { MapModifier } from "#app/modifier/modifier";
import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";
import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
import GameManager from "./utils/gameManager";
import { Moves } from "#app/enums/moves";
import { getPartyLuckValue, itemPoolChecks } from "#app/modifier/modifier-type";
@ -7,7 +7,7 @@ import { Biome } from "#app/enums/biome";
import { BattleEndPhase } from "#app/phases/battle-end-phase";
import { Mode } from "#app/ui/ui";
import ModifierSelectUiHandler from "#app/ui/modifier-select-ui-handler";
import Overrides from "#app/overrides";
import { Species } from "#app/enums/species";
//const TIMEOUT = 20 * 1000;
@ -74,51 +74,49 @@ describe("Shop modifications", async () => {
afterEach(() => {
game.phaseInterceptor.restoreOg();
itemPoolChecks.clear();
vi.resetAllMocks();
vi.clearAllMocks();
});
it("should not have Eviolite and Mini Black Hole available in Classic if not unlocked", async () => {
await game.classicMode.runToSummon();
expect(itemPoolChecks.get("EVIOLITE")).toBeDefined();
expect(itemPoolChecks.get("EVIOLITE")).toBeFalsy();
expect(itemPoolChecks.get("MINI_BLACK_HOLE")).toBeDefined();
expect(itemPoolChecks.get("MINI_BLACK_HOLE")).toBeFalsy();
const party = game.scene.getParty();
game.move.select(Moves.KOWTOW_CLEAVE);
await game.phaseInterceptor.to("DamagePhase");
await game.doKillOpponents();
await game.phaseInterceptor.to(BattleEndPhase);
game.onNextPrompt("SelectModifierPhase", Mode.MODIFIER_SELECT, () => {
expect(game.scene.ui.getHandler()).toBeInstanceOf(ModifierSelectUiHandler);
expect(itemPoolChecks.get("EVIOLITE")).toBeDefined();
expect(itemPoolChecks.get("EVIOLITE")).toBeFalsy();
expect(itemPoolChecks.get("MINI_BLACK_HOLE")).toBeDefined();
expect(itemPoolChecks.get("MINI_BLACK_HOLE")).toBeFalsy();
expect(party[0].getLuck()).toBeGreaterThan(0);
});
});
it("should have Eviolite and Mini Black Hole available in Daily", async () => {
await game.dailyMode.runToSummon();
expect(itemPoolChecks.get("EVIOLITE")).toBeDefined();
expect(itemPoolChecks.get("EVIOLITE")).toBeFalsy();
expect(itemPoolChecks.get("MINI_BLACK_HOLE")).toBeDefined();
expect(itemPoolChecks.get("MINI_BLACK_HOLE")).toBeFalsy();
const party = game.scene.getParty();
game.move.select(Moves.KOWTOW_CLEAVE);
await game.phaseInterceptor.to("DamagePhase");
await game.doKillOpponents();
await game.phaseInterceptor.to(BattleEndPhase);
game.onNextPrompt("SelectModifierPhase", Mode.MODIFIER_SELECT, () => {
expect(game.scene.ui.getHandler()).toBeInstanceOf(ModifierSelectUiHandler);
expect(itemPoolChecks.get("EVIOLITE")).toBeDefined();
expect(itemPoolChecks.get("EVIOLITE")).toBeTruthy();
expect(itemPoolChecks.get("MINI_BLACK_HOLE")).toBeDefined();
expect(itemPoolChecks.get("MINI_BLACK_HOLE")).toBeTruthy();
expect(party[0].getLuck()).toBeGreaterThan(0);
});
});
it("should apply luck in Classic Mode", async () => {
await game.classicMode.runToSummon();
await game.classicMode.runToSummon([Species.PIKACHU]);
const party = game.scene.getParty();
expect(Overrides.SHINY_OVERRIDE).toBeTruthy();
expect(party[0]).toBeDefined();
vi.spyOn(party[0], "getLuck").mockReturnValue(3);
expect(party[0].getLuck()).toBeGreaterThan(0);
expect(getPartyLuckValue(party)).toBeGreaterThan(0);
});
@ -127,6 +125,7 @@ describe("Shop modifications", async () => {
await game.dailyMode.runToSummon();
const party = game.scene.getParty();
expect(party[0]).toBeDefined();
vi.spyOn(party[0], "getLuck").mockReturnValue(3);
expect(party[0].getLuck()).toBeGreaterThan(0);
expect(getPartyLuckValue(party)).toBe(0);
});

View File

@ -8,7 +8,6 @@ import { GameModes, getGameMode } from "#app/game-mode";
import { Starter } from "#app/ui/starter-select-ui-handler";
import { Species } from "#enums/species";
import Battle, { BattleType } from "#app/battle";
import Overrides from "#app/overrides";
/** Function to convert Blob to string */
export function blobToString(blob) {
@ -42,7 +41,7 @@ export function generateStarter(scene, species?: Species[]) {
const starterGender = starter.species.malePercent !== null
? !starterProps.female ? Gender.MALE : Gender.FEMALE
: Gender.GENDERLESS;
const starterPokemon = scene.addPlayerPokemon(starter.species, startingLevel, starter.abilityIndex, starterFormIndex, starterGender, Overrides.SHINY_OVERRIDE || starterProps.shiny, Overrides.VARIANT_OVERRIDE ? Overrides.VARIANT_OVERRIDE : starterProps.variant, undefined, starter.nature);
const starterPokemon = scene.addPlayerPokemon(starter.species, startingLevel, starter.abilityIndex, starterFormIndex, starterGender, starterProps.shiny, starterProps.variant, undefined, starter.nature);
starter.moveset = starterPokemon.moveset;
}
return starters;