From 12ed73f9ff9de1a145683de8a73c170613371979 Mon Sep 17 00:00:00 2001 From: historia <[not public]> Date: Mon, 29 Jun 2026 01:41:49 -0400 Subject: wrap_width and table improvements, targeting 80 character default width --- internal/game/cmd_look.go | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) (limited to 'internal/game/cmd_look.go') diff --git a/internal/game/cmd_look.go b/internal/game/cmd_look.go index a1ad708..c34052a 100644 --- a/internal/game/cmd_look.go +++ b/internal/game/cmd_look.go @@ -22,22 +22,34 @@ func (g *Game) doLook(sess *net.Session) { g.showRoomName(sess, p, room) + wrapWidth := p.OptionInt("wrap_width") + if wrapWidth < 80 { + wrapWidth = 80 + } + var mapLines []string - if p.OptionString("tiny_map") != "off" { + mapOn := p.OptionString("tiny_map") != "off" + if mapOn { mapLines = buildTinyMap(g, sess, p.RoomID, mapGlyphsForPlayer(p.OptionBool("unicode"))) if len(mapLines) != 7 { mapLines = nil + mapOn = false } } + descWidth := wrapWidth + if mapOn { + descWidth = wrapWidth - 9 + } + var content []string - content = append(content, g.showRoomDescription(sess, p, room)...) + content = append(content, g.showRoomDescription(sess, p, room, descWidth)...) content = append(content, g.showRoomObjects(sess, p, room)...) content = append(content, g.showRoomMobs(sess, p, room)...) content = append(content, g.showGroundItems(sess, p, room)...) - if len(mapLines) == 7 { - g.writeLookSideBySide(sess, p, content, mapLines) + if mapOn { + g.writeLookSideBySide(sess, p, content, mapLines, descWidth) } else { for _, line := range content { sess.WriteLine(line) @@ -138,13 +150,13 @@ func wrapText(text string, width int) []string { return lines } -func (g *Game) writeLookSideBySide(sess *net.Session, p *player.Player, contentLines []string, mapLines []string) { +func (g *Game) writeLookSideBySide(sess *net.Session, p *player.Player, contentLines []string, mapLines []string, descWidth int) { total := len(contentLines) if len(mapLines) > total { total = len(mapLines) } leftMap := p.OptionString("tiny_map") == "left" - mapWidth := p.OptionInt("room_desc_width") + mapWidth := descWidth if mapWidth <= 0 { mapWidth = 70 } -- cgit v1.2.3