aboutsummaryrefslogtreecommitdiff
path: root/internal/game/cmd_walk.go
diff options
context:
space:
mode:
authorhistoria <[not public]>2026-06-29 17:19:40 -0400
committerhistoria <[not public]>2026-06-29 17:19:40 -0400
commitfeb80b7dde200d4121cd9f9c583a08f9869c5588 (patch)
tree3271cae1d74c8f3b84ef3ae84f8f62e563029dff /internal/game/cmd_walk.go
parentc6cbf76b33ac20d071d25e74b70f6901476193a6 (diff)
downloadthehouseoficarus-feb80b7dde200d4121cd9f9c583a08f9869c5588.tar.gz
feat: incardinal directions (nw, ne, sw, se). probably janky in ways I haven't yet discovered.
Diffstat (limited to 'internal/game/cmd_walk.go')
-rw-r--r--internal/game/cmd_walk.go36
1 files changed, 32 insertions, 4 deletions
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