Update overrides

Relocated the "isUnlocked" function to gameData since it requires a reference to it in order to run

Removed unnecessary override that disables unlocked items (and its associated overridesHelper statement)
This commit is contained in:
RedstonewolfX 2024-08-27 17:54:09 -04:00
parent d7263b6677
commit 3e65888ff1
7 changed files with 20 additions and 30 deletions

View File

@ -10,7 +10,7 @@ import PartyUiHandler, { PokemonMoveSelectFilter, PokemonSelectFilter } from "..
import * as Utils from "../utils";
import { TempBattleStat, getTempBattleStatBoosterItemName, getTempBattleStatName } from "../data/temp-battle-stat";
import { getBerryEffectDescription, getBerryName } from "../data/berry";
import { isUnlocked, Unlockables } from "../system/unlockables";
import { Unlockables } from "../system/unlockables";
import { StatusEffect, getStatusEffectDescriptor } from "../data/status-effect";
import { SpeciesFormKey } from "../data/pokemon-species";
import BattleScene from "../battle-scene";
@ -1597,7 +1597,7 @@ const modifierPool: ModifierPool = {
new WeightedModifierType(modifierTypes.AMULET_COIN, skipInLastClassicWaveOrDefault(3)),
new WeightedModifierType(modifierTypes.EVIOLITE, (party: Pokemon[]) => {
const { gameMode, gameData } = party[0].scene;
if (gameMode.isDaily || (!gameMode.isFreshStartChallenge() && isUnlocked(Unlockables.EVIOLITE, gameData))) {
if (gameMode.isDaily || (!gameMode.isFreshStartChallenge() && gameData.isUnlocked(Unlockables.EVIOLITE))) {
return party.some(p => ((p.getSpeciesForm(true).speciesId in pokemonEvolutions) || (p.isFusion() && (p.getFusionSpeciesForm(true).speciesId in pokemonEvolutions))) && !p.getHeldItems().some(i => i instanceof Modifiers.EvolutionStatBoosterModifier)) ? 10 : 0;
}
return 0;
@ -1675,7 +1675,7 @@ const modifierPool: ModifierPool = {
new WeightedModifierType(modifierTypes.MULTI_LENS, 18),
new WeightedModifierType(modifierTypes.VOUCHER_PREMIUM, (party: Pokemon[], rerollCount: integer) => !party[0].scene.gameMode.isDaily && !party[0].scene.gameMode.isEndless && !party[0].scene.gameMode.isSplicedOnly ? Math.max(5 - rerollCount * 2, 0) : 0, 5),
new WeightedModifierType(modifierTypes.DNA_SPLICERS, (party: Pokemon[]) => !party[0].scene.gameMode.isSplicedOnly && party.filter(p => !p.fusionSpecies).length > 1 ? 24 : 0, 24),
new WeightedModifierType(modifierTypes.MINI_BLACK_HOLE, (party: Pokemon[]) => (party[0].scene.gameMode.isDaily || (!party[0].scene.gameMode.isFreshStartChallenge() && isUnlocked(Unlockables.MINI_BLACK_HOLE, party[0].scene.gameData))) ? 1 : 0, 1),
new WeightedModifierType(modifierTypes.MINI_BLACK_HOLE, (party: Pokemon[]) => (party[0].scene.gameMode.isDaily || (!party[0].scene.gameMode.isFreshStartChallenge() && party[0].scene.gameData.isUnlocked(Unlockables.MINI_BLACK_HOLE))) ? 1 : 0, 1),
].map(m => {
m.setTier(ModifierTier.MASTER); return m;
})

View File

@ -72,8 +72,6 @@ class DefaultOverrides {
};
/** Forces an item to be UNLOCKED */
readonly UNLOCK_OVERRIDE: Unlockables[] = [];
/** Forces an item to be NOT UNLOCKED */
readonly DISABLE_UNLOCK_OVERRIDE: Unlockables[] = [];
// ----------------
// PLAYER OVERRIDES

View File

@ -8,7 +8,7 @@ import { GameModes, GameMode, getGameMode } from "#app/game-mode.js";
import { regenerateModifierPoolThresholds, ModifierPoolType, modifierTypes, getDailyRunStarterModifiers } from "#app/modifier/modifier-type.js";
import { Phase } from "#app/phase.js";
import { SessionSaveData } from "#app/system/game-data.js";
import { isUnlocked, Unlockables } from "#app/system/unlockables.js";
import { Unlockables } from "#app/system/unlockables.js";
import { vouchers } from "#app/system/voucher.js";
import { OptionSelectItem, OptionSelectConfig } from "#app/ui/abstact-option-select-ui-handler.js";
import { SaveSlotUiMode } from "#app/ui/save-slot-select-ui-handler.js";
@ -76,7 +76,7 @@ export class TitlePhase extends Phase {
this.scene.ui.clearText();
this.end();
};
if (isUnlocked(Unlockables.ENDLESS_MODE, this.scene.gameData)) {
if (this.scene.gameData.isUnlocked(Unlockables.ENDLESS_MODE)) {
const options: OptionSelectItem[] = [
{
label: GameMode.getModeName(GameModes.CLASSIC),
@ -100,7 +100,7 @@ export class TitlePhase extends Phase {
}
}
];
if (isUnlocked(Unlockables.SPLICED_ENDLESS_MODE, this.scene.gameData)) {
if (this.scene.gameData.isUnlocked(Unlockables.SPLICED_ENDLESS_MODE)) {
options.push({
label: GameMode.getModeName(GameModes.SPLICED_ENDLESS),
handler: () => {

View File

@ -364,6 +364,12 @@ export class GameData {
unlockPity: this.unlockPity.slice(0)
};
}
public isUnlocked(unlockable: Unlockables): boolean {
if (Overrides.UNLOCK_OVERRIDE.includes(unlockable)) {
return true;
}
return this.unlocks[unlockable];
}
public saveSystem(): Promise<boolean> {
return new Promise<boolean>(resolve => {

View File

@ -1,7 +1,5 @@
import i18next from "i18next";
import { GameMode, GameModes } from "../game-mode";
import Overrides from "#app/overrides";
import { GameData } from "./game-data";
export enum Unlockables {
ENDLESS_MODE,
@ -10,16 +8,6 @@ export enum Unlockables {
EVIOLITE
}
export function isUnlocked(unlockable: Unlockables, gameData: GameData): boolean {
if (Overrides.UNLOCK_OVERRIDE.includes(unlockable)) {
return true;
}
if (Overrides.DISABLE_UNLOCK_OVERRIDE.includes(unlockable)) {
return false;
}
return gameData.unlocks[unlockable];
}
export function getUnlockableName(unlockable: Unlockables) {
switch (unlockable) {
case Unlockables.ENDLESS_MODE:

View File

@ -4,8 +4,8 @@ import { MapModifier } from "#app/modifier/modifier.js";
import { SelectModifierPhase } from "../phases/select-modifier-phase";
import { Moves } from "#app/enums/moves.js";
import { Abilities } from "#app/enums/abilities.js";
import { Unlockables } from "#app/system/unlockables.js";
import { poolHasEviolite, poolHasBlackHole } from "#app/modifier/modifier-type.js";
import { TitlePhase } from "#app/phases/title-phase.js";
describe("Daily Mode", () => {
let phaserGame: Phaser.Game;
@ -45,14 +45,15 @@ describe("Daily Mode", () => {
.battleType("single")
.startingLevel(200)
.moveset([Moves.SURF])
.enemyAbility(Abilities.BALL_FETCH)
.startingModifier([{ name: "LOCK_CAPSULE" }])
.lockUnlockable([Unlockables.MINI_BLACK_HOLE, Unlockables.EVIOLITE]);
.enemyAbility(Abilities.BALL_FETCH);
});
afterEach(() => {
game.phaseInterceptor.restoreOg();
});
it("should only allow Mini Black Hole and Eviolite outside of Daily if unlocked", async () => {
const titlePhase = new TitlePhase(game.scene);
game.scene.unshiftPhase(titlePhase);
await game.phaseInterceptor.run(TitlePhase);
await game.classicMode.runToSummon();
await game.startBattle();
@ -62,6 +63,9 @@ describe("Daily Mode", () => {
expect(poolHasBlackHole).toBeFalsy();
});
it("should allow Eviolite and Mini Black Hole in shop when in Daily Run", async () => {
const titlePhase = new TitlePhase(game.scene);
game.scene.unshiftPhase(titlePhase);
await game.phaseInterceptor.run(TitlePhase);
await game.dailyMode.runToSummon();
await game.startBattle();

View File

@ -288,12 +288,6 @@ export class OverridesHelper extends GameManagerHelper {
return this;
}
lockUnlockable(unlockable: Unlockables[]) {
vi.spyOn(Overrides, "DISABLE_UNLOCK_OVERRIDE", "get").mockReturnValue(unlockable);
this.log("Temporarily re-locked the following content: ", unlockable);
return this;
}
private log(...params: any[]) {
console.log("Overrides:", ...params);
}