From 9292634f2f8d71a53879ff07e1330c671b207d51 Mon Sep 17 00:00:00 2001 From: historia <[not public]> Date: Mon, 6 Jul 2026 23:05:04 -0400 Subject: feat: split the concept of hidden and impassable exits. add player_flag for discovered hidden exits. --- internal/world/room_test.go | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) (limited to 'internal/world/room_test.go') diff --git a/internal/world/room_test.go b/internal/world/room_test.go index e7b1718..1ad974e 100644 --- a/internal/world/room_test.go +++ b/internal/world/room_test.go @@ -4,6 +4,8 @@ import ( "os" "path/filepath" "testing" + + "gopkg.in/yaml.v3" ) func writeRoom(t *testing.T, dir string, body string) { @@ -90,3 +92,45 @@ func TestNormalizeObjectName(t *testing.T) { } } } + +func TestExitDefUnmarshalAlwaysBlocked(t *testing.T) { + y := `exits: + north: + room: 5 + always_blocked: true + south: 3 + east: + room: 7 + hidden: true +` + var room struct { + Exits map[ExitDir]ExitDef `yaml:"exits"` + } + if err := yaml.Unmarshal([]byte(y), &room); err != nil { + t.Fatalf("unmarshal: %v", err) + } + if len(room.Exits) != 3 { + t.Fatalf("expected 3 exits, got %d", len(room.Exits)) + } + n := room.Exits[North] + if !n.AlwaysBlocked { + t.Error("north exit should have AlwaysBlocked=true") + } + if n.Room != 5 { + t.Errorf("north target = %d, want 5", n.Room) + } + s := room.Exits[South] + if s.Room != 3 { + t.Errorf("south target = %d, want 3", s.Room) + } + if s.AlwaysBlocked { + t.Error("south exit should not have AlwaysBlocked") + } + e := room.Exits[East] + if !e.Hidden { + t.Error("east exit should have Hidden=true") + } + if e.AlwaysBlocked { + t.Error("east exit should not have AlwaysBlocked") + } +} -- cgit v1.2.3