blob: 3596ebf147458ba21a5802b75a67e0199e560885 (
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
|
package game
import (
"fmt"
"strings"
"thehouseoficarus/internal/net"
)
func (g *Game) executePrompt(sess *net.Session, args []string, rawInput string) {
if len(args) == 0 {
g.doHelp(sess, "prompt")
} 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 == "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))
}
|