aboutsummaryrefslogtreecommitdiff
path: root/internal/game
diff options
context:
space:
mode:
authorhistoria <[not public]>2026-06-29 01:41:49 -0400
committerhistoria <[not public]>2026-06-29 01:41:49 -0400
commit12ed73f9ff9de1a145683de8a73c170613371979 (patch)
tree8b35d3dfda8231edcbc33e2fc2eb68000128e48c /internal/game
parente9d87838590a02c7ca028fad8cd16e42a582dd32 (diff)
downloadthehouseoficarus-12ed73f9ff9de1a145683de8a73c170613371979.tar.gz
wrap_width and table improvements, targeting 80 character default width
Diffstat (limited to 'internal/game')
-rw-r--r--internal/game/cmd_aps.go2
-rw-r--r--internal/game/cmd_bank.go2
-rw-r--r--internal/game/cmd_color.go2
-rw-r--r--internal/game/cmd_look.go24
-rw-r--r--internal/game/cmd_mods.go2
-rw-r--r--internal/game/cmd_option.go2
-rw-r--r--internal/game/cmd_shop.go4
-rw-r--r--internal/game/cmd_skills.go2
-rw-r--r--internal/game/cmd_tech.go2
-rw-r--r--internal/game/look_room.go3
-rw-r--r--internal/game/production_menu.go4
-rw-r--r--internal/game/render_help.go4
12 files changed, 34 insertions, 19 deletions
diff --git a/internal/game/cmd_aps.go b/internal/game/cmd_aps.go
index 5e209a6..a5cff78 100644
--- a/internal/game/cmd_aps.go
+++ b/internal/game/cmd_aps.go
@@ -148,7 +148,7 @@ func displayApsNodes(g *Game, sess *net.Session, p *player.Player, known []int)
Rows: rows,
}
- for _, line := range t.Render(p.OptionBool("unicode")) {
+ for _, line := range t.Render(p.OptionBool("unicode"), p.OptionInt("wrap_width")) {
sess.WriteLine(line)
}
}
diff --git a/internal/game/cmd_bank.go b/internal/game/cmd_bank.go
index c489ad8..bbf600f 100644
--- a/internal/game/cmd_bank.go
+++ b/internal/game/cmd_bank.go
@@ -110,7 +110,7 @@ func (g *Game) showBankBrowse(sess *net.Session) {
})
}
- for _, line := range t.Render(unicode) {
+ for _, line := range t.Render(unicode, p.OptionInt("wrap_width")) {
sess.WriteLine(line)
}
}
diff --git a/internal/game/cmd_color.go b/internal/game/cmd_color.go
index 8e90f02..00b4ce8 100644
--- a/internal/game/cmd_color.go
+++ b/internal/game/cmd_color.go
@@ -193,7 +193,7 @@ func showColorTable(g *Game, sess *net.Session) {
color.Render(mode, color.Parse("F3"), source),
})
}
- for _, line := range table.Render(p.OptionBool("unicode")) {
+ for _, line := range table.Render(p.OptionBool("unicode"), p.OptionInt("wrap_width")) {
sess.WriteLine(line)
}
}
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
}
diff --git a/internal/game/cmd_mods.go b/internal/game/cmd_mods.go
index 4f3f9ff..9468e89 100644
--- a/internal/game/cmd_mods.go
+++ b/internal/game/cmd_mods.go
@@ -92,7 +92,7 @@ func (g *Game) doMods(sess *net.Session, showAll bool) {
}
}
- for _, line := range t.Render(p.OptionBool("unicode")) {
+ for _, line := range t.Render(p.OptionBool("unicode"), p.OptionInt("wrap_width")) {
sess.WriteLine(line)
}
sess.WriteLine("")
diff --git a/internal/game/cmd_option.go b/internal/game/cmd_option.go
index a2e54c2..958fc0b 100644
--- a/internal/game/cmd_option.go
+++ b/internal/game/cmd_option.go
@@ -35,7 +35,7 @@ func (g *Game) doOption(sess *net.Session, input string) {
color.Render(mode, color.Parse("FC"), def.Description),
})
}
- for _, line := range table.Render(p.OptionBool("unicode")) {
+ for _, line := range table.Render(p.OptionBool("unicode"), p.OptionInt("wrap_width")) {
sess.WriteLine(line)
}
return
diff --git a/internal/game/cmd_shop.go b/internal/game/cmd_shop.go
index 91a11c6..69de750 100644
--- a/internal/game/cmd_shop.go
+++ b/internal/game/cmd_shop.go
@@ -118,8 +118,10 @@ func (g *Game) showShopBrowse(sess *net.Session) {
}
unicode := true
+ wrapWidth := 0
if p := sess.Player; p != nil {
unicode = p.OptionBool("unicode")
+ wrapWidth = p.OptionInt("wrap_width")
}
t := ui.Table{
@@ -145,7 +147,7 @@ func (g *Game) showShopBrowse(sess *net.Session) {
})
}
- for _, line := range t.Render(unicode) {
+ for _, line := range t.Render(unicode, wrapWidth) {
sess.WriteLine(line)
}
}
diff --git a/internal/game/cmd_skills.go b/internal/game/cmd_skills.go
index 9321b96..4aacd31 100644
--- a/internal/game/cmd_skills.go
+++ b/internal/game/cmd_skills.go
@@ -35,7 +35,7 @@ func (g *Game) doSkills(sess *net.Session) {
color.Render(mode, color.Parse("B3"), strconv.Itoa(next)),
})
}
- for _, line := range t.Render(p.OptionBool("unicode")) {
+ for _, line := range t.Render(p.OptionBool("unicode"), p.OptionInt("wrap_width")) {
sess.WriteLine(line)
}
}
diff --git a/internal/game/cmd_tech.go b/internal/game/cmd_tech.go
index 8c6f14f..cb0465f 100644
--- a/internal/game/cmd_tech.go
+++ b/internal/game/cmd_tech.go
@@ -150,7 +150,7 @@ func (g *Game) doTechList(sess *net.Session) {
})
}
- for _, line := range t.Render(p.OptionBool("unicode")) {
+ for _, line := range t.Render(p.OptionBool("unicode"), p.OptionInt("wrap_width")) {
sess.WriteLine(line)
}
diff --git a/internal/game/look_room.go b/internal/game/look_room.go
index 585efb0..f35d564 100644
--- a/internal/game/look_room.go
+++ b/internal/game/look_room.go
@@ -35,8 +35,7 @@ func (g *Game) roomSymbolBracket(sess *net.Session, p *player.Player, room *worl
color.Render(mode, dimSpec, "]")
}
-func (g *Game) showRoomDescription(sess *net.Session, p *player.Player, room *world.Room) []string {
- descWidth := p.OptionInt("room_desc_width")
+func (g *Game) showRoomDescription(sess *net.Session, p *player.Player, room *world.Room, descWidth int) []string {
if descWidth <= 0 {
descWidth = 70
}
diff --git a/internal/game/production_menu.go b/internal/game/production_menu.go
index f625d54..bc2fccc 100644
--- a/internal/game/production_menu.go
+++ b/internal/game/production_menu.go
@@ -169,7 +169,7 @@ func (g *Game) showProductionTable(sess *net.Session, p *player.Player, items []
unicode := p.OptionBool("unicode")
sess.WriteLine("")
- for _, line := range tbl.Render(unicode) {
+ for _, line := range tbl.Render(unicode, p.OptionInt("wrap_width")) {
sess.WriteLine(line)
}
@@ -350,7 +350,7 @@ func (g *Game) showMenuTable(sess *net.Session, title string, names []string) {
}
unicode := p.OptionBool("unicode")
sess.WriteLine("")
- for _, line := range tbl.Render(unicode) {
+ for _, line := range tbl.Render(unicode, p.OptionInt("wrap_width")) {
sess.WriteLine(line)
}
}
diff --git a/internal/game/render_help.go b/internal/game/render_help.go
index 869d306..798eadf 100644
--- a/internal/game/render_help.go
+++ b/internal/game/render_help.go
@@ -100,8 +100,10 @@ func LoadHelp(dataDir string) ([]HelpDef, error) {
func (g *Game) doHelp(sess *net.Session, topic string) {
if topic == "" {
unicode := true
+ wrapWidth := 0
if p := sess.Player; p != nil {
unicode = p.OptionBool("unicode")
+ wrapWidth = p.OptionInt("wrap_width")
}
sess.WriteLine("")
@@ -112,7 +114,7 @@ func (g *Game) doHelp(sess *net.Session, topic string) {
for _, c := range commandList {
t.Rows = append(t.Rows, []string{c.Name, c.Type, c.Desc})
}
- for _, line := range t.Render(unicode) {
+ for _, line := range t.Render(unicode, wrapWidth) {
sess.WriteLine(line)
}
sess.WriteLine("")