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)
|
||||
}
|
||||
|
||||
|
||||
@@ -92,6 +92,13 @@ pub fip fun skill/order2(a: skill, b: skill): order2<skill>
|
||||
pub fun skill/(==)(a: skill, b: skill): bool
|
||||
a.skill-id == b.skill-id
|
||||
|
||||
// Get the skills in a skill group.
|
||||
pub fun skill-group/skills(g: skill-group): list<skill>
|
||||
match g
|
||||
{{- range $g := $.Groups }}
|
||||
{{ kkenum $g.Name }} -> [ {{- range $s := index $.Related $g.ID }}{{ kkenum $s.Name }}{{ if ne $s.InheritID 0 }}-Inherit{{ end }}, {{ end }}]
|
||||
{{- end }}
|
||||
|
||||
// Get complete skill info.
|
||||
pub fun skill/detail(^s: skill): skill-detail
|
||||
match s
|
||||
|
||||
Reference in New Issue
Block a user