diff options
Diffstat (limited to 'internal/world')
| -rw-r--r-- | internal/world/room.go | 63 | ||||
| -rw-r--r-- | internal/world/world.go | 2 |
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 "" |
