From feb80b7dde200d4121cd9f9c583a08f9869c5588 Mon Sep 17 00:00:00 2001 From: historia <[not public]> Date: Mon, 29 Jun 2026 17:19:40 -0400 Subject: feat: incardinal directions (nw, ne, sw, se). probably janky in ways I haven't yet discovered. --- internal/game/cmd_walk.go | 36 ++++++++++++++++++++++++++++++++---- 1 file changed, 32 insertions(+), 4 deletions(-) (limited to 'internal/game/cmd_walk.go') diff --git a/internal/game/cmd_walk.go b/internal/game/cmd_walk.go index d7d51e2..ec62eec 100644 --- a/internal/game/cmd_walk.go +++ b/internal/game/cmd_walk.go @@ -60,9 +60,25 @@ func parseWalkDirections(input string) ([]string, error) { var dir string switch ch { case 'n': - dir = string(world.North) + if i < len(input) && input[i] == 'e' { + i++ + dir = string(world.Northeast) + } else if i < len(input) && input[i] == 'w' { + i++ + dir = string(world.Northwest) + } else { + dir = string(world.North) + } case 's': - dir = string(world.South) + if i < len(input) && input[i] == 'e' { + i++ + dir = string(world.Southeast) + } else if i < len(input) && input[i] == 'w' { + i++ + dir = string(world.Southwest) + } else { + dir = string(world.South) + } case 'e': dir = string(world.East) case 'w': @@ -150,6 +166,14 @@ func directionToChar(dir string) string { return "e" case world.West: return "w" + case world.Northeast: + return "ne" + case world.Northwest: + return "nw" + case world.Southeast: + return "se" + case world.Southwest: + return "sw" case world.Up: return "u" case world.Down: @@ -158,7 +182,11 @@ func directionToChar(dir string) string { return "?" } -var bfsSearchDirs = []world.ExitDir{world.North, world.South, world.East, world.West, world.Up, world.Down} +var walkSearchDirs = []world.ExitDir{ + world.North, world.South, world.East, world.West, + world.Northeast, world.Northwest, world.Southeast, world.Southwest, + world.Up, world.Down, +} func (g *Game) findPathToRoom(fromRoom, toRoom int) []string { if fromRoom == toRoom { @@ -183,7 +211,7 @@ func (g *Game) findPathToRoom(fromRoom, toRoom int) []string { continue } - for _, dir := range bfsSearchDirs { + for _, dir := range walkSearchDirs { exitDef, exists := room.Exits[dir] if !exists { continue -- cgit v1.2.3