Merge pull request #8 from emdeann/inverse-daily
Add inverse challenge to daily run for event
This commit is contained in:
commit
cacd025e3e
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Reference in New Issue