From 15b7e221b799ef107dec44ecdb294026dfd3d059 Mon Sep 17 00:00:00 2001 From: historia <[not public]> Date: Wed, 24 Jun 2026 22:55:35 -0400 Subject: refactor: pulled techs out to yaml files, unified numerous combat functions, broke up game object --- internal/game/ui_xpdrop.go | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 internal/game/ui_xpdrop.go (limited to 'internal/game/ui_xpdrop.go') diff --git a/internal/game/ui_xpdrop.go b/internal/game/ui_xpdrop.go new file mode 100644 index 0000000..a9bff23 --- /dev/null +++ b/internal/game/ui_xpdrop.go @@ -0,0 +1,31 @@ +package game + +import ( + "fmt" + "strings" + + "thehouseoficarus/internal/net" + "thehouseoficarus/internal/player" +) + +// formatXpDrop returns the colored XP-drop suffix for a slice of gains, or "" +// if xp_drops are disabled or there are no gains. +func (g *Game) formatXpDrop(sess *net.Session, p *player.Player, gains []xpGain) string { + if !p.OptionBool("xp_drops") || len(gains) == 0 { + return "" + } + var parts []string + for _, gain := range gains { + parts = append(parts, fmt.Sprintf("+%dxp %s", gain.XP, player.SkillAbbr[player.SkillName(gain.Skill)])) + } + return g.colorize(sess, "xp", " ("+strings.Join(parts, ", ")+")") +} + +// formatXpDropSingle returns the colored XP-drop suffix for a single skill, or "" +// if xp_drops are disabled or xp is 0. +func (g *Game) formatXpDropSingle(sess *net.Session, p *player.Player, skill player.SkillName, xp int) string { + if !p.OptionBool("xp_drops") || xp <= 0 { + return "" + } + return g.colorize(sess, "xp", fmt.Sprintf(" (+%dxp %s)", xp, player.SkillAbbr[skill])) +} -- cgit v1.2.3