Files
gogobee/internal/plugin/combat_narrative_drain_test.go
prosolis 2ce56cf76a Combat narration: format magnitude for stat_drain/debuff/ally_buff
These three stateful enemy-effect cases emitted their flavor pool via bare
pickRand, leaking the literal %d placeholder to players ("-%d damage on
every strike from here"). The magnitude is carried in CombatEvent.Damage,
exactly like the already-correct max_hp_drain / spell_fizzle cases; wrap
them in fmt.Sprintf. Add a regression test asserting no placeholder leaks.
2026-05-22 09:26:17 -07:00

25 lines
925 B
Go

package plugin
import (
"strings"
"testing"
)
// TestRenderEvent_StatefulDrainsFormatMagnitude is a regression test for the
// leaked "%d" in stateful enemy-effect narration. stat_drain, debuff and
// ally_buff carry their magnitude in CombatEvent.Damage and their flavor
// pools contain a %d placeholder; renderEvent must fmt.Sprintf them rather
// than emit the template raw (which surfaced "-%d damage" to players).
func TestRenderEvent_StatefulDrainsFormatMagnitude(t *testing.T) {
for _, action := range []string{"stat_drain", "debuff", "ally_buff"} {
e := CombatEvent{Actor: "enemy", Action: action, Damage: 4}
out := renderEvent(e, "Rurina", "Shadow", CombatResult{}, newActionPicker())
if strings.Contains(out, "%") {
t.Errorf("%s: leaked format placeholder in output: %q", action, out)
}
if !strings.Contains(out, "4") {
t.Errorf("%s: expected magnitude 4 in output: %q", action, out)
}
}
}