aboutsummaryrefslogtreecommitdiff
path: root/internal/game/cmd_look.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/game/cmd_look.go')
-rw-r--r--internal/game/cmd_look.go28
1 files changed, 5 insertions, 23 deletions
diff --git a/internal/game/cmd_look.go b/internal/game/cmd_look.go
index c34052a..f36fd9e 100644
--- a/internal/game/cmd_look.go
+++ b/internal/game/cmd_look.go
@@ -67,31 +67,13 @@ func (g *Game) doExits(sess *net.Session) {
sess.WriteLine("There are no exits here.")
return
}
- type exitLine struct {
- dir string
- name string
- }
- var lines []exitLine
- maxDirLen := 0
- for _, dir := range world.ExitOrder {
- exitDef, ok := room.Exits[dir]
- if !ok {
- continue
- }
- coloredDir := g.colorize(sess, "exit_direction", string(dir))
- targetRoom, err := g.World.LoadRoom(exitDef.Room)
- targetName := g.colorize(sess, "room_number", fmt.Sprintf("#%d", exitDef.Room))
- if err == nil {
- targetName = g.colorize(sess, "exit_name", targetRoom.Name)
- }
- lines = append(lines, exitLine{coloredDir, targetName})
- if visibleLen(coloredDir) > maxDirLen {
- maxDirLen = visibleLen(coloredDir)
- }
+ lines := g.formatExitLines(sess, room)
+ if len(lines) == 0 {
+ sess.WriteLine("There are no exits here.")
+ return
}
for _, l := range lines {
- pad := maxDirLen + (len(l.dir) - visibleLen(l.dir))
- sess.WriteLine(fmt.Sprintf(" %-*s - %s", pad, l.dir, l.name))
+ sess.WriteLine(l)
}
}