generated from nhcarrigan/template
feat: add lifetime stats to player profile
Introduce six lifetime stat fields (gold, clicks, bosses, quests, adventurers, achievements) that accumulate across all prestige and transcendence resets and are never cleared. - schema: add six new Float fields to the Player model - prestige route: capture current-run totals and increment lifetime fields before resetting per-run counters to zero - profile route: return lifetime fields as the All Time section data; add four new ProfileSettings toggles for visibility control - ProfilePage: display lifetime bosses/quests/adventurers/achievements in All Time section; remove GameProvider dependency by importing formatNumber directly (fixes crash on public profile pages) - EditProfileModal: add four new All Time stat toggles - types: update Player, ProfileSettings, and PublicProfileResponse
This commit is contained in:
@@ -22,8 +22,14 @@ const parseProfileSettings = (raw: unknown): ProfileSettings => {
|
||||
return {
|
||||
showTotalGold: obj.showTotalGold !== false,
|
||||
showTotalClicks: obj.showTotalClicks !== false,
|
||||
showPrestige: obj.showPrestige !== false,
|
||||
showLifetimeBossesDefeated: obj.showLifetimeBossesDefeated !== false,
|
||||
showLifetimeQuestsCompleted: obj.showLifetimeQuestsCompleted !== false,
|
||||
showLifetimeAdventurersRecruited: obj.showLifetimeAdventurersRecruited !== false,
|
||||
showLifetimeAchievementsUnlocked: obj.showLifetimeAchievementsUnlocked !== false,
|
||||
showGuildFounded: obj.showGuildFounded !== false,
|
||||
showCurrentGold: obj.showCurrentGold !== false,
|
||||
showCurrentClicks: obj.showCurrentClicks !== false,
|
||||
showPrestige: obj.showPrestige !== false,
|
||||
showBossesDefeated: obj.showBossesDefeated !== false,
|
||||
showQuestsCompleted: obj.showQuestsCompleted !== false,
|
||||
showAdventurersRecruited: obj.showAdventurersRecruited !== false,
|
||||
@@ -63,14 +69,22 @@ profileRouter.get("/:discordId", async (context) => {
|
||||
avatar: player.avatar ?? null,
|
||||
bio: player.bio ?? "",
|
||||
profileSettings,
|
||||
createdAt: player.createdAt,
|
||||
// All Time stats — cumulative across all runs, never reset
|
||||
totalGoldEarned: player.lifetimeGoldEarned,
|
||||
totalClicks: player.lifetimeClicks,
|
||||
lifetimeBossesDefeated: player.lifetimeBossesDefeated,
|
||||
lifetimeQuestsCompleted: player.lifetimeQuestsCompleted,
|
||||
lifetimeAdventurersRecruited: player.lifetimeAdventurersRecruited,
|
||||
lifetimeAchievementsUnlocked: player.lifetimeAchievementsUnlocked,
|
||||
// Current Run stats — from live GameState, reset on prestige & transcendence
|
||||
currentRunGold: state?.player.totalGoldEarned ?? 0,
|
||||
currentRunClicks: state?.player.totalClicks ?? 0,
|
||||
prestigeCount,
|
||||
totalGoldEarned: player.totalGoldEarned,
|
||||
totalClicks: player.totalClicks,
|
||||
bossesDefeated,
|
||||
questsCompleted,
|
||||
adventurersRecruited,
|
||||
achievementsUnlocked,
|
||||
createdAt: player.createdAt,
|
||||
});
|
||||
});
|
||||
|
||||
@@ -86,8 +100,14 @@ profileRouter.put("/", authMiddleware, async (context) => {
|
||||
const profileSettings: ProfileSettings = {
|
||||
showTotalGold: body.profileSettings?.showTotalGold !== false,
|
||||
showTotalClicks: body.profileSettings?.showTotalClicks !== false,
|
||||
showPrestige: body.profileSettings?.showPrestige !== false,
|
||||
showLifetimeBossesDefeated: body.profileSettings?.showLifetimeBossesDefeated !== false,
|
||||
showLifetimeQuestsCompleted: body.profileSettings?.showLifetimeQuestsCompleted !== false,
|
||||
showLifetimeAdventurersRecruited: body.profileSettings?.showLifetimeAdventurersRecruited !== false,
|
||||
showLifetimeAchievementsUnlocked: body.profileSettings?.showLifetimeAchievementsUnlocked !== false,
|
||||
showGuildFounded: body.profileSettings?.showGuildFounded !== false,
|
||||
showCurrentGold: body.profileSettings?.showCurrentGold !== false,
|
||||
showCurrentClicks: body.profileSettings?.showCurrentClicks !== false,
|
||||
showPrestige: body.profileSettings?.showPrestige !== false,
|
||||
showBossesDefeated: body.profileSettings?.showBossesDefeated !== false,
|
||||
showQuestsCompleted: body.profileSettings?.showQuestsCompleted !== false,
|
||||
showAdventurersRecruited: body.profileSettings?.showAdventurersRecruited !== false,
|
||||
|
||||
Reference in New Issue
Block a user