package game import ( "testing" "thehouseoficarus/internal/player" "thehouseoficarus/internal/world" ) func TestDiscoveredExitFlagKey(t *testing.T) { key := discoveredExitFlag(2001, world.North) if key != "hidden_exit_2001_north" { t.Errorf("unexpected flag key: %q", key) } key = discoveredExitFlag(100, world.Down) if key != "hidden_exit_100_down" { t.Errorf("unexpected flag key: %q", key) } } func TestExitDiscoveredUndiscovered(t *testing.T) { p := &player.Player{} if g := (&Game{}).exitDiscovered(p, 42, world.East); g { t.Error("expected undiscovered to be false") } } func TestExitDiscoveredAfterMark(t *testing.T) { g := &Game{Flags: NewFlagStore()} p := &player.Player{} roomID := 42 dir := world.East flagKey := discoveredExitFlag(roomID, dir) if g.exitDiscovered(p, roomID, dir) { t.Error("should not be discovered before marking") } g.markExitDiscovered(p, roomID, dir) if !g.exitDiscovered(p, roomID, dir) { t.Error("should be discovered after marking") } if getPlayerFlagInt(p, flagKey) == 0 { t.Error("flag should be set after marking") } } func TestExitDiscoveredGodMode(t *testing.T) { p := &player.Player{GodMode: true} if !(&Game{}).exitDiscovered(p, 99, world.South) { t.Error("god mode should always see exits as discovered") } } func TestExitHiddenFiltered(t *testing.T) { g := &Game{Flags: NewFlagStore()} p := &player.Player{} if !g.exitHiddenFiltered(p, 1, world.North, false) { t.Error("non-hidden exit should pass filter") } if g.exitHiddenFiltered(p, 1, world.North, true) { t.Error("hidden undiscovered exit should be filtered") } g.markExitDiscovered(p, 1, world.North) if !g.exitHiddenFiltered(p, 1, world.North, true) { t.Error("hidden discovered exit should pass filter") } } func TestExitDiscoveredDifferentRoom(t *testing.T) { g := &Game{Flags: NewFlagStore()} p := &player.Player{} g.markExitDiscovered(p, 10, world.North) if g.exitDiscovered(p, 10, world.East) { t.Error("discovering north should not mark east as discovered") } if g.exitDiscovered(p, 20, world.North) { t.Error("discovering room 10 north should not mark room 20 north") } }