aboutsummaryrefslogtreecommitdiff
path: root/internal/game/lifecycle.go
diff options
context:
space:
mode:
authorhistoria <[not public]>2026-09-19 03:15:59 -0400
committerhistoria <[not public]>2026-09-19 03:15:59 -0400
commit0e60567a7a0addb9421769ee7be7853bfa8788cb (patch)
tree7645112db0e4eae95b8a83c1e4f9aab38bede655 /internal/game/lifecycle.go
parentcc33072eced3d5460512c09c42ec4531c807d7af (diff)
downloadthehouseoficarus-0e60567a7a0addb9421769ee7be7853bfa8788cb.tar.gz
refactor: simplifcation, change how rooms are stored in player yaml, remove legacy code
Diffstat (limited to 'internal/game/lifecycle.go')
-rw-r--r--internal/game/lifecycle.go31
1 files changed, 31 insertions, 0 deletions
diff --git a/internal/game/lifecycle.go b/internal/game/lifecycle.go
new file mode 100644
index 0000000..b39c805
--- /dev/null
+++ b/internal/game/lifecycle.go
@@ -0,0 +1,31 @@
+package game
+
+import (
+ "thehouseoficarus/internal/net"
+ "thehouseoficarus/internal/player"
+)
+
+// releaseCharacterRuntime tears down a character's live world presence when it
+// leaves the world, whether through the quit countdown final tick or a hard
+// disconnect. Keeping it in one place is what stops a per-player system from
+// being cleaned up on one exit path and forgotten on another: the quit path
+// used to leave a player occupying a safespot cover and holding a stale action.
+//
+// It deliberately does NOT detach the session registry, touch trigger
+// sequences, persist the character, or resolve casino wagers. Callers own
+// those because their ordering differs: disconnect must snapshot locked
+// sequences (persistLockedOnDisconnect) before sequences are dropped, and
+// resolves casino wagers through its deferral/refund path, while quit forfeits
+// a mid-round stake immediately before saving.
+func (g *Game) releaseCharacterRuntime(sess *net.Session, p *player.Player) {
+ if p == nil {
+ return
+ }
+ g.stopCombat(p.Name)
+ g.cancelRest(p.Name)
+ g.cancelAction(p)
+ if ss, ok := g.safespot.Get(p.Name); ok {
+ g.forceLeaveSafespot(sess, p, &ss, "")
+ }
+ delete(g.hackingStates, p.Name)
+}