generated from nhcarrigan/template
fix: update dailyChallenges client state on boss defeat
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user