From 63b5195b14f19f51ed5f9e7a4be3b55af82b9486 Mon Sep 17 00:00:00 2001 From: Tempoanon <163687446+Tempo-anon@users.noreply.github.com> Date: Mon, 12 Aug 2024 01:34:53 -0400 Subject: [PATCH] [Bug] Some fresh start fixes (#3420) * Fix some fresh start bugs * Forgot a ! * Add fresh start check on eviolite too * Remove part about cost being 3 * Update src/game-mode.ts Co-authored-by: flx-sta <50131232+flx-sta@users.noreply.github.com> * Rename isFreshStart helper function --------- Co-authored-by: flx-sta <50131232+flx-sta@users.noreply.github.com> --- src/data/challenge.ts | 4 ++-- src/game-mode.ts | 18 ++++++++++++++++++ src/modifier/modifier-type.ts | 4 ++-- src/phases.ts | 2 +- 4 files changed, 23 insertions(+), 5 deletions(-) diff --git a/src/data/challenge.ts b/src/data/challenge.ts index 18cc58ddaf1..0df496c2ea4 100644 --- a/src/data/challenge.ts +++ b/src/data/challenge.ts @@ -630,8 +630,8 @@ export class FreshStartChallenge extends Challenge { } applyStarterCost(species: Species, cost: Utils.NumberHolder): boolean { - if (defaultStarterSpecies.includes(species) && cost.value !== 3) { - cost.value = 3; + if (defaultStarterSpecies.includes(species)) { + cost.value = speciesStarters[species]; return true; } return false; diff --git a/src/game-mode.ts b/src/game-mode.ts index 2475cb5cfb4..e78b9017c12 100644 --- a/src/game-mode.ts +++ b/src/game-mode.ts @@ -8,6 +8,7 @@ import Overrides from "#app/overrides"; import * as Utils from "./utils"; import { Biome } from "#enums/biome"; import { Species } from "#enums/species"; +import { Challenges } from "./enums/challenges"; export enum GameModes { CLASSIC, @@ -55,6 +56,23 @@ export class GameMode implements GameModeConfig { this.battleConfig = battleConfig || {}; } + /** + * Helper function to see if a GameMode has a specific challenge type + * @param challenge the Challenges it looks for + * @returns true if the game mode has that challenge + */ + hasChallenge(challenge: Challenges): boolean { + return this.challenges.some(c => c.id === challenge); + } + + /** + * Helper function to see if the game mode is using fresh start + * @returns true if a fresh start challenge is being applied + */ + isFreshStartChallenge(): boolean { + return this.hasChallenge(Challenges.FRESH_START); + } + /** * @returns either: * - override from overrides.ts diff --git a/src/modifier/modifier-type.ts b/src/modifier/modifier-type.ts index 330132b55fc..942ef4e1bfc 100644 --- a/src/modifier/modifier-type.ts +++ b/src/modifier/modifier-type.ts @@ -1545,7 +1545,7 @@ const modifierPool: ModifierPool = { new WeightedModifierType(modifierTypes.RARE_EVOLUTION_ITEM, (party: Pokemon[]) => Math.min(Math.ceil(party[0].scene.currentBattle.waveIndex / 15) * 4, 32), 32), new WeightedModifierType(modifierTypes.AMULET_COIN, skipInLastClassicWaveOrDefault(3)), new WeightedModifierType(modifierTypes.EVIOLITE, (party: Pokemon[]) => { - if (party[0].scene.gameData.unlocks[Unlockables.EVIOLITE]) { + if (!party[0].scene.gameMode.isFreshStartChallenge() && party[0].scene.gameData.unlocks[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; @@ -1623,7 +1623,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.gameData.unlocks[Unlockables.MINI_BLACK_HOLE] ? 1 : 0, 1), + new WeightedModifierType(modifierTypes.MINI_BLACK_HOLE, (party: Pokemon[]) => (!party[0].scene.gameMode.isFreshStartChallenge() && party[0].scene.gameData.unlocks[Unlockables.MINI_BLACK_HOLE]) ? 1 : 0, 1), ].map(m => { m.setTier(ModifierTier.MASTER); return m; }) diff --git a/src/phases.ts b/src/phases.ts index fcd3cfb8801..73413b248a4 100644 --- a/src/phases.ts +++ b/src/phases.ts @@ -2031,7 +2031,7 @@ export class CommandPhase extends FieldPhase { } break; case Command.BALL: - if (this.scene.arena.biomeType === Biome.END && (!this.scene.gameMode.isClassic || (this.scene.getEnemyField().filter(p => p.isActive(true)).some(p => !p.scene.gameData.dexData[p.species.speciesId].caughtAttr) && this.scene.gameData.getStarterCount(d => !!d.caughtAttr) < Object.keys(speciesStarters).length - 1))) { + if (!this.scene.gameMode.isFreshStartChallenge() && this.scene.arena.biomeType === Biome.END && (!this.scene.gameMode.isClassic || (this.scene.getEnemyField().filter(p => p.isActive(true)).some(p => !p.scene.gameData.dexData[p.species.speciesId].caughtAttr) && this.scene.gameData.getStarterCount(d => !!d.caughtAttr) < Object.keys(speciesStarters).length - 1))) { this.scene.ui.setMode(Mode.COMMAND, this.fieldIndex); this.scene.ui.setMode(Mode.MESSAGE); this.scene.ui.showText(i18next.t("battle:noPokeballForce"), null, () => {