aboutsummaryrefslogtreecommitdiff
path: root/internal/game/cmd_symbol.go
diff options
context:
space:
mode:
authorhistoria <[not public]>2026-06-22 04:24:11 -0400
committerhistoria <[not public]>2026-06-22 04:24:11 -0400
commit5b9a75a1520a198c9c6b1f1f55e05c9f4aab5629 (patch)
tree18f500ca3492ba206a3f66e2f01146b05a1675b2 /internal/game/cmd_symbol.go
parent7f07c7236578e1a7bcef0282ff9d7f5bf8c7c045 (diff)
downloadthehouseoficarus-5b9a75a1520a198c9c6b1f1f55e05c9f4aab5629.tar.gz
feat: map now only reveals with exploration. players can set custom map symbols.
Diffstat (limited to 'internal/game/cmd_symbol.go')
-rw-r--r--internal/game/cmd_symbol.go91
1 files changed, 91 insertions, 0 deletions
diff --git a/internal/game/cmd_symbol.go b/internal/game/cmd_symbol.go
new file mode 100644
index 0000000..ec8d68b
--- /dev/null
+++ b/internal/game/cmd_symbol.go
@@ -0,0 +1,91 @@
+package game
+
+import (
+ "fmt"
+ "strings"
+ "unicode/utf8"
+
+ "thehouseoficarus/internal/color"
+ "thehouseoficarus/internal/net"
+ "thehouseoficarus/internal/player"
+)
+
+func (g *Game) executeSymbol(sess *net.Session, args []string, rawInput string) {
+ p := sess.Player
+ if len(args) == 0 {
+ data, ok := p.MapSymbols[p.RoomID]
+ if !ok {
+ sess.WriteLine("No custom symbol set for this room.")
+ return
+ }
+ msg := fmt.Sprintf("Custom symbol: %s", data.Char)
+ if data.Color != "" {
+ spec := color.Parse(data.Color)
+ colored := color.Render(g.colorMode(sess), spec, data.Char)
+ msg = fmt.Sprintf("Custom symbol: %s (%s)", colored, data.Color)
+ }
+ sess.WriteLine(msg)
+ return
+ }
+
+ // ponytail: extract symbol char from rawInput to preserve case, since
+ // handleGameCommand lowercases args before dispatch (same pattern as say).
+ char := args[0]
+ if idx := strings.Index(strings.ToLower(rawInput), "symbol"); idx >= 0 {
+ rest := strings.TrimSpace(rawInput[idx+6:])
+ if space := strings.Index(rest, " "); space >= 0 {
+ char = rest[:space]
+ } else {
+ char = rest
+ }
+ }
+
+ cleared := false
+ if strings.EqualFold(char, "clear") || strings.EqualFold(char, "remove") {
+ delete(p.MapSymbols, p.RoomID)
+ if err := g.AccountStore.SaveCharacter(p); err != nil {
+ sess.WriteLine("Error saving: " + err.Error())
+ return
+ }
+ sess.WriteLine("Custom symbol cleared for this room.")
+ cleared = true
+ }
+
+ if !cleared {
+ r, size := utf8.DecodeRuneInString(char)
+ if size == 0 || size != len(char) || r == utf8.RuneError {
+ sess.WriteLine("Usage: symbol <single character> [color...]")
+ return
+ }
+
+ colorSpec := ""
+ if len(args) > 1 {
+ colorSpec = strings.Join(args[1:], " ")
+ if colorSpec != "" {
+ spec := color.Parse(colorSpec)
+ if spec.Empty() {
+ sess.WriteLine("Invalid color spec. Use a color number like 232 and/or bold/dim/underline.")
+ return
+ }
+ }
+ }
+
+ p.MapSymbols[p.RoomID] = player.MapSymbolData{
+ Char: char,
+ Color: colorSpec,
+ }
+
+ if err := g.AccountStore.SaveCharacter(p); err != nil {
+ sess.WriteLine("Error saving: " + err.Error())
+ return
+ }
+
+ msg := fmt.Sprintf("Map symbol set to: %s", char)
+ if colorSpec != "" {
+ spec := color.Parse(colorSpec)
+ colored := color.Render(g.colorMode(sess), spec, char)
+ msg = fmt.Sprintf("Map symbol set to: %s", colored)
+ }
+ sess.WriteLine(msg)
+ }
+}