diff options
| author | historia <[not public]> | 2026-06-15 00:55:26 -0400 |
|---|---|---|
| committer | historia <[not public]> | 2026-06-15 00:56:27 -0400 |
| commit | 445c4612cc5cf2c226f85894b6ad1e2419a374e2 (patch) | |
| tree | df3c6d4702cbeb7bd1618f88e93eb9cd08bcfcf4 /internal/game/help.go | |
| parent | b6fdde0aa6fcefd735e7c550aaa7fca879023f1c (diff) | |
| download | thehouseoficarus-445c4612cc5cf2c226f85894b6ad1e2419a374e2.tar.gz | |
feat: walk command, improved tables and columns
Diffstat (limited to 'internal/game/help.go')
| -rw-r--r-- | internal/game/help.go | 19 |
1 files changed, 14 insertions, 5 deletions
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 <command>' for details.") + sess.WriteLine("Use 'help <command>' for details.") return } |
