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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
|
package game
import (
"fmt"
"sort"
"strings"
"thehouseoficarus/internal/color"
"thehouseoficarus/internal/net"
"thehouseoficarus/internal/player"
)
func (g *Game) doMods(sess *net.Session) {
p := sess.Player.(*player.Player)
mode := g.colorMode(sess)
sciLevel := p.Level(player.Science)
categories := []struct {
Name string
Cat ModCategory
}{
{"Combat", ModCombat},
{"Processing", ModProcessing},
{"Utility", ModUtility},
{"Transport", ModTransport},
{"Enchantment", ModEnchant},
}
sess.WriteLine("")
anyMods := false
for _, cat := range categories {
var mods []*ModDef
for _, m := range AllMods {
if m.Category == cat.Cat && m.Level <= sciLevel {
mods = append(mods, m)
}
}
if len(mods) == 0 {
continue
}
sort.Slice(mods, func(i, j int) bool {
return mods[i].Level < mods[j].Level
})
t := &Table{Title: cat.Name + " Mods", Columns: []string{
color.Render(mode, color.Parse("75"), "Mod"),
color.Render(mode, color.Parse("230"), "Lv"),
color.Render(mode, color.Parse("245"), "Cost"),
color.Render(mode, color.Parse("222"), "XP"),
}}
for _, m := range mods {
costStr := g.modCostDisplay(p, m)
xpStr := fmt.Sprintf("%.1f", m.BaseXP)
if m.MaxHit > 0 {
xpStr += fmt.Sprintf(" (max %d)", m.MaxHit)
}
t.Rows = append(t.Rows, []string{
color.Render(mode, color.Parse("75"), m.Name),
color.Render(mode, color.Parse("230"), fmt.Sprint(m.Level)),
color.Render(mode, color.Parse("245"), costStr),
color.Render(mode, color.Parse("222"), xpStr),
})
}
for _, line := range t.Render(p.OptionBool("unicode")) {
sess.WriteLine(line)
}
anyMods = true
}
if !anyMods {
sess.WriteLine("You don't know any mods yet. Train Science to unlock mods.")
}
if p.AutocastMod != "" {
mod := GetMod(p.AutocastMod)
if mod != nil {
sess.WriteLine(fmt.Sprintf("\nAutocast: %s", g.colorize(sess, "science_mod", mod.Name)))
}
}
}
func (g *Game) modCostDisplay(p *player.Player, mod *ModDef) string {
cost := g.effectiveJunkCost(p, mod)
if len(cost) == 0 {
return "free"
}
var parts []string
keys := make([]string, 0, len(cost))
for k := range cost {
keys = append(keys, k)
}
sort.Strings(keys)
for _, itemID := range keys {
qty := cost[itemID]
def, _ := g.ItemStore.Load(itemID)
name := itemID
if def != nil {
name = def.Name
}
if qty > 1 {
parts = append(parts, fmt.Sprintf("%d %s", qty, name))
} else {
parts = append(parts, name)
}
}
return strings.Join(parts, ", ")
}
|