diff options
| author | historia <[not public]> | 2026-06-21 03:46:25 -0400 |
|---|---|---|
| committer | historia <[not public]> | 2026-06-21 03:46:25 -0400 |
| commit | 84072ffe6365ad57c4976e9272762aa6db41de7e (patch) | |
| tree | d911389fd91e129871c23ec539e67a2666d9f78a /internal/game/ui_combat.go | |
| parent | e4bc2de6e6aa507044a6a75b4c1954974539a857 (diff) | |
| download | thehouseoficarus-84072ffe6365ad57c4976e9272762aa6db41de7e.tar.gz | |
feat: better score output
Diffstat (limited to 'internal/game/ui_combat.go')
| -rw-r--r-- | internal/game/ui_combat.go | 38 |
1 files changed, 5 insertions, 33 deletions
diff --git a/internal/game/ui_combat.go b/internal/game/ui_combat.go index 56de7e8..ef00fd5 100644 --- a/internal/game/ui_combat.go +++ b/internal/game/ui_combat.go @@ -1,12 +1,6 @@ package game -import ( - "math" - "strings" - - "thehouseoficarus/internal/color" - "thehouseoficarus/internal/net" -) +import "thehouseoficarus/internal/net" func (g *Game) hpBar(sess *net.Session, current, max int) string { if max <= 0 { @@ -20,16 +14,6 @@ func (g *Game) hpBar(sess *net.Session, current, max int) string { } pct := float64(current) / float64(max) * 100.0 - filled := int(math.Round(pct / 10.0)) - if filled < 0 { - filled = 0 - } - if filled > 10 { - filled = 10 - } - - mode := g.colorMode(sess) - var fgColor int switch { case pct >= 70: @@ -40,20 +24,8 @@ func (g *Game) hpBar(sess *net.Session, current, max int) string { fgColor = 160 } - fillSpec := color.ColorSpec{Fg: fgColor} - emptySpec := color.ColorSpec{Fg: 238, Dim: true} - - fillChar := "█" - emptyChar := "░" - if sess.Player != nil && !sess.Player.OptionBool("unicode") { - fillChar = "#" - emptyChar = "." - } - - var sb strings.Builder - sb.WriteString("[") - sb.WriteString(color.Render(mode, fillSpec, strings.Repeat(fillChar, filled))) - sb.WriteString(color.Render(mode, emptySpec, strings.Repeat(emptyChar, 10-filled))) - sb.WriteString("]") - return sb.String() + unicode := sess.Player != nil && sess.Player.OptionBool("unicode") + style := &BarStyle{FilledColor: fgColor, EmptyColor: 238, EmptyDim: true} + bar := RenderColoredBar(current, max, 10, unicode, style, g.colorMode(sess)) + return "[" + bar + "]" } |
