mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[PR #1644] [MERGED] Normalize legacy activeQuests shapes in one shared quest-merge helper #5176
Labels
No labels
android
bug
bugfix
ci
client
code freeze pause
container
dependencies
docs
documentation
duplicate
enhancement
feature
feature
feature
feature-creep
fixed-in-refactor
fixed-in-staging
good first issue
help wanted
in-pr
in-pr
needs-codeowner-decision
normal-scope
old-codebase
old-codebase
pull-request
qol
question
refactor
regression
revisit later
roadmap
scope-risk
scope-risk
server
server
shared
soup
upstream
windows
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Pasta-Devs/Marinara-Engine#5176
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/1644
Author: @Romuromylus
Created: 5/30/2026
Status: ✅ Merged
Merged: 5/30/2026
Merged by: @Romuromylus
Base:
refactor← Head:fix/quest-merge-normalize📝 Commits (4)
ee061deNormalize legacy activeQuests shapes in one shared quest-merge helpercfbb107Make quest-collection normalization lossless for nested/keyed shapes7232c9dFormat quest-merge files to repository Prettier styled96d332Don't promote a non-quest keyed record to a phantom quest📊 Changes
4 files changed (+551 additions, -268 deletions)
View changed files
📝
src/engine/generation/tracker-snapshots.ts(+7 -233)➕
src/engine/shared/game-state/player-stats.test.ts(+240 -0)➕
src/engine/shared/game-state/player-stats.ts(+297 -0)📝
src/features/runtime/generation/hooks/use-generate.ts(+7 -35)📄 Description
Why this change
Two quest-merge code paths existed and neither restored the pre-rewrite tolerance for non-array
activeQuestsshapes (keyed quest maps, grouped containers, nested collections):tracker-snapshots.ts) normalized objectives and auto-removed completed quests, butclonePlayerStatsdropped any keyed/groupedactiveQueststo[].use-generate.ts applyQuestUpdates) was an entirely separate, simpler merge: it matched quests bynameonly, passed objectives through raw, did no completed-removal, and also dropped non-array shapes.So legacy/imported saves silently lost quests, and the optimistic and persisted merges diverged.
What changed
src/engine/shared/game-state/player-stats.ts(mode-neutral deterministic helper) owns player-stats normalization, including the newnormalizeActiveQuestCollection: handles plain arrays, keyed quest maps ({ questId: quest }), grouped/wrapper containers ({ quests | groups | items | activeQuests | children: [...] }), and nested collections, depth-guarded.tracker-snapshots.tsand the UI Quest Board path now both call the sameapplyQuestUpdatesToPlayerStats, so optimistic and persisted merges are byte-identical (match byquestEntryIdthenname, normalized objectives, completed-empty-objective removal).parseStat/parseInventoryItem/parseCustomTrackerField/clonePlayerStats/…) that had been duplicated across the two files. Dependency direction stays one-way (tracker-snapshots → player-stats,use-generate → player-stats); no import cycle.Verification
pnpm checkpasses (architecture + frontend tsc + cargo check + docs).player-stats.test.ts(12 tests) covers keyed maps, grouped containers, object- and nested-shaped objectives, completed-empty-objective removal, create/update/fail matching by id and name, and the changed-flag semantics.src/engine/generation,src/engine/shared, 229 tests) green.Risk / behavior note
The UI optimistic path now matches by
questEntryId | name(was name-only) and auto-removes completed-empty quests, matching the persisted path. This is the intended parity but is a visible delta: a completed quest that the optimistic UI previously kept on screen until the next storage refresh now disappears immediately. Worth a quick look inpnpm tauri devagainst a real imported save before merge.Linked issue
Closes #1530.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.