From 445c4612cc5cf2c226f85894b6ad1e2419a374e2 Mon Sep 17 00:00:00 2001 From: historia <[not public]> Date: Mon, 15 Jun 2026 00:55:26 -0400 Subject: feat: walk command, improved tables and columns --- internal/game/help.go | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'internal/game/help.go') diff --git a/internal/game/help.go b/internal/game/help.go index 1e93dcf..2e9caa4 100644 --- a/internal/game/help.go +++ b/internal/game/help.go @@ -7,6 +7,7 @@ import ( "strings" "thirdcollapse/internal/net" + "thirdcollapse/internal/player" "gopkg.in/yaml.v3" ) @@ -49,7 +50,6 @@ func (g *Game) doHelp(sess *net.Session, topic string) { } if topic == "" { - // Group by category cats := make(map[string][]HelpDef) var catOrder []string for _, h := range helps { @@ -59,14 +59,23 @@ func (g *Game) doHelp(sess *net.Session, topic string) { cats[h.Category] = append(cats[h.Category], h) } - sess.WriteLine("\nCommands:") + unicode := true + if p, _ := sess.Player.(*player.Player); p != nil { + unicode = p.OptionBool("unicode") + } + + sess.WriteLine("") for _, cat := range catOrder { - sess.WriteLine(fmt.Sprintf("\n %s:", cat)) + t := &Table{Title: cat} for _, h := range cats[cat] { - sess.WriteLine(fmt.Sprintf(" %-12s - %s", h.Name, firstLine(h.Content))) + t.Rows = append(t.Rows, []string{h.Name, firstLine(h.Content)}) + } + for _, line := range t.Render(unicode) { + sess.WriteLine(line) } + sess.WriteLine("") } - sess.WriteLine("\n Use 'help ' for details.") + sess.WriteLine("Use 'help ' for details.") return } -- cgit v1.2.3