horsegen: generate group -> skills relation

This commit is contained in:
2026-01-11 15:08:26 -05:00
parent 399f160718
commit be41389006
3 changed files with 278 additions and 3 deletions

View File

@@ -62,10 +62,26 @@ func ExecCharacterKK(t *template.Template, w io.Writer, c []NamedID[Character],
}
func ExecSkillKK(t *template.Template, w io.Writer, g []NamedID[SkillGroup], s []Skill) error {
m := make(map[int][]Skill, len(g))
u := make(map[int]int, len(g))
for _, t := range s {
m[t.GroupID] = append(m[t.GroupID], t)
if t.Rarity >= 4 {
// Add inheritable uniques to u so we can add inherited versions to groups.
u[t.ID] = t.GroupID
}
}
// Now that u is set up, iterate through again and add in inherited skills.
for _, t := range s {
if t.InheritID != 0 {
m[u[t.InheritID]] = append(m[u[t.InheritID]], t)
}
}
data := struct {
Groups []NamedID[SkillGroup]
Skills []Skill
}{g, s}
Groups []NamedID[SkillGroup]
Skills []Skill
Related map[int][]Skill
}{g, s, m}
return t.ExecuteTemplate(w, "koka-skill", &data)
}