aboutsummaryrefslogtreecommitdiff
path: root/internal/world/fix_regressions_test.go
diff options
context:
space:
mode:
authorhistoria <[not public]>2026-10-06 12:57:23 -0400
committerhistoria <[not public]>2026-10-06 12:57:23 -0400
commit9666676766bf21364f4fc4d0d1d336e72f2a91b4 (patch)
tree0cade34091d7602790dc38cd44053f0b74bbadf2 /internal/world/fix_regressions_test.go
parent4bc1daaf259e0c19c5fe4a12ec8bc7f6e5a735c1 (diff)
downloadthehouseoficarus-9666676766bf21364f4fc4d0d1d336e72f2a91b4.tar.gz
refactor: split casino.go, dedup helpers, remove audit docs
Diffstat (limited to 'internal/world/fix_regressions_test.go')
-rw-r--r--internal/world/fix_regressions_test.go61
1 files changed, 61 insertions, 0 deletions
diff --git a/internal/world/fix_regressions_test.go b/internal/world/fix_regressions_test.go
index f2ef795..770d2ef 100644
--- a/internal/world/fix_regressions_test.go
+++ b/internal/world/fix_regressions_test.go
@@ -151,3 +151,64 @@ func TestRekeyRoomsRemapsHomeRoomID(t *testing.T) {
t.Fatalf("HomeRoomID after rekey = %d, want 3", moved.HomeRoomID)
}
}
+
+// TestSetObjPropsMatchHomeRoomNotCurrentRoom: content edits pass the declaring
+// room, so property setters must match on HomeRoomID rather than the object's
+// current RoomID (which differs while it has wandered away).
+func TestSetObjPropsMatchHomeRoomNotCurrentRoom(t *testing.T) {
+ w := New(t.TempDir())
+ w.objStates[w.ObjStateKey(2, "anvil", 0)] = &ObjState{
+ RoomID: 2,
+ HomeRoomID: 1,
+ DefID: "anvil",
+ Index: 0,
+ }
+ w.SetObjName(1, "anvil", "iron anvil")
+ w.SetObjAliases(1, "anvil", []string{"workbench"})
+ w.SetObjWander(1, "anvil", []int{2, 3}, 4)
+ w.SetObjDepleteTimer(1, "anvil", 7)
+
+ st := w.GetObjState(2, "anvil", 0)
+ if st.Name != "iron anvil" {
+ t.Fatalf("name not applied: %+v", st)
+ }
+ if len(st.Aliases) != 1 || st.Aliases[0] != "workbench" {
+ t.Fatalf("aliases not applied: %+v", st)
+ }
+ if len(st.WanderRooms) != 2 || st.WanderInterval != 4 {
+ t.Fatalf("wander not applied: %+v", st)
+ }
+ if st.SharedMax != 7 {
+ t.Fatalf("deplete timer not applied: %+v", st)
+ }
+}
+
+// TestTickObjWanderSkipsOccupiedDestination: a wandering instance whose
+// destination key is already occupied must not evict the occupant for the
+// process lifetime.
+func TestTickObjWanderSkipsOccupiedDestination(t *testing.T) {
+ w := New(t.TempDir())
+ w.AddRoomPath(1, "room-1")
+ w.AddRoomPath(2, "room-2")
+ w.objStates[w.ObjStateKey(2, "anvil", 0)] = &ObjState{
+ RoomID: 2,
+ HomeRoomID: 2,
+ DefID: "anvil",
+ Index: 0,
+ }
+ w.objStates[w.ObjStateKey(1, "anvil", 0)] = &ObjState{
+ RoomID: 1,
+ HomeRoomID: 1,
+ DefID: "anvil",
+ Index: 0,
+ WanderRooms: []int{2},
+ WanderInterval: 1,
+ }
+ w.TickObjWander()
+ if w.GetObjState(2, "anvil", 0) == nil {
+ t.Fatal("destination occupant was evicted by a colliding wanderer")
+ }
+ if w.GetObjState(1, "anvil", 0) == nil {
+ t.Fatal("wanderer was lost instead of skipping the occupied destination")
+ }
+}