diff options
| author | historia <[not public]> | 2026-06-27 02:49:01 -0400 |
|---|---|---|
| committer | historia <[not public]> | 2026-06-27 02:49:01 -0400 |
| commit | 1cab9ca20e24742f770a676f84e4ed9f1636f297 (patch) | |
| tree | aad74b0f365515d971dc3ae8c0e79e0541015561 /internal | |
| parent | 6f3d21d6e7f01155ce0c461857a053b43d329392 (diff) | |
| download | thehouseoficarus-1cab9ca20e24742f770a676f84e4ed9f1636f297.tar.gz | |
feat: exits added to prompt
Diffstat (limited to 'internal')
| -rw-r--r-- | internal/game/cmd_prompt.go | 12 | ||||
| -rw-r--r-- | internal/game/render_prompt.go | 19 |
2 files changed, 20 insertions, 11 deletions
diff --git a/internal/game/cmd_prompt.go b/internal/game/cmd_prompt.go index 110d08c..3596ebf 100644 --- a/internal/game/cmd_prompt.go +++ b/internal/game/cmd_prompt.go @@ -9,7 +9,7 @@ import ( func (g *Game) executePrompt(sess *net.Session, args []string, rawInput string) { if len(args) == 0 { - g.doPrompt(sess, "") + g.doHelp(sess, "prompt") } else { msgStart := strings.Index(strings.ToLower(rawInput), "prompt ") + 7 if msgStart >= 7 && msgStart < len(rawInput) { @@ -23,16 +23,6 @@ func (g *Game) executePrompt(sess *net.Session, args []string, rawInput string) func (g *Game) doPrompt(sess *net.Session, input string) { p := sess.Player - if input == "" { - prompt := p.Prompt - if prompt == "" { - prompt = "> " - } - sess.WriteLine(fmt.Sprintf("Prompt: %s", prompt)) - sess.WriteLine("Use 'prompt <value>' to change. Use 'prompt none' for blank. Use 'prompt reset' to restore default.") - return - } - if input == "reset" { p.Prompt = "> " g.AccountStore.SaveCharacter(p) diff --git a/internal/game/render_prompt.go b/internal/game/render_prompt.go index 7d3fafd..b992c8c 100644 --- a/internal/game/render_prompt.go +++ b/internal/game/render_prompt.go @@ -7,6 +7,7 @@ import ( "thehouseoficarus/internal/color" "thehouseoficarus/internal/net" "thehouseoficarus/internal/player" + "thehouseoficarus/internal/world" ) func (g *Game) promptStr(sess *net.Session) string { @@ -51,6 +52,24 @@ func (g *Game) expandPromptVars(sess *net.Session, text string) string { text = strings.ReplaceAll(text, "%m", mobHP) text = strings.ReplaceAll(text, "%M", mobMaxHP) + allExits, openExits := "", "" + if room, err := g.World.LoadRoom(p.RoomID); err == nil { + for _, dir := range world.ExitOrder { + exitDef, ok := room.Exits[dir] + if !ok { + continue + } + letter := strings.ToUpper(string(dir)[:1]) + allExits += letter + if exitDef.Condition != nil && !g.checkCondition(sess, exitDef.Condition) { + continue + } + openExits += letter + } + } + text = strings.ReplaceAll(text, "%E", allExits) + text = strings.ReplaceAll(text, "%e", openExits) + for _, sk := range player.AllSkills { tag := string(sk) text = strings.ReplaceAll(text, "%X_"+tag, fmt.Sprint(p.Skills[sk])) |
