diff options
| author | historia <[not public]> | 2026-06-16 01:59:27 -0400 |
|---|---|---|
| committer | historia <[not public]> | 2026-06-16 01:59:27 -0400 |
| commit | 43f21aabae8924f35c12c8485e690aeefe0089fb (patch) | |
| tree | b5fbadb89df3cf4ffec86503bb8e2d7e52b27454 /internal/game/game.go | |
| parent | 4cc1ddcd185509080b4b3e15d1646567edd51c9d (diff) | |
| download | thehouseoficarus-43f21aabae8924f35c12c8485e690aeefe0089fb.tar.gz | |
feat: overhauled ansi color, added prompt options
Diffstat (limited to 'internal/game/game.go')
| -rw-r--r-- | internal/game/game.go | 19 |
1 files changed, 7 insertions, 12 deletions
diff --git a/internal/game/game.go b/internal/game/game.go index 3c00d7e..456419f 100644 --- a/internal/game/game.go +++ b/internal/game/game.go @@ -9,6 +9,7 @@ import ( "thirdcollapse/internal/action" "thirdcollapse/internal/combat" + "thirdcollapse/internal/config" "thirdcollapse/internal/engine" "thirdcollapse/internal/net" "thirdcollapse/internal/object" @@ -42,6 +43,7 @@ type Game struct { Hub *net.Hub Ticks *engine.Engine WorldFlags map[string]any + ColorConfig *config.ColorsConfig dataDir string restTimers map[string]uint64 charsMu sync.Mutex @@ -52,7 +54,7 @@ type Game struct { pendingDepletions []pendingDepletion } -func New(dataDir string) *Game { +func New(dataDir string, colorConfig *config.ColorsConfig) *Game { return &Game{ World: world.New(dataDir), ObjectStore: object.NewObjectStore(dataDir), @@ -62,6 +64,7 @@ func New(dataDir string) *Game { BehaviorStore: action.NewStore(dataDir), Ticks: engine.New(), WorldFlags: make(map[string]any), + ColorConfig: colorConfig, dataDir: dataDir, restTimers: make(map[string]uint64), loggedInChars: make(map[string]*net.Session), @@ -123,7 +126,7 @@ func classifyCommand(cmd string) CommandClass { case "say", "score", "sc", "inventory", "i", "inv", "equipment", "eq", "look", "l", "exits", "help", "map", "option", "options", "alias", "unalias", - "description", "desc", "queued": + "description", "desc", "queued", "color", "colors": return ClassInstant case "wear", "wield", "remove", "unwear", "unwield", "style": return ClassFree @@ -140,16 +143,6 @@ func classifyCommand(cmd string) CommandClass { return ClassUnknown } -func (g *Game) promptStr(sess *net.Session) string { - prompt := "> " - if p, ok := sess.Player.(*player.Player); ok && p != nil { - if custom := p.OptionString("prompt"); custom != "" { - prompt = custom - } - } - return g.colorTag(sess, prompt) -} - func (g *Game) writePrompt(sess *net.Session) { sess.Write("\r\n" + g.promptStr(sess)) } @@ -307,6 +300,8 @@ func (g *Game) executeCommand(sess *net.Session, cmd string, args []string, rawI g.doDescription(sess) case "option", "options": g.doOption(sess, strings.Join(args, " ")) + case "color", "colors": + g.doColor(sess, strings.Join(args, " ")) case "exits": g.doExits(sess) case "map": |
