diff options
| author | historia <[not public]> | 2026-06-29 01:41:49 -0400 |
|---|---|---|
| committer | historia <[not public]> | 2026-06-29 01:41:49 -0400 |
| commit | 12ed73f9ff9de1a145683de8a73c170613371979 (patch) | |
| tree | 8b35d3dfda8231edcbc33e2fc2eb68000128e48c /internal/game/cmd_look.go | |
| parent | e9d87838590a02c7ca028fad8cd16e42a582dd32 (diff) | |
| download | thehouseoficarus-12ed73f9ff9de1a145683de8a73c170613371979.tar.gz | |
wrap_width and table improvements, targeting 80 character default width
Diffstat (limited to 'internal/game/cmd_look.go')
| -rw-r--r-- | internal/game/cmd_look.go | 24 |
1 files changed, 18 insertions, 6 deletions
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 } |
