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
|
package game
import (
"fmt"
"thehouseoficarus/internal/net"
"thehouseoficarus/internal/ui"
)
func (g *Game) dmgDisplay(sess *net.Session, dmg int) string {
if sess.Player != nil && sess.Player.OptionBool("unicode") {
return fmt.Sprintf("\U0001FB38 %d \U0001FB34", dmg)
}
return fmt.Sprintf("> %d <", dmg)
}
func (g *Game) renderBar(sess *net.Session, current, max, lowColor 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 = 108
case pct >= 40:
fgColor = 179
default:
fgColor = lowColor
}
unicode := sess.Player != nil && sess.Player.OptionBool("unicode")
style := &ui.BarStyle{FilledColor: fgColor, EmptyColor: 237, EmptyDim: true}
bar := ui.RenderColoredBar(current, max, 10, unicode, style, g.colorMode(sess))
return "[" + bar + "]"
}
func (g *Game) hpBar(sess *net.Session, current, max int) string {
return g.renderBar(sess, current, max, 167)
}
|