diff options
| author | historia <[not public]> | 2026-07-06 23:05:04 -0400 |
|---|---|---|
| committer | historia <[not public]> | 2026-07-06 23:05:04 -0400 |
| commit | 9292634f2f8d71a53879ff07e1330c671b207d51 (patch) | |
| tree | dcffadf7f697e8ad0705d787d8f599bdeeedb812 /internal/game/render_map.go | |
| parent | 911aae15f4e869c93239ef7c630c61e1d9d4ef3f (diff) | |
| download | thehouseoficarus-9292634f2f8d71a53879ff07e1330c671b207d51.tar.gz | |
feat: split the concept of hidden and impassable exits. add player_flag for discovered hidden exits.
Diffstat (limited to 'internal/game/render_map.go')
| -rw-r--r-- | internal/game/render_map.go | 45 |
1 files changed, 37 insertions, 8 deletions
diff --git a/internal/game/render_map.go b/internal/game/render_map.go index 1bc9adc..5e57bc7 100644 --- a/internal/game/render_map.go +++ b/internal/game/render_map.go @@ -6,6 +6,7 @@ import ( "thehouseoficarus/internal/color" "thehouseoficarus/internal/net" + "thehouseoficarus/internal/player" "thehouseoficarus/internal/world" ) @@ -55,10 +56,26 @@ type mapGraph struct { // player's z-plane is constant. const playerZ = 0 -func buildGraph(g *Game, startRoomID int) *mapGraph { +func buildGraph(g *Game, sess *net.Session, startRoomID int) *mapGraph { rg := world.BuildGrid(startRoomID, func(id int) (*world.Room, bool) { return loadRoom(g, id) - }, nil, nil) + }, nil, func(fromID int, dir world.ExitDir, targetID int) bool { + if sess == nil || sess.Player == nil { + return true + } + room, ok := loadRoom(g, fromID) + if !ok { + return true + } + exit, ok := room.Exits[dir] + if !ok || exit.Room != targetID { + return true + } + if exit.Hidden && !g.exitDiscovered(sess.Player, fromID, dir) { + return false + } + return true + }, nil) return &mapGraph{posToRoom: rg.RoomAt, dist: rg.Dist} } @@ -88,7 +105,7 @@ func renderMapCells(grid [][]mapCell, colorMode string, startRow, endRow int, bo func buildTinyMap(g *Game, sess *net.Session, roomID int, mg mapGlyphs) []string { visited := roomsVisited(sess) - bg := buildGraph(g, roomID) + bg := buildGraph(g, sess, roomID) colorMode := colorModeFor(sess) atSpec := resolveMapAt(g, sess) @@ -261,7 +278,7 @@ func buildTinyMap(g *Game, sess *net.Session, roomID int, mg mapGlyphs) []string func buildFullMap(g *Game, sess *net.Session, roomID, mapWidth, mapHeight int, mg mapGlyphs) []string { visited := roomsVisited(sess) - bg := buildGraph(g, roomID) + bg := buildGraph(g, sess, roomID) colorMode := colorModeFor(sess) atSpec := resolveMapAt(g, sess) @@ -602,10 +619,15 @@ func exitStateTo(g *Game, sess *net.Session, from int, dir world.ExitDir, neighb if !ok || exit.Room != neighbor { return exitAbsent } - // Hidden exits are non-traversable to players but are followed by the map - // layout BFS, so they always render as traversable (open) connectors. - if exit.Hidden { - return exitOpen + p := sessPlayer(sess) + if exit.Hidden && !g.exitDiscovered(p, from, dir) { + return exitAbsent + } + if exit.AlwaysBlocked { + if p != nil && p.GodMode { + return exitOpen + } + return exitBlocked } if exit.Condition == nil || sess == nil || sess.Player == nil { return exitOpen @@ -616,6 +638,13 @@ func exitStateTo(g *Game, sess *net.Session, from int, dir world.ExitDir, neighb return exitBlocked } +func sessPlayer(sess *net.Session) *player.Player { + if sess != nil { + return sess.Player + } + return nil +} + func isDiagonalGlyph(ch rune) bool { return ch == '\\' || ch == '/' || ch == '↗' || ch == '↖' || ch == '↘' || ch == '↙' } |
