Spellcasting expansion

This commit is contained in:
2026-05-27 10:28:44 +02:00
parent bd9d2c6da0
commit a2d9820f8d
2 changed files with 81 additions and 0 deletions
+30
View File
@@ -452,6 +452,7 @@ func (ctx *wikiContext) classProgressionRows(levels string, projections map[stri
row["HasSpellProgression"] = hasSpellProgression(classRow)
row["HasSpellsPerDay"] = hasPerDay
row["HasSpellsKnown"] = hasKnown
row["SpellcastingAdvancementNote"] = classSpellcastingAdvancementNote(classRow, level)
populateClassSpellProgressionFields(row, "SpellsPerDay", spellsPerDayByLevel[level])
populateClassSpellProgressionFields(row, "SpellsKnown", spellsKnownByLevel[level])
out = append(out, row)
@@ -459,6 +460,35 @@ func (ctx *wikiContext) classProgressionRows(levels string, projections map[stri
return out, nil
}
func classSpellcastingAdvancementNote(classRow map[string]any, level int) string {
if level < 1 || isClassSpellcaster(classRow) {
return ""
}
notes := []string{}
if advancesSpellcastingAtLevel(classRow, "ArcSpellLvlMod", level) {
notes = append(notes, "+1 level of existing arcane spellcasting class")
}
if advancesSpellcastingAtLevel(classRow, "DivSpellLvlMod", level) {
notes = append(notes, "+1 level of existing divine spellcasting class")
}
return strings.Join(notes, "; ")
}
func advancesSpellcastingAtLevel(classRow map[string]any, field string, level int) bool {
mod, err := asInt(fieldValue(classRow, field))
if err != nil || mod <= 0 {
return false
}
return roundedSpellcastingLevelAdvancement(level, mod) > roundedSpellcastingLevelAdvancement(level-1, mod)
}
func roundedSpellcastingLevelAdvancement(level, mod int) int {
if level <= 0 || mod <= 0 {
return 0
}
return (level*2 + mod) / (mod * 2)
}
func (ctx *wikiContext) classProgressionNote(classRow map[string]any, level int) string {
meta, err := parseExistingMetadata(classRow)
if err != nil || meta == nil {