aboutsummaryrefslogtreecommitdiff
path: root/internal/game/cmd_prompt.go
blob: 8850ea18457c1e67238cdf2b9df13979a6c31664 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package game

import (
	"fmt"

	"thehouseoficarus/internal/net"
)

func (g *Game) doPrompt(sess *net.Session, input string) {
	p := sess.Player

	if input == "" {
		prompt := p.Prompt
		if prompt == "" {
			prompt = "> "
		}
		sess.WriteLine(fmt.Sprintf("\nPrompt: %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)
		sess.WriteLine("\nPrompt reset to default.")
		return
	}

	if input == "none" {
		p.Prompt = " "
		g.AccountStore.SaveCharacter(p)
		sess.WriteLine("\nPrompt set to blank.")
		return
	}

	p.Prompt = input
	g.AccountStore.SaveCharacter(p)
	sess.WriteLine(fmt.Sprintf("\nPrompt set to: %s", input))
}