aboutsummaryrefslogtreecommitdiff
path: root/internal/game/cmd_description.go
blob: 68758402c98f3681fe28e8d79891f3b64c26709c (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
package game

import (
	"fmt"

	"thirdcollapse/internal/net"
	"thirdcollapse/internal/player"
)

func (g *Game) doDescription(sess *net.Session) {
	p := sess.Player.(*player.Player)
	sess.WriteLine("")
	if p.Description != "" {
		sess.WriteLine(fmt.Sprintf("Current description: %s", p.Description))
	} else {
		sess.WriteLine("You don't have a description set.")
	}
	sess.WriteLine("")
	sess.Write("Enter a new description (or press enter to keep current): ")
	sess.State = net.StateChangeDescription
}

func (g *Game) handleDescriptionChange(sess *net.Session, input string) {
	if input != "" {
		p := sess.Player.(*player.Player)
		p.Description = input
		g.AccountStore.SaveCharacter(p)
		sess.WriteLine(fmt.Sprintf("Description set to: %s", input))
	} else {
		sess.WriteLine("Description left unchanged.")
	}
	sess.State = net.StateGame
	sess.Write("\r\n> ")
}