blob: 110d08c74b5ef68f04db5d40b1f72bed8cb154c8 (
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
package game
import (
"fmt"
"strings"
"thehouseoficarus/internal/net"
)
func (g *Game) executePrompt(sess *net.Session, args []string, rawInput string) {
if len(args) == 0 {
g.doPrompt(sess, "")
} else {
msgStart := strings.Index(strings.ToLower(rawInput), "prompt ") + 7
if msgStart >= 7 && msgStart < len(rawInput) {
g.doPrompt(sess, rawInput[msgStart:])
} else {
g.doPrompt(sess, strings.Join(args, " "))
}
}
}
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)
sess.WriteLine("Prompt reset to default.")
return
}
if input == "none" {
p.Prompt = ""
g.AccountStore.SaveCharacter(p)
sess.WriteLine("Prompt set to blank.")
return
}
p.Prompt = input
g.AccountStore.SaveCharacter(p)
sess.WriteLine(fmt.Sprintf("Prompt set to: %s", input))
}
|