blob: ef00fd53d3ed74010c7c1d0e028371db3df9801d (
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
|
package game
import "thehouseoficarus/internal/net"
func (g *Game) hpBar(sess *net.Session, current, max int) string {
if max <= 0 {
max = 1
}
if current < 0 {
current = 0
}
if current > max {
current = max
}
pct := float64(current) / float64(max) * 100.0
var fgColor int
switch {
case pct >= 70:
fgColor = 82
case pct >= 40:
fgColor = 220
default:
fgColor = 160
}
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 + "]"
}
|