Merge pull request #8 from emdeann/inverse-daily

Add inverse challenge to daily run for event
This commit is contained in:
damocleas 2025-03-31 02:43:42 -04:00 committed by GitHub
commit cacd025e3e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 38 additions and 0 deletions

View File

@ -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

View File

@ -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);

View File

@ -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 {