diff --git a/src/game-mode.ts b/src/game-mode.ts index 9ab1674bcce..bc1af035d40 100644 --- a/src/game-mode.ts +++ b/src/game-mode.ts @@ -68,6 +68,19 @@ export class GameMode implements GameModeConfig { this.battleConfig = battleConfig || {}; } + /** + * Enables challenges if they are disabled and sets the specified challenge's value + * @param challenge The challenge to set + * @param value The value to give the challenge. Impact depends on the specific challenge + */ + setChallengeValue(challenge: Challenges, value: number) { + if (!this.isChallenge) { + this.isChallenge = true; + this.challenges = allChallenges.map(c => copyChallenge(c)); + } + this.challenges.filter((chal: Challenge) => chal.id === challenge).map((chal: Challenge) => (chal.value = value)); + } + /** * Helper function to see if a GameMode has a specific challenge type * @param challenge the Challenges it looks for diff --git a/src/phases/title-phase.ts b/src/phases/title-phase.ts index 5b69f8db45c..dc455a0a62a 100644 --- a/src/phases/title-phase.ts +++ b/src/phases/title-phase.ts @@ -212,6 +212,8 @@ export class TitlePhase extends Phase { const generateDaily = (seed: string) => { globalScene.gameMode = getGameMode(GameModes.DAILY); + // Daily runs don't support all challenges yet (starter select restrictions aren't considered) + globalScene.eventManager.startEventChallenges(); globalScene.setSeed(seed); globalScene.resetSeed(0); diff --git a/src/timed-event-manager.ts b/src/timed-event-manager.ts index e6e62d400bd..70afa009da9 100644 --- a/src/timed-event-manager.ts +++ b/src/timed-event-manager.ts @@ -9,6 +9,7 @@ import { WeatherType } from "#enums/weather-type"; import { CLASSIC_CANDY_FRIENDSHIP_MULTIPLIER } from "./data/balance/starters"; import { MysteryEncounterType } from "./enums/mystery-encounter-type"; import { MysteryEncounterTier } from "./enums/mystery-encounter-tier"; +import { Challenges } from "#enums/challenges"; export enum EventType { SHINY, @@ -43,6 +44,11 @@ interface EventWaveReward { type EventMusicReplacement = [string, string]; +interface EventChallenge { + challenge: Challenges; + value: number; +} + interface TimedEvent extends EventBanner { name: string; eventType: EventType; @@ -61,6 +67,7 @@ interface TimedEvent extends EventBanner { classicWaveRewards?: EventWaveReward[]; // Rival battle rewards trainerShinyChance?: number; // Odds over 65536 of trainer mon generating as shiny music?: EventMusicReplacement[]; + dailyRunChallenges?: EventChallenge[]; } const timedEvents: TimedEvent[] = [ @@ -296,6 +303,12 @@ const timedEvents: TimedEvent[] = [ ["title", "title_afd"], ["battle_rival_3", "battle_rival_3_afd"], ], + dailyRunChallenges: [ + { + challenge: Challenges.INVERSE_BATTLE, + value: 1, + }, + ], }, ]; @@ -510,6 +523,16 @@ export class TimedEventManager { }); return ret; } + + /** + * Activates any challenges on {@linkcode globalScene.gameMode} for the currently active event + */ + startEventChallenges(): void { + const challenges = this.activeEvent()?.dailyRunChallenges; + challenges?.forEach((eventChal: EventChallenge) => + globalScene.gameMode.setChallengeValue(eventChal.challenge, eventChal.value), + ); + } } export class TimedEventDisplay extends Phaser.GameObjects.Container {