aboutsummaryrefslogtreecommitdiff
path: root/internal/game
diff options
context:
space:
mode:
authorhistoria <[not public]>2026-06-29 04:41:40 -0400
committerhistoria <[not public]>2026-06-29 04:41:40 -0400
commit71ce47ca37566be8dc390434df4cd01422298094 (patch)
treec688dc5ff84af8c03a5c825dd6a3926281a8cae3 /internal/game
parent0fe67cfd5def4ac3e919fd611fe5acc55ca2d253 (diff)
downloadthehouseoficarus-71ce47ca37566be8dc390434df4cd01422298094.tar.gz
fix: long fields truncated better in tables
Diffstat (limited to 'internal/game')
-rw-r--r--internal/game/cmd_color.go1
-rw-r--r--internal/game/cmd_option.go11
-rw-r--r--internal/game/sys_safespot.go12
3 files changed, 10 insertions, 14 deletions
diff --git a/internal/game/cmd_color.go b/internal/game/cmd_color.go
index fd9fa55..f7041df 100644
--- a/internal/game/cmd_color.go
+++ b/internal/game/cmd_color.go
@@ -166,6 +166,7 @@ var colorCategoryOrder = []string{
"map_at",
"map_blocked",
+ "safespot_alert",
}
func showColorTable(g *Game, sess *net.Session) {
diff --git a/internal/game/cmd_option.go b/internal/game/cmd_option.go
index 958fc0b..f404c2e 100644
--- a/internal/game/cmd_option.go
+++ b/internal/game/cmd_option.go
@@ -26,7 +26,7 @@ func (g *Game) doOption(sess *net.Session, input string) {
}
for _, def := range player.OptionDefs {
val := formatOptionValue(p, &def)
- val = truncateForTable(val)
+ val = truncateForTable(val, p.OptionBool("unicode"))
valid := formatValidValues(&def)
table.Rows = append(table.Rows, []string{
color.Render(mode, color.Parse("4B"), def.Name),
@@ -150,9 +150,12 @@ func parseOptionValue(def *player.OptionDef, input string) (any, bool) {
return nil, false
}
-func truncateForTable(s string) string {
- if len(s) <= 10 {
+func truncateForTable(s string, unicode bool) string {
+ ellipsis := color.Ellipsis(unicode)
+ ellipLen := len([]rune(ellipsis))
+ if len([]rune(s)) <= 10 {
return s
}
- return s[:7] + "..."
+ runes := []rune(s)
+ return string(runes[:10-ellipLen]) + ellipsis
}
diff --git a/internal/game/sys_safespot.go b/internal/game/sys_safespot.go
index 5544667..cdb954b 100644
--- a/internal/game/sys_safespot.go
+++ b/internal/game/sys_safespot.go
@@ -191,12 +191,7 @@ func (g *Game) degradeSafespot(st *world.ObjState, objDef *object.ObjectDef, cfg
if occSess := g.sessionInRoom(name, roomSessions); occSess != nil {
occSess.WriteLine(color.ExpandTags(g.colorMode(occSess),
fmt.Sprintf("The %s crumbles away!", objDef.Name)))
- if occSess.Player != nil {
- alert := occSess.Player.OptionString("safespot_alert")
- if alert != "" {
- occSess.WriteLine(color.ExpandTags(g.colorMode(occSess), alert))
- }
- }
+ occSess.WriteLine(g.colorize(occSess, "safespot_alert", "Your safespot has been compromised!"))
g.writePrompt(occSess)
}
}
@@ -265,10 +260,7 @@ func (g *Game) forceLeaveSafespot(sess *net.Session, p *player.Player, ss *Safes
if reason != "" {
sess.WriteLine(reason)
- alert := p.OptionString("safespot_alert")
- if alert != "" {
- sess.WriteLine(color.ExpandTags(g.colorMode(sess), alert))
- }
+ sess.WriteLine(g.colorize(sess, "safespot_alert", "Your safespot has been compromised!"))
}
}