aboutsummaryrefslogtreecommitdiff
path: root/internal/game/map_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/game/map_test.go')
-rw-r--r--internal/game/map_test.go27
1 files changed, 22 insertions, 5 deletions
diff --git a/internal/game/map_test.go b/internal/game/map_test.go
index 4869d38..0d529cf 100644
--- a/internal/game/map_test.go
+++ b/internal/game/map_test.go
@@ -26,15 +26,17 @@ func writeTempRoom(t *testing.T, dir string, id int, body string) {
}
// TestMapConnectorGlyphs verifies the directional link rendering: bidirectional
-// links draw a bar, one-way (or one-side-blocked) links draw a directional
-// arrow, and links with no traversable direction draw a blocked 'X'.
+// links draw a bar, one-way links draw a directional arrow, outward-blocked
+// links draw a blocked 'X', and links with no traversable direction draw 'X'.
func TestMapConnectorGlyphs(t *testing.T) {
const condEast = "name: One\nexits:\n east:\n room: 2\n condition:\n flag: gate_open\n"
+ const condSouth = "name: Three\nexits:\n south:\n room: 2\n condition:\n flag: gate_open\n"
cases := []struct {
name string
room1 string
room2 string
+ room3 string
flagOpen bool
wantPresent string
wantAbsent []string
@@ -54,12 +56,12 @@ func TestMapConnectorGlyphs(t *testing.T) {
wantAbsent: []string{"X", "-", "<"},
},
{
- name: "forward blocked, reverse open -> arrow not X",
+ name: "forward blocked, reverse open -> X (shortest path is blocked)",
room1: condEast,
room2: "name: Two\nexits:\n west: 1\n",
flagOpen: false,
- wantPresent: "<",
- wantAbsent: []string{"X", "-", ">"},
+ wantPresent: "X",
+ wantAbsent: []string{"-", "<", ">"},
},
{
name: "forward blocked, reverse absent -> X",
@@ -77,6 +79,18 @@ func TestMapConnectorGlyphs(t *testing.T) {
wantPresent: "-",
wantAbsent: []string{"X", "<", ">"},
},
+ {
+ name: "outward open, inward blocked -> outward arrow (dist rules)",
+ room1: "name: One\nexits:\n east: 2\n",
+ room2: "name: Two\nexits:\n west: 1\n north: 3\n",
+ room3: condSouth,
+ flagOpen: false,
+ // dist[room1]=0, dist[room2]=1, dist[room3]=2.
+ // Link 2↔3: near=2 (dist1), far=3 (dist2).
+ // out = 2→north→3 = open → '^'
+ wantPresent: "^",
+ wantAbsent: []string{"X", "v", "<", ">"},
+ },
}
for _, tc := range cases {
@@ -84,6 +98,9 @@ func TestMapConnectorGlyphs(t *testing.T) {
dir := t.TempDir()
writeTempRoom(t, dir, 1, tc.room1)
writeTempRoom(t, dir, 2, tc.room2)
+ if tc.room3 != "" {
+ writeTempRoom(t, dir, 3, tc.room3)
+ }
g := &Game{Deps: Deps{World: world.New(dir)}, Flags: NewFlagStore()}
if tc.flagOpen {