diff options
| author | historia <[not public]> | 2026-06-19 18:20:26 -0400 |
|---|---|---|
| committer | historia <[not public]> | 2026-06-19 18:20:26 -0400 |
| commit | 0ea4eec5dd2122c6704216971eb1249276297867 (patch) | |
| tree | 430fbbef04e837820f1d031c190f52ecd6112e25 /internal/game/cmd_mods.go | |
| parent | 3a58125d14bb307f861b38c6c5b0a63babde7e08 (diff) | |
| download | thehouseoficarus-0ea4eec5dd2122c6704216971eb1249276297867.tar.gz | |
shop fixes, 'toggle' completely removed, movement speed increased
Diffstat (limited to 'internal/game/cmd_mods.go')
| -rw-r--r-- | internal/game/cmd_mods.go | 109 |
1 files changed, 48 insertions, 61 deletions
diff --git a/internal/game/cmd_mods.go b/internal/game/cmd_mods.go index b9161e3..65d7ad7 100644 --- a/internal/game/cmd_mods.go +++ b/internal/game/cmd_mods.go @@ -3,109 +3,96 @@ 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) +func (g *Game) doMods(sess *net.Session, showAll bool) { + p := sess.Player sciLevel := p.Level(player.Science) + mode := g.colorMode(sess) 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 + var catMods []*ModDef for _, m := range AllMods { - if m.Category == cat.Cat && m.Level <= sciLevel { - mods = append(mods, m) + if m.Category != cat.Cat { + continue + } + if !showAll && m.Level > sciLevel { + continue } + catMods = append(catMods, m) } - if len(mods) == 0 { + if len(catMods) == 0 { continue } + anyMods = true - sort.Slice(mods, func(i, j int) bool { - return mods[i].Level < mods[j].Level + sort.Slice(catMods, func(i, j int) bool { + return catMods[i].Level < catMods[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"), - }} + t := &Table{ + Title: cat.Name, + Columns: []string{ + color.Render(mode, color.Parse("75"), "Module"), + color.Render(mode, color.Parse("245"), "Level"), + color.Render(mode, color.Parse("222"), "Cost"), + color.Render(mode, color.Parse("179"), "XP"), + }, + } + + for _, m := range catMods { + unlocked := m.Level <= sciLevel + levelStr := fmt.Sprintf("Lv %d", m.Level) + costStr := g.junkCostString(p, m) + xpStr := fmt.Sprintf("%d XP", m.BaseXP) - 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) + if unlocked { + t.Rows = append(t.Rows, []string{ + color.Render(mode, color.Parse("75"), m.Name), + color.Render(mode, color.Parse("245"), levelStr), + color.Render(mode, color.Parse("222"), costStr), + color.Render(mode, color.Parse("179"), xpStr), + }) + } else { + t.Rows = append(t.Rows, []string{ + g.colorize(sess, "dim", m.Name), + g.colorize(sess, "dim", levelStr), + g.colorize(sess, "dim", costStr), + g.colorize(sess, "dim", xpStr), + }) } - 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 + sess.WriteLine("") } if !anyMods { - sess.WriteLine("You don't know any mods yet. Train Science to unlock mods.") + sess.WriteLine("No modules found.") } - if p.AutocastMod != "" { - mod := GetMod(p.AutocastMod) + if p.AutotriggerMod != "" { + mod := GetMod(p.AutotriggerMod) 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) + sess.WriteLine(fmt.Sprintf("Autotrigger: %s", g.colorize(sess, "science_mod", mod.Name))) } } - return strings.Join(parts, ", ") } |
