horsegen: generate group -> skills relation
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user