Let the restart action undo a death #345
No reviewers
Labels
No labels
4-29
bug
documentation
duplicate
enhancement
flow improvement
good first issue
help wanted
invalid
investigating
issue-agent
issue-agent-blocked
issue-agent-complete
issue-agent-pr-open
issue-agent-runner-nelsonlaptop
issue-agent-runner-nelsonpc
issue-agent-runner-nelsonpc-user
issue-agent-running
needs-verification
next to do
question
queue
recon
relics-stats-onboarding
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
romaine-life/spirelens!345
Loading…
Reference in a new issue
No description provided.
Delete branch "claude/undo-death-restart"
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?
The gap
Dying is the one room ending that destroys what the restart action replays.
RunManager.OnEnded(isVictory: false)— called synchronously fromCreatureCmd.Killonce every player is dead — runsDeleteCurrentRun(), soRoomResetter.Describe()found no run save and the row could only say therestart was unavailable. A death from carelessness while multitasking had no
recovery, even though the save it needed existed moments earlier.
The same call records the loss everywhere the game keeps score, which is why
putting the save back is not enough on its own:
UpdateProgressWithRunData—TotalLosses++,CurrentWinStreak = 0,playtime, floors climbed, per-card
TimesLost, per-encounter and per-enemylosses;
CreateRunHistoryEntry— writeshistory/{StartTime}.run(SpireLens'RunTracker.OnRunEndedhangs off this as a postfix, stampingoutcome=loss);Progress.CurrentScoreand may
ObtainEpocha score unlock.Restoring only the run save would leave a loss counted, a streak broken and a
history entry for a death that no longer happened — a recorded outcome that
never occurred.
The fix
RunManagerOnEndedDeathRestorePatch, a prefix onRunManager.OnEnded,so it is ahead of all of the above.
RoomResetter.CaptureDeathRestorePointkeeps
current_run.save(still the room's opening state),Progress.ToSerializable(), and the run id whose rewind snapshot matches, inuser://SpireLens/death-restore.json. Singleplayer, non-abandoned, once perrun, and skipped when there is no rewind snapshot to restore the record from —
refusing beats half-undoing.
Describe()offers the restart while the run is over (IsGameOver, thegame-over screen) or absent (the main menu), reading the kept point. The row
names the room and where the replay lands, as it already does live.
progress.save, deletes{StartTime}.run, and calls the newRunTracker.RollBackEndedRunToLastRunSave, which reloads the rewind snapshotfrom disk (
OnRunEndedclears the statics but leaves the file) and un-endsthe record. Then the ordinary Continue path runs and writes the run save back.
history entry appears: restoring it then would roll progress back over runs
played since. Profile-scoped.
Not reversible, and documented as such: the run metrics already uploaded and
any Steam achievement unlocked on the way out.
Notes
docs/sts2-runtime-primer.mdgains a "Death Deletes The Save" section underthe run-save write points.
RunData, so noFixtures/RunSchemafixture isneeded; the restore point is its own transient file.
verification was run.