aboutsummaryrefslogtreecommitdiff
path: root/internal/game/ui_help.go
diff options
context:
space:
mode:
authorworkhorse <workhorse@localhost.localdomain>2026-06-19 20:24:52 -0400
committerworkhorse <workhorse@localhost.localdomain>2026-06-19 20:24:52 -0400
commit8ee8982b8759bcae116647cc993867f4c8b0a6ce (patch)
treeee01f7b1d745cbc94d9981108a1209527487b3e5 /internal/game/ui_help.go
parent2bec24859af8f03c80a0a58e3240519942450167 (diff)
downloadthehouseoficarus-8ee8982b8759bcae116647cc993867f4c8b0a6ce.tar.gz
reorganized items, objects, and rooms in directories. oranized module names. added startup checks.
Diffstat (limited to 'internal/game/ui_help.go')
-rw-r--r--internal/game/ui_help.go152
1 files changed, 152 insertions, 0 deletions
diff --git a/internal/game/ui_help.go b/internal/game/ui_help.go
new file mode 100644
index 0000000..151d1ba
--- /dev/null
+++ b/internal/game/ui_help.go
@@ -0,0 +1,152 @@
+package game
+
+import (
+ "fmt"
+ "path/filepath"
+ "strings"
+
+ "thehouseoficarus/internal/action"
+ "thehouseoficarus/internal/net"
+ "gopkg.in/yaml.v3"
+)
+
+type HelpDef struct {
+ Name string `yaml:"name"`
+ Category string `yaml:"category"`
+ 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"},
+ {"autotrigger / auto", "Instant", "Set a module to auto-trigger"},
+ {"bank", "Active", "Open bank interface"},
+ {"burn", "Active", "Start a fire"},
+ {"chop / cut", "Active", "Chop trees (Woodcutting)"},
+ {"clean", "Free", "Clean grimy herbs (Pharmacy)"},
+ {"color / colors", "Instant", "Customize display colors"},
+ {"colortable", "Instant", "Display color reference chart"},
+ {"construct / make", "Active", "Build furniture (Construction)"},
+ {"cook", "Active", "Cook raw food on a fire or range"},
+ {"craft", "Active", "Craft jewelry (Crafting)"},
+ {"description / desc", "Instant", "Set your character description"},
+ {"drink", "Free", "Drink a potion"},
+ {"drop", "Active", "Drop items to the ground"},
+ {"eat", "Free", "Eat food to restore hitpoints"},
+ {"equipment / eq", "Instant", "Show equipped items"},
+ {"exits", "Instant", "List available exits"},
+ {"farm", "Active", "Farm crops (Farming)"},
+ {"fish", "Active", "Fish at fishing spots (Fishing)"},
+ {"fletch", "Free", "Fletch logs into bows (Fletching)"},
+ {"get / take / pick", "Active", "Pick up items from the ground"},
+ {"help", "Instant", "Show help topics"},
+ {"id / identify", "Active", "Identify herbs (Pharmacy)"},
+ {"inventory / i / inv", "Instant", "Show your inventory"},
+ {"jack / jackin", "Active", "Jack into a terminal (Hacking)"},
+ {"look / l", "Instant", "Look around or examine things"},
+ {"map", "Instant", "Display an ASCII map of the area"},
+ {"mine", "Active", "Mine rocks (Mining)"},
+ {"mix", "Active", "Mix potions (Pharmacy)"},
+ {"mods / modlist", "Instant", "List available science modules"},
+ {"north / south / east / west / up / down", "Active", "Move in a direction"},
+ {"option / options", "Instant", "View or change settings"},
+ {"prompt", "Instant", "Set custom command prompt"},
+ {"pull / push", "Active", "Interact with objects"},
+ {"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"},
+ {"smelt", "Active", "Smelt ore into bars (Smithing)"},
+ {"smith", "Active", "Smith bars into items (Smithing)"},
+ {"sneak", "Instant", "Toggle sneak mode"},
+ {"steal", "Active", "Steal from mobs (Thieving)"},
+ {"stoke", "Active", "Add logs to a fire"},
+ {"style", "Instant", "Change combat style"},
+ {"talk / speak / ask", "Active", "Talk to NPCs"},
+ {"tech", "Instant", "Toggle technology abilities"},
+ {"trigger", "Active", "Trigger a science module"},
+ {"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")
+ var helps []HelpDef
+ action.WalkYAMLDir(dir, func(path, id string, data []byte) error {
+ var h HelpDef
+ if err := yaml.Unmarshal(data, &h); err != nil {
+ return nil
+ }
+ helps = append(helps, h)
+ return nil
+ })
+ return helps, nil
+}
+
+func (g *Game) doHelp(sess *net.Session, topic string) {
+ if topic == "" {
+ unicode := true
+ if p := sess.Player; p != nil {
+ unicode = p.OptionBool("unicode")
+ }
+
+ 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("")
+ 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 <command>' 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
+ }
+
+ topic = strings.ToLower(topic)
+ for _, h := range helps {
+ if strings.ToLower(h.Name) == topic {
+ sess.WriteLine(fmt.Sprintf("\n %s", h.Content))
+ return
+ }
+ }
+ sess.WriteLine(fmt.Sprintf("No help found for '%s'.", topic))
+}
+
+func firstLine(s string) string {
+ if idx := strings.Index(s, "\n"); idx >= 0 {
+ return s[:idx]
+ }
+ return s
+}
+
+func (g *Game) executeHelp(sess *net.Session, args []string, rawInput string) {
+ if len(args) == 0 {
+ g.doHelp(sess, "")
+ } else {
+ g.doHelp(sess, strings.Join(args, " "))
+ }
+}