feat: add daily challenges system

Three PST-midnight-resetting challenges generated deterministically per
day from click, boss, quest, and prestige types. Progress tracked
server-side for bosses and prestige, client-side for clicks and quests.
Crystal rewards awarded on completion and preserved through prestige resets.
This commit is contained in:
2026-03-06 22:22:18 -08:00
committed by Naomi Carrigan
parent a7d4b72805
commit aaeece1a18
15 changed files with 462 additions and 8 deletions
+32
View File
@@ -0,0 +1,32 @@
import type { DailyChallengeState, DailyChallengeType } from "@elysium/types";
/**
* Increments progress for daily challenges matching the given type.
* Returns the updated challenge state and any crystals awarded for newly-completed challenges.
*
* Note: challenge generation and daily resets are handled server-side only.
* This utility is purely for client-side progress tracking.
*/
export const updateChallengeProgress = (
challengeState: DailyChallengeState,
type: DailyChallengeType,
amount: number,
): { updatedChallenges: DailyChallengeState; crystalsAwarded: number } => {
let crystalsAwarded = 0;
const updatedChallenges: DailyChallengeState = {
...challengeState,
challenges: challengeState.challenges.map((challenge) => {
if (challenge.type !== type || challenge.completed) return challenge;
const newProgress = Math.min(challenge.progress + amount, challenge.target);
const nowCompleted = newProgress >= challenge.target;
if (nowCompleted) crystalsAwarded += challenge.rewardCrystals;
return { ...challenge, progress: newProgress, completed: nowCompleted };
}),
};
return { updatedChallenges, crystalsAwarded };
};