aboutsummaryrefslogtreecommitdiff
path: root/internal/game/cmd_skills.go
blob: 2eeb14923bb5f5b4da291a96627f39a099a5fdc0 (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
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)
	t := &ui.Table{Title: "Skills", Columns: []string{
		color.Render(mode, color.Parse("49"), "Skill"),
		color.Render(mode, color.Parse("F5"), "Abbr"),
		color.Render(mode, color.Parse("FA"), "Level"),
		color.Render(mode, color.Parse("B3"), "XP"),
		color.Render(mode, color.Parse("B3"), "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, color.Parse("49"), string(s)),
			color.Render(mode, color.Parse("F5"), player.SkillAbbr[s]),
			color.Render(mode, color.Parse("FA"), strconv.Itoa(level)),
			color.Render(mode, color.Parse("B3"), strconv.Itoa(xp)),
			color.Render(mode, color.Parse("B3"), strconv.Itoa(next)),
		})
	}
	for _, line := range t.Render(p.OptionBool("unicode"), p.OptionInt("wrap_width")) {
		sess.WriteLine(line)
	}
}