aboutsummaryrefslogtreecommitdiff
path: root/internal/game/sys_safespot_state_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/game/sys_safespot_state_test.go')
-rw-r--r--internal/game/sys_safespot_state_test.go19
1 files changed, 19 insertions, 0 deletions
diff --git a/internal/game/sys_safespot_state_test.go b/internal/game/sys_safespot_state_test.go
new file mode 100644
index 0000000..2976bce
--- /dev/null
+++ b/internal/game/sys_safespot_state_test.go
@@ -0,0 +1,19 @@
+package game
+
+import "testing"
+
+// TestSafespotManagerRekeyRooms: a live room rename must remap the room ID
+// stored on an active safespot, or the safespot lookup misses and the player
+// is force-ejected from cover.
+func TestSafespotManagerRekeyRooms(t *testing.T) {
+ m := NewSafespotManager()
+ m.Set("alice", SafespotState{Active: true, ObjectDefID: "bush", RoomID: 5})
+ m.Set("bob", SafespotState{Active: true, ObjectDefID: "rock", RoomID: 9})
+ m.RekeyRooms(map[int]int{5: 7})
+ if ss, _ := m.Get("alice"); ss.RoomID != 7 {
+ t.Fatalf("alice safespot room = %d, want 7", ss.RoomID)
+ }
+ if ss, _ := m.Get("bob"); ss.RoomID != 9 {
+ t.Fatalf("bob safespot room = %d, want 9 (unchanged)", ss.RoomID)
+ }
+}