horsegen: generate data per region

This commit is contained in:
2026-01-15 13:43:54 -05:00
parent 5b5e008b5e
commit d6fb4b6caf
16 changed files with 1287 additions and 2261 deletions

View File

@@ -26,7 +26,7 @@ func LoadTemplates() (*template.Template, error) {
// ExecCharacter renders the Koka character module to kk and the Go character file to g.
// If either is nil, it is skipped.
func ExecCharacter(t *template.Template, kk, g io.Writer, c []NamedID[Character], pairs, trios []AffinityRelation) error {
func ExecCharacter(t *template.Template, region string, kk, g io.Writer, c []NamedID[Character], pairs, trios []AffinityRelation) error {
if len(pairs) != len(c)*len(c) {
return fmt.Errorf("there are %d pairs but there must be %d for %d characters", len(pairs), len(c)*len(c), len(c))
}
@@ -53,6 +53,7 @@ func ExecCharacter(t *template.Template, kk, g io.Writer, c []NamedID[Character]
}
data := struct {
Region string
Characters []NamedID[Character]
Pairs []AffinityRelation
Trios []AffinityRelation
@@ -60,7 +61,7 @@ func ExecCharacter(t *template.Template, kk, g io.Writer, c []NamedID[Character]
TrioMaps map[int]map[int]map[int]int
Count int
MaxID int
}{c, pairs, trios, pm, tm, len(c), maxid}
}{region, c, pairs, trios, pm, tm, len(c), maxid}
var err error
if kk != nil {
err = errors.Join(t.ExecuteTemplate(kk, "koka-character", &data))
@@ -71,7 +72,7 @@ func ExecCharacter(t *template.Template, kk, g io.Writer, c []NamedID[Character]
return err
}
func ExecSkill(t *template.Template, kk, g io.Writer, groups []NamedID[SkillGroup], skills []Skill) error {
func ExecSkill(t *template.Template, region string, kk, g io.Writer, groups []NamedID[SkillGroup], skills []Skill) error {
m := make(map[int][]Skill, len(groups))
u := make(map[int]int, len(groups))
for _, t := range skills {
@@ -88,10 +89,11 @@ func ExecSkill(t *template.Template, kk, g io.Writer, groups []NamedID[SkillGrou
}
}
data := struct {
Region string
Groups []NamedID[SkillGroup]
Skills []Skill
Related map[int][]Skill
}{groups, skills, m}
}{region, groups, skills, m}
var err error
if kk != nil {
err = errors.Join(t.ExecuteTemplate(kk, "koka-skill", &data))
@@ -102,11 +104,12 @@ func ExecSkill(t *template.Template, kk, g io.Writer, groups []NamedID[SkillGrou
return err
}
func ExecSkillGroupKK(t *template.Template, w io.Writer, g []NamedID[SkillGroup], s []Skill) error {
func ExecSkillGroupKK(t *template.Template, region string, w io.Writer, g []NamedID[SkillGroup], s []Skill) error {
data := struct {
Region string
Groups []NamedID[SkillGroup]
Skills []Skill
}{g, s}
}{region, g, s}
return t.ExecuteTemplate(w, "koka-skill-group", &data)
}