aboutsummaryrefslogtreecommitdiff
path: root/internal/game/session_registry.go
diff options
context:
space:
mode:
authorhistoria <[not public]>2026-09-15 15:35:52 -0400
committerhistoria <[not public]>2026-09-15 15:35:52 -0400
commit0b0b25222b3131ada79ff78c28eb8bf07d977deb (patch)
tree2ceaef5203595044f66a8f00064cd8e017f8f48d /internal/game/session_registry.go
parent396c3facb8287b9a34076cae8f3d7b300d366d99 (diff)
downloadthehouseoficarus-0b0b25222b3131ada79ff78c28eb8bf07d977deb.tar.gz
feat: single-owner game state, transactional lifecycle, durable money on server stop
Diffstat (limited to 'internal/game/session_registry.go')
-rw-r--r--internal/game/session_registry.go19
1 files changed, 19 insertions, 0 deletions
diff --git a/internal/game/session_registry.go b/internal/game/session_registry.go
new file mode 100644
index 0000000..0e47f82
--- /dev/null
+++ b/internal/game/session_registry.go
@@ -0,0 +1,19 @@
+package game
+
+import "thehouseoficarus/internal/net"
+
+// attachSession registers a fully-logged-in session in the game's
+// character registry. Menu flows call it through connectCharacter; the test
+// harness uses it to skip the menu.
+func (g *Game) attachSession(sess *net.Session) {
+ g.charsMu.Lock()
+ g.loggedInChars[sess.Player.Name] = sess
+ g.charsMu.Unlock()
+}
+
+// detachSession removes a character's registry entry.
+func (g *Game) detachSession(name string) {
+ g.charsMu.Lock()
+ delete(g.loggedInChars, name)
+ g.charsMu.Unlock()
+}