aboutsummaryrefslogtreecommitdiff
path: root/internal/world
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/world
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/world')
-rw-r--r--internal/world/room.go63
-rw-r--r--internal/world/world.go2
2 files changed, 45 insertions, 20 deletions
diff --git a/internal/world/room.go b/internal/world/room.go
index 21e1277..15f847f 100644
--- a/internal/world/room.go
+++ b/internal/world/room.go
@@ -11,34 +11,59 @@ import (
type ExitDir string
const (
- North ExitDir = "north"
- South ExitDir = "south"
- East ExitDir = "east"
- West ExitDir = "west"
- Up ExitDir = "up"
- Down ExitDir = "down"
+ North ExitDir = "north"
+ South ExitDir = "south"
+ East ExitDir = "east"
+ West ExitDir = "west"
+ Northeast ExitDir = "northeast"
+ Northwest ExitDir = "northwest"
+ Southeast ExitDir = "southeast"
+ Southwest ExitDir = "southwest"
+ Up ExitDir = "up"
+ Down ExitDir = "down"
)
var ExitAliases = map[string]ExitDir{
- "n": North,
- "s": South,
- "e": East,
- "w": West,
- "u": Up,
- "d": Down,
+ "n": North,
+ "s": South,
+ "e": East,
+ "w": West,
+ "ne": Northeast,
+ "nw": Northwest,
+ "se": Southeast,
+ "sw": Southwest,
+ "u": Up,
+ "d": Down,
}
var OppositeExit = map[ExitDir]ExitDir{
- North: South,
- South: North,
- East: West,
- West: East,
- Up: Down,
- Down: Up,
+ North: South,
+ South: North,
+ East: West,
+ West: East,
+ Northeast: Southwest,
+ Northwest: Southeast,
+ Southeast: Northwest,
+ Southwest: Northeast,
+ Up: Down,
+ Down: Up,
}
var ExitOrder = []ExitDir{
- North, South, East, West, Up, Down,
+ North, South, East, West,
+ Northeast, Northwest, Southeast, Southwest,
+ Up, Down,
+}
+
+var DirectionDeltas = map[ExitDir][2]int{
+ North: {0, -1},
+ South: {0, 1},
+ East: {1, 0},
+ West: {-1, 0},
+ Northeast: {1, -1},
+ Northwest: {-1, -1},
+ Southeast: {1, 1},
+ Southwest: {-1, 1},
}
type SpawnDef struct {
diff --git a/internal/world/world.go b/internal/world/world.go
index 0c992ad..3dfa99b 100644
--- a/internal/world/world.go
+++ b/internal/world/world.go
@@ -68,7 +68,7 @@ func (w *World) ResolveExit(input string) ExitDir {
}
canon := ExitDir(strings.ToLower(input))
switch canon {
- case North, South, East, West, Up, Down:
+ case North, South, East, West, Northeast, Northwest, Southeast, Southwest, Up, Down:
return canon
}
return ""