Spellcasting expansion
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user