blob: d91556a75dd091ba21a5c000956f5449e070eaa2 (
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("\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))
}
|