aboutsummaryrefslogtreecommitdiff
path: root/internal/world/room_test.go
diff options
context:
space:
mode:
authorhistoria <[not public]>2026-07-06 23:05:04 -0400
committerhistoria <[not public]>2026-07-06 23:05:04 -0400
commit9292634f2f8d71a53879ff07e1330c671b207d51 (patch)
treedcffadf7f697e8ad0705d787d8f599bdeeedb812 /internal/world/room_test.go
parent911aae15f4e869c93239ef7c630c61e1d9d4ef3f (diff)
downloadthehouseoficarus-9292634f2f8d71a53879ff07e1330c671b207d51.tar.gz
feat: split the concept of hidden and impassable exits. add player_flag for discovered hidden exits.
Diffstat (limited to 'internal/world/room_test.go')
-rw-r--r--internal/world/room_test.go44
1 files changed, 44 insertions, 0 deletions
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")
+ }
+}