mirror of
https://github.com/prosolis/gogobee.git
synced 2026-07-15 16:42:41 +00:00
The audit plan flagged jargon leaks in the SRD spell prose surfaced by
!cast and !spellbook. Verifying against HEAD turned up two corrections
to the plan's framing:
- The overlay in dnd_spells_data.go wins on ID collision, so for the
~76 hand-authored spells the *overlay* Descriptions are what players
actually see — and those were crunchier than the SRD ("Heal 1d8 +
WIS mod HP. Touch.", "8d6 fire in 20 ft radius. DEX save half.",
etc.). Touching only the generated SRD file would have missed the
bigger leak.
- The Upcast field is never displayed at runtime (only the import
generator reads it), so testing it against the regex would test
dead data.
So this commit:
- rewrites every overlay Description into playful, jargon-free flavor
in the charm_person voice ("Sweet-talk a humanoid…") — no dice, no
saves, no AC math, no ability-mod references
- adds 31 overlay shims for SRD-only spells whose generated text was
broken (placeholder gaps from the Open5e classifier — "no larger
than a.", "up to to", "in a in range"), empty ("You touch a
creature."), typo-laden ("magicou", "undeadou", "diseasesou"), or
jargon-heavy (false_life's "1d4+4 temporary hit points")
- adds TestSpellDescriptionsAreJargonFree, a regex sweep over the
merged registry that bans "saving throw", "spell slot of",
"ability modifier", "hit points equal to", and \bNdN\b dice
notation. Currently passing; will fail-loud on regressions or new
SRD imports that need overlay shims.
The generated dnd_spells_srd_data.go is left untouched — overlay is
the regen-safe surface per its own header comment.
46 lines
1.6 KiB
Go
46 lines
1.6 KiB
Go
package plugin
|
|
|
|
import (
|
|
"regexp"
|
|
"testing"
|
|
)
|
|
|
|
// TestSpellDescriptionsAreJargonFree scans every reachable spell Description
|
|
// in the merged registry (SRD + hand-authored overlay) for D&D jargon that
|
|
// leaks into player-facing chat via dnd_cast.go's !cast confirmation and the
|
|
// !spellbook list view. Per feedback_accessibility_over_dnd_crunch, the
|
|
// player surface should be verb/outcome-led — no math, no dice, no saves.
|
|
//
|
|
// Failures usually mean either (a) a new SRD entry was added without an
|
|
// overlay shim in dnd_spells_data.go, or (b) an overlay Description was
|
|
// edited back into crunch. Fix in dnd_spells_data.go; do NOT touch the
|
|
// generated dnd_spells_srd_data.go directly (it's regenerated from Open5e).
|
|
//
|
|
// Upcast strings are NOT tested — they're never displayed (grep
|
|
// `\.Upcast` across the codebase to confirm; only the import generator
|
|
// reads them as of 2026-05-15).
|
|
func TestSpellDescriptionsAreJargonFree(t *testing.T) {
|
|
bans := []struct {
|
|
name string
|
|
re *regexp.Regexp
|
|
}{
|
|
{"saving throw", regexp.MustCompile(`(?i)saving throw`)},
|
|
{"spell slot of", regexp.MustCompile(`(?i)spell slot of`)},
|
|
{"ability modifier", regexp.MustCompile(`(?i)ability modifier`)},
|
|
{"hit points equal to", regexp.MustCompile(`(?i)hit points equal to`)},
|
|
{"NdN dice notation", regexp.MustCompile(`\b\d+d\d+\b`)},
|
|
}
|
|
|
|
for id, s := range dndSpellRegistry {
|
|
if s.Description == "" {
|
|
continue
|
|
}
|
|
for _, b := range bans {
|
|
if b.re.MatchString(s.Description) {
|
|
t.Errorf("spell %q Description leaks %q jargon: %q",
|
|
id, b.name, s.Description)
|
|
}
|
|
}
|
|
}
|
|
}
|