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;
|
return firstBoss?.id;
|
||||||
}).filter(Boolean);
|
}).filter(Boolean);
|
||||||
|
|
||||||
|
const challengeUpdate = prev.dailyChallenges
|
||||||
|
? updateChallengeProgress(prev.dailyChallenges, "bossesDefeated", 1)
|
||||||
|
: { updatedChallenges: undefined, crystalsAwarded: 0 };
|
||||||
|
|
||||||
return {
|
return {
|
||||||
...prev,
|
...prev,
|
||||||
bosses: prev.bosses.map((b) => {
|
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");
|
prev.quests.some((q) => q.id === z.unlockQuestId && q.status === "completed");
|
||||||
return questOk ? { ...z, status: "unlocked" as const } : z;
|
return questOk ? { ...z, status: "unlocked" as const } : z;
|
||||||
}),
|
}),
|
||||||
|
...(challengeUpdate.updatedChallenges !== undefined
|
||||||
|
? { dailyChallenges: challengeUpdate.updatedChallenges }
|
||||||
|
: {}),
|
||||||
resources: result.rewards
|
resources: result.rewards
|
||||||
? {
|
? {
|
||||||
...prev.resources,
|
...prev.resources,
|
||||||
gold: prev.resources.gold + result.rewards.gold,
|
gold: prev.resources.gold + result.rewards.gold,
|
||||||
essence: prev.resources.essence + result.rewards.essence,
|
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
|
prestige: result.rewards?.bountyRunestones
|
||||||
? { ...prev.prestige, runestones: prev.prestige.runestones + result.rewards.bountyRunestones }
|
? { ...prev.prestige, runestones: prev.prestige.runestones + result.rewards.bountyRunestones }
|
||||||
: prev.prestige,
|
: prev.prestige,
|
||||||
|
|||||||
Reference in New Issue
Block a user