aboutsummaryrefslogtreecommitdiff
path: root/internal/game/cmd_prompt.go
blob: 81c3409b17d036586cccd72783e69f9776b0fa0f (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
package game

import (
	"fmt"

	"thehouseoficarus/internal/net"
	"thehouseoficarus/internal/player"
)

func (g *Game) doPrompt(sess *net.Session, input string) {
	p := sess.Player.(*player.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 reset' to restore default.")
		return
	}

	if input == "reset" {
		p.Prompt = "> "
		g.AccountStore.SaveCharacter(p)
		sess.WriteLine("\nPrompt reset to default.")
		return
	}

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