aboutsummaryrefslogtreecommitdiff
path: root/internal/game/render_color.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/game/render_color.go')
-rw-r--r--internal/game/render_color.go43
1 files changed, 36 insertions, 7 deletions
diff --git a/internal/game/render_color.go b/internal/game/render_color.go
index 3464f26..958b671 100644
--- a/internal/game/render_color.go
+++ b/internal/game/render_color.go
@@ -42,24 +42,53 @@ func (g *Game) colorize(sess *net.Session, category, text string) string {
return color.Render(g.colorMode(sess), spec, text)
}
-func levelColorSpec(myLevel, theirLevel int) color.ColorSpec {
+// resolveConstant returns the live spec for a constant (player-invisible)
+// color category. Unlike resolveColor, it never consults the account's
+// per-player override map — constants are admin-tunable only — so players
+// have no way to change them. Falls back through the file's constant_colors
+// map, then to the built-in DefaultConstantColors.
+func (g *Game) resolveConstant(sess *net.Session, category string) color.ColorSpec {
+ if g.ConstantColorConfig != nil {
+ if val, ok := (*g.ConstantColorConfig)[category]; ok && val != "" {
+ return color.Parse(val)
+ }
+ }
+ if val, ok := config.DefaultConstantColors()[category]; ok && val != "" {
+ return color.Parse(val)
+ }
+ return color.NoColor()
+}
+
+// colorizeConstant paints text with a constant color spec, bypassing the
+// player override tier entirely.
+func (g *Game) colorizeConstant(sess *net.Session, category, text string) string {
+ spec := g.resolveConstant(sess, category)
+ return color.Render(g.colorMode(sess), spec, text)
+}
+
+// levelColorSpec returns the color spec for the level-difference band shown
+// next to mob/player levels (green/red/white by how far the target is from
+// the viewer). Uses admin-tunable constant_colors; falls back to built-ins.
+func (g *Game) levelColorSpec(sess *net.Session, myLevel, theirLevel int) color.ColorSpec {
diff := theirLevel - myLevel
+ var name string
switch {
case diff == 0:
- return color.Parse("FA")
+ name = "level_diff_equal"
case diff > 0 && diff < 5:
- return color.Parse("B3")
+ name = "level_diff_up_small"
case diff >= 5:
- return color.Parse("A7")
+ name = "level_diff_up_big"
case diff < 0 && diff > -5:
- return color.Parse("6E")
+ name = "level_diff_down_small"
default:
- return color.Parse("41")
+ name = "level_diff_down_big"
}
+ return g.resolveConstant(sess, name)
}
func (g *Game) levelColorize(sess *net.Session, myLevel, theirLevel int, text string) string {
- spec := levelColorSpec(myLevel, theirLevel)
+ spec := g.levelColorSpec(sess, myLevel, theirLevel)
return color.Render(g.colorMode(sess), spec, text)
}