Manually-authored class notes
This commit is contained in:
@@ -441,7 +441,14 @@ func (ctx *wikiContext) classProgressionRows(levels string, projections map[stri
|
||||
if hitDie > 0 {
|
||||
row["HPMax"] = level * hitDie
|
||||
}
|
||||
row["Notes"] = ""
|
||||
if !presentWikiValue(fieldValue(row, "Notes")) {
|
||||
if note := ctx.classProgressionNote(classRow, level); note != "" {
|
||||
row["Notes"] = note
|
||||
}
|
||||
}
|
||||
if _, ok := row["Notes"]; !ok {
|
||||
row["Notes"] = ""
|
||||
}
|
||||
row["HasSpellProgression"] = hasSpellProgression(classRow)
|
||||
row["HasSpellsPerDay"] = hasPerDay
|
||||
row["HasSpellsKnown"] = hasKnown
|
||||
@@ -452,6 +459,38 @@ func (ctx *wikiContext) classProgressionRows(levels string, projections map[stri
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (ctx *wikiContext) classProgressionNote(classRow map[string]any, level int) string {
|
||||
meta, err := parseExistingMetadata(classRow)
|
||||
if err != nil || meta == nil {
|
||||
return ""
|
||||
}
|
||||
wiki, _ := meta["wiki"].(map[string]any)
|
||||
if wiki == nil {
|
||||
return ""
|
||||
}
|
||||
raw := wiki["progression_notes"]
|
||||
if raw == nil {
|
||||
return ""
|
||||
}
|
||||
switch typed := raw.(type) {
|
||||
case map[string]any:
|
||||
for _, key := range []string{strconv.Itoa(level), formatLevelNoteKey(level)} {
|
||||
if value, ok := typed[key]; ok {
|
||||
return strings.TrimSpace(ctx.resolveTextValue(value, nil))
|
||||
}
|
||||
}
|
||||
case []any:
|
||||
if level > 0 && level <= len(typed) {
|
||||
return strings.TrimSpace(ctx.resolveTextValue(typed[level-1], nil))
|
||||
}
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func formatLevelNoteKey(level int) string {
|
||||
return "level_" + strconv.Itoa(level)
|
||||
}
|
||||
|
||||
func classSpellProgressionByLevel(table *wikiTable) map[int]map[int]string {
|
||||
out := map[int]map[int]string{}
|
||||
if table == nil {
|
||||
|
||||
Reference in New Issue
Block a user