From 43f21aabae8924f35c12c8485e690aeefe0089fb Mon Sep 17 00:00:00 2001 From: historia <[not public]> Date: Tue, 16 Jun 2026 01:59:27 -0400 Subject: feat: overhauled ansi color, added prompt options --- internal/game/help.go | 87 ++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 62 insertions(+), 25 deletions(-) (limited to 'internal/game/help.go') diff --git a/internal/game/help.go b/internal/game/help.go index 2e9caa4..4d716ad 100644 --- a/internal/game/help.go +++ b/internal/game/help.go @@ -17,6 +17,47 @@ type HelpDef struct { Content string `yaml:"description"` } +type cmdEntry struct { + Name string + Type string + Desc string +} + +var commandList = []cmdEntry{ + {"alias", "Instant", "Create command shortcuts"}, + {"attack / kill", "Active", "Attack a mob"}, + {"burn", "Active", "Start a fire"}, + {"chop / cut", "Active", "Chop trees (Woodcutting)"}, + {"color / colors", "Instant", "Customize display colors"}, + {"description / desc", "Instant", "Set your character description"}, + {"drop", "Active", "Drop items to the ground"}, + {"equipment / eq", "Instant", "Show equipped items"}, + {"exits", "Instant", "List available exits"}, + {"fish", "Active", "Fish at fishing spots (Fishing)"}, + {"get / take / pick", "Active", "Pick up items from the ground"}, + {"help", "Instant", "Show help topics"}, + {"inventory / i / inv", "Instant", "Show your inventory"}, + {"look / l", "Instant", "Look around or examine things"}, + {"map", "Instant", "Display an ASCII map of the area"}, + {"mine", "Active", "Mine rocks (Mining)"}, + {"north / south / east / west / up / down", "Active", "Move in a direction"}, + {"option / options", "Instant", "View or change settings"}, + {"pull / push", "Active", "Toggle levers and switches"}, + {"queued", "Instant", "Show pending tick actions"}, + {"quit", "Active", "Rest and disconnect"}, + {"remove / unwear / unwield", "Free", "Unequip items"}, + {"say", "Instant", "Chat with players in your room"}, + {"score / sc", "Instant", "View your stats and skills"}, + {"search", "Active", "Search items for loot"}, + {"stoke", "Active", "Add logs to a fire"}, + {"style", "Free", "Change combat style"}, + {"talk / speak / ask", "Active", "Talk to NPCs"}, + {"unalias", "Instant", "Remove command shortcuts"}, + {"use", "Active", "Use an object (crafting)"}, + {"walk", "Active", "Pathfind to a room or multi-step walk"}, + {"wear / wield", "Free", "Equip items"}, +} + func LoadHelp(dataDir string) ([]HelpDef, error) { dir := filepath.Join(dataDir, "help") entries, err := os.ReadDir(dir) @@ -43,39 +84,35 @@ func LoadHelp(dataDir string) ([]HelpDef, error) { } func (g *Game) doHelp(sess *net.Session, topic string) { - helps, err := LoadHelp(g.dataDir) - if err != nil || len(helps) == 0 { - sess.WriteLine("No help available.") - return - } - if topic == "" { - cats := make(map[string][]HelpDef) - var catOrder []string - for _, h := range helps { - if _, ok := cats[h.Category]; !ok { - catOrder = append(catOrder, h.Category) - } - cats[h.Category] = append(cats[h.Category], h) - } - unicode := true if p, _ := sess.Player.(*player.Player); p != nil { unicode = p.OptionBool("unicode") } sess.WriteLine("") - for _, cat := range catOrder { - t := &Table{Title: cat} - for _, h := range cats[cat] { - t.Rows = append(t.Rows, []string{h.Name, firstLine(h.Content)}) - } - for _, line := range t.Render(unicode) { - sess.WriteLine(line) - } - sess.WriteLine("") + t := &Table{ + Title: "Commands", + Columns: []string{"Command", "Type", "Description"}, + } + for _, c := range commandList { + t.Rows = append(t.Rows, []string{c.Name, c.Type, c.Desc}) + } + for _, line := range t.Render(unicode) { + sess.WriteLine(line) } - sess.WriteLine("Use 'help ' for details.") + sess.WriteLine("") + sess.WriteLine("Command types: Instant (runs immediately), Free (queued before active),") + sess.WriteLine("Active (replaces current action, queued per tick).") + sess.WriteLine("") + sess.WriteLine("Use 'help ' for detailed usage of a specific command.") + sess.WriteLine("Use 'option' to view and change settings, 'color' to customize colors.") + return + } + + helps, err := LoadHelp(g.dataDir) + if err != nil || len(helps) == 0 { + sess.WriteLine("No help available.") return } -- cgit v1.2.3