aboutsummaryrefslogtreecommitdiff
path: root/internal/world/room_migrate_test.go
diff options
context:
space:
mode:
authorhistoria <[not public]>2026-07-08 19:59:14 -0400
committerhistoria <[not public]>2026-07-08 19:59:14 -0400
commit09d325dcf5e779eab5550d3fd3377bde50101428 (patch)
treea433be903aabbf1d2eadce2aacdac12a9eb8dde0 /internal/world/room_migrate_test.go
parent9184377301c2604e003f36426788c032fb0ca524 (diff)
downloadthehouseoficarus-09d325dcf5e779eab5550d3fd3377bde50101428.tar.gz
feat: unify on use, on look, and on kill. all support same conditions/actions now.
Diffstat (limited to 'internal/world/room_migrate_test.go')
-rw-r--r--internal/world/room_migrate_test.go26
1 files changed, 18 insertions, 8 deletions
diff --git a/internal/world/room_migrate_test.go b/internal/world/room_migrate_test.go
index 5696a36..c54adf2 100644
--- a/internal/world/room_migrate_test.go
+++ b/internal/world/room_migrate_test.go
@@ -1,23 +1,29 @@
package world
-import "testing"
+import (
+ "testing"
+
+ "thehouseoficarus/internal/behavior"
+)
func TestRoomRewriteRoomIDs(t *testing.T) {
r := &Room{
Exits: map[ExitDir]ExitDef{
- North: {Room: 10, SetGlobalFlags: map[string]any{"last": 10}},
+ North: {Room: 10, OnTraverse: []behavior.Interaction{{Action: &behavior.StepAction{
+ NodeAction: behavior.NodeAction{SetGlobalFlags: map[string]any{"last": 10}, Teleport: 110},
+ }}}},
South: {Room: 99},
},
Triggers: []TriggerDef{
{
Room: 30,
- Steps: []TriggerStep{
- {Teleport: 40, SpawnMob: &SpawnMobConfig{DespawnRooms: []int{50, 60}}},
+ Steps: []behavior.StepAction{
+ {NodeAction: behavior.NodeAction{Teleport: 40}, SpawnMob: &behavior.SpawnMobConfig{DespawnRooms: []int{50, 60}}},
},
},
},
- OnEnter: []EnterStep{
- {Teleport: 70, SpawnMob: &SpawnMobConfig{DespawnRooms: []int{80}}},
+ OnEnter: []behavior.StepAction{
+ {NodeAction: behavior.NodeAction{Teleport: 70}, SpawnMob: &behavior.SpawnMobConfig{DespawnRooms: []int{80}}},
},
Mobs: []RoomMob{
{ID: "guard", WanderRooms: []int{90, 100}},
@@ -26,7 +32,7 @@ func TestRoomRewriteRoomIDs(t *testing.T) {
idMap := map[int]int{
10: 11, 20: 21, 30: 31, 40: 41, 50: 51, 60: 61,
- 70: 71, 80: 81, 90: 91, 100: 101,
+ 70: 71, 80: 81, 90: 91, 100: 101, 110: 111,
}
if !r.RewriteRoomIDs(idMap) {
t.Fatal("expected changed=true")
@@ -43,9 +49,13 @@ func TestRoomRewriteRoomIDs(t *testing.T) {
// Author set_flags values are NOT structural room references and must not
// be remapped (the old swapid regex wrongly rewrote these).
- if v := r.Exits[North].SetGlobalFlags["last"]; v != 10 {
+ if v := r.Exits[North].OnTraverse[0].Action.SetGlobalFlags["last"]; v != 10 {
t.Errorf("set_global_flags value remapped: got %v, want 10", v)
}
+ // Exit on_traverse teleport IS a structural room reference and must remap.
+ if r.Exits[North].OnTraverse[0].Action.Teleport != 111 {
+ t.Errorf("exit on_traverse teleport = %d, want 111", r.Exits[North].OnTraverse[0].Action.Teleport)
+ }
if r.Triggers[0].Room != 31 {
t.Errorf("trigger room = %d, want 31", r.Triggers[0].Room)