fix: preserve all-time stats, achievements, and boss first-kill across prestige #47

Merged
naomi merged 3 commits from fix/prestige-resets into main 2026-03-09 21:53:59 -07:00
Owner

Resolves #37, resolves #38, and resolves #39 — three related bugs where prestige incorrectly reset data that should survive all prestige resets.

Changes

fix: preserve lifetime player stats across prestige (#37)

After prestige, GameState.player.lifetime* fields were stale — they reflected values from before the current run. The Prisma Player record was incremented correctly, but the GameState JSON saved to the DB had old values, so the UI showed wrong all-time totals on reload.

buildPostPrestigeState now computes the run-stat contributions (bosses defeated, quests completed, adventurers recruited, achievements unlocked, gold earned, clicks) and folds them into the fresh player object before writing the prestige state.

fix: preserve achievements across prestige (#38)

buildPostPrestigeState was reconstructing achievements from defaultAchievements (via initialGameState), resetting all unlocked achievements on every prestige. Achievements are now carried forward from currentState.achievements instead.

fix: preserve boss first-kill state across prestige (#39)

Added bountyRunestonesClaimed?: boolean to the Boss type. The boss challenge route now:

  • Only awards the first-kill bounty runestones if bountyRunestonesClaimed !== true
  • Sets bountyRunestonesClaimed = true on first defeat

buildPostPrestigeState maps the fresh boss list and carries the bountyRunestonesClaimed flag forward from the current state, so the bounty is never re-awarded in subsequent prestige runs. The boss panel badge is also hidden for bosses whose bounty is already claimed.

Test Coverage

All three fixes include new tests covering the new behaviours. API coverage remains at 100%.

This PR was created with help from Hikari~ 🌸

Resolves #37, resolves #38, and resolves #39 — three related bugs where prestige incorrectly reset data that should survive all prestige resets. ## Changes ### fix: preserve lifetime player stats across prestige (#37) After prestige, `GameState.player.lifetime*` fields were stale — they reflected values from *before* the current run. The Prisma Player record was incremented correctly, but the GameState JSON saved to the DB had old values, so the UI showed wrong all-time totals on reload. `buildPostPrestigeState` now computes the run-stat contributions (bosses defeated, quests completed, adventurers recruited, achievements unlocked, gold earned, clicks) and folds them into the fresh player object before writing the prestige state. ### fix: preserve achievements across prestige (#38) `buildPostPrestigeState` was reconstructing achievements from `defaultAchievements` (via `initialGameState`), resetting all unlocked achievements on every prestige. Achievements are now carried forward from `currentState.achievements` instead. ### fix: preserve boss first-kill state across prestige (#39) Added `bountyRunestonesClaimed?: boolean` to the `Boss` type. The boss challenge route now: - Only awards the first-kill bounty runestones if `bountyRunestonesClaimed !== true` - Sets `bountyRunestonesClaimed = true` on first defeat `buildPostPrestigeState` maps the fresh boss list and carries the `bountyRunestonesClaimed` flag forward from the current state, so the bounty is never re-awarded in subsequent prestige runs. The boss panel badge is also hidden for bosses whose bounty is already claimed. ## Test Coverage All three fixes include new tests covering the new behaviours. API coverage remains at 100%. ✨ This PR was created with help from Hikari~ 🌸
hikari added 3 commits 2026-03-09 21:35:26 -07:00
Fixes #37. After prestige, the GameState's player.lifetime* fields were
stale — they did not include the current run's contributions. The Prisma
Player record was updated correctly, but the saved GameState had old values,
so the UI showed stale all-time totals on reload.

buildPostPrestigeState now computes run-stat contributions and folds them
into the fresh player object before writing the prestige state, ensuring
the GameState is always consistent with the DB Player record.
Fixes #38. buildPostPrestigeState was using structuredClone(defaultAchievements)
via the freshState, which reset all achievements on every prestige. Achievements
are now carried forward from currentState.achievements instead, ensuring unlocked
achievements are never lost across prestige resets.
fix: preserve boss first-kill state across prestige
CI / Lint, Build & Test (pull_request) Successful in 1m10s
Security Scan and Upload / Security & DefectDojo Upload (pull_request) Successful in 1m11s
35e4d71d98
Fixes #39. Added bountyRunestonesClaimed?: boolean to the Boss type.
The first-kill bounty runestones are now only awarded once across all
prestige resets — the boss route checks the flag before awarding, sets
it on first defeat, and buildPostPrestigeState carries the flag forward
through fresh boss state on prestige. The boss panel badge no longer
shows for bosses whose bounty has already been claimed.
naomi merged commit d0790890ee into main 2026-03-09 21:53:59 -07:00
naomi deleted branch fix/prestige-resets 2026-03-09 21:53:59 -07:00
Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: nhcarrigan/elysium#47