aboutsummaryrefslogtreecommitdiff
path: root/internal/game/cmd_skills.go
blob: 2f9f52e22317d009bff2f6db8a2563225b7551e3 (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
package game

import (
	"strconv"

	"thehouseoficarus/internal/color"
	"thehouseoficarus/internal/net"
	"thehouseoficarus/internal/player"
	"thehouseoficarus/internal/ui"
)

func (g *Game) executeSkills(sess *net.Session, args []string, rawInput string) {
	g.doSkills(sess)
}

func (g *Game) doSkills(sess *net.Session) {
	p := sess.Player
	mode := g.colorMode(sess)
	hLabel := g.resolveConstant(sess, "table_header_label")
	hDetail := g.resolveConstant(sess, "table_header_detail")
	hValue := g.resolveConstant(sess, "table_header_value")
	hXP := g.resolveConstant(sess, "table_header_xp")
	t := &ui.Table{Title: "Skills", Columns: []string{
		color.Render(mode, hLabel, "Skill"),
		color.Render(mode, hDetail, "Abbr"),
		color.Render(mode, hValue, "Level"),
		color.Render(mode, hXP, "XP"),
		color.Render(mode, hXP, "XP to Next"),
	}}
	for _, s := range player.AllSkills {
		level := p.Level(s)
		xp := p.Skills[s]
		next := player.XPForNextLevel(xp)
		t.Rows = append(t.Rows, []string{
			color.Render(mode, hLabel, string(s)),
			color.Render(mode, hDetail, player.SkillAbbr[s]),
			color.Render(mode, hValue, strconv.Itoa(level)),
			color.Render(mode, hXP, strconv.Itoa(xp)),
			color.Render(mode, hXP, strconv.Itoa(next)),
		})
	}
	for _, line := range t.Render(p.OptionBool("unicode"), p.OptionInt("wrap_width")) {
		sess.WriteLine(line)
	}
}