From bcb523f5985e8abe85522fd6590d06c40343520b Mon Sep 17 00:00:00 2001 From: Hikari Date: Sat, 7 Mar 2026 15:37:07 -0800 Subject: [PATCH] fix: update dailyChallenges client state on boss defeat --- apps/web/src/context/GameContext.tsx | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/apps/web/src/context/GameContext.tsx b/apps/web/src/context/GameContext.tsx index 95054bc..b7714d6 100644 --- a/apps/web/src/context/GameContext.tsx +++ b/apps/web/src/context/GameContext.tsx @@ -23,6 +23,10 @@ const applyBossResult = (prev: GameState, bossId: string, result: BossChallengeR return firstBoss?.id; }).filter(Boolean); + const challengeUpdate = prev.dailyChallenges + ? updateChallengeProgress(prev.dailyChallenges, "bossesDefeated", 1) + : { updatedChallenges: undefined, crystalsAwarded: 0 }; + return { ...prev, bosses: prev.bosses.map((b) => { @@ -42,14 +46,20 @@ const applyBossResult = (prev: GameState, bossId: string, result: BossChallengeR prev.quests.some((q) => q.id === z.unlockQuestId && q.status === "completed"); return questOk ? { ...z, status: "unlocked" as const } : z; }), + ...(challengeUpdate.updatedChallenges !== undefined + ? { dailyChallenges: challengeUpdate.updatedChallenges } + : {}), resources: result.rewards ? { ...prev.resources, gold: prev.resources.gold + result.rewards.gold, essence: prev.resources.essence + result.rewards.essence, - crystals: prev.resources.crystals + result.rewards.crystals, + crystals: prev.resources.crystals + result.rewards.crystals + challengeUpdate.crystalsAwarded, } - : prev.resources, + : { + ...prev.resources, + crystals: prev.resources.crystals + challengeUpdate.crystalsAwarded, + }, prestige: result.rewards?.bountyRunestones ? { ...prev.prestige, runestones: prev.prestige.runestones + result.rewards.bountyRunestones } : prev.prestige,