Wiki List Support

This commit is contained in:
2026-05-21 21:54:07 +02:00
parent 4495feb128
commit 96afb64c7a
3 changed files with 170 additions and 1 deletions
+31 -1
View File
@@ -37,7 +37,7 @@ func loadWikiDataProviders(path string) (map[string]wikiDataProviderDefinition,
return nil, fmt.Errorf("wiki data providers %s: provider %s missing source", path, name)
}
switch strings.TrimSpace(def.Source) {
case "class_progression", "class_feats", "class_summary", "race_feats", "race_name_forms":
case "class_progression", "class_feats", "class_skills", "class_summary", "race_feats", "race_name_forms":
default:
return nil, fmt.Errorf("wiki data providers %s: provider %s has unknown source %q", path, name, def.Source)
}
@@ -64,6 +64,11 @@ func (ctx *wikiContext) wikiDataProviderRows(name string, page wikiTemplatePage)
return nil, nil
}
return ctx.classFeatRows(page.Row), nil
case "class_skills":
if page.Category != "classes" {
return nil, nil
}
return ctx.classSkillRows(page.Row), nil
case "class_summary":
if page.Category != "classes" {
return nil, nil
@@ -84,6 +89,31 @@ func (ctx *wikiContext) wikiDataProviderRows(name string, page wikiTemplatePage)
}
}
func (ctx *wikiContext) classSkillRows(classRow map[string]any) []map[string]any {
table := ctx.tableForValue(fieldValue(classRow, "SkillsTable"), ctx.classSkillTables)
if table == nil {
return nil
}
rows := []map[string]any{}
for _, source := range table.Rows {
if stringValue(source, "ClassSkill") != "1" {
continue
}
key := resolveReferenceKey(fieldValue(source, "SkillIndex"), ctx.skillIDToKey)
if key == "" {
key = resolveReferenceKey(fieldValue(source, "SkillIndex"), nil)
}
if key == "" || !ctx.canReferenceWikiKey(key) {
continue
}
row := cloneRowMap(source)
row["SkillKey"] = key
row["SkillName"] = ctx.resolveSkillName(key)
rows = append(rows, row)
}
return rows
}
func (ctx *wikiContext) raceFeatRows(raceRow map[string]any) []map[string]any {
values := []any{}
switch typed := fieldValue(raceRow, "FeatsTable").(type) {