feature/class-wiki-spell-progression (#13)
Reviewed-on: https://gitea.westgate.pw/ShadowsOverWestgate/sow-tools/pulls/13 Co-authored-by: vickydotbat <vickydotbat@tutamail.com> Co-committed-by: vickydotbat <vickydotbat@tutamail.com>
This commit is contained in:
@@ -90,38 +90,41 @@ type wikiTable struct {
|
||||
}
|
||||
|
||||
type wikiContext struct {
|
||||
dialog map[string]string
|
||||
rowsByKey map[string]map[string]any
|
||||
featRows map[string]map[string]any
|
||||
featIDToKey map[int]string
|
||||
skillRows map[string]map[string]any
|
||||
skillIDToKey map[int]string
|
||||
spellRows map[string]map[string]any
|
||||
baseitemRows map[string]map[string]any
|
||||
classRows map[string]map[string]any
|
||||
classIDToKey map[int]string
|
||||
raceRows map[string]map[string]any
|
||||
raceIDToKey map[int]string
|
||||
masterfeatRows map[string]map[string]any
|
||||
classFeatTables map[string]wikiTable
|
||||
classSkillTables map[string]wikiTable
|
||||
classBonusTables map[string]wikiTable
|
||||
classSaveTables map[string]wikiTable
|
||||
raceFeatTables map[string]wikiTable
|
||||
statuses map[string]map[string]string
|
||||
implementedFeats map[string]struct{}
|
||||
manualSections []wikiManualSection
|
||||
templateDir string
|
||||
wikiTablesPath string
|
||||
wikiTableDefinitions map[string]wikiTableDefinition
|
||||
wikiDataPath string
|
||||
wikiDataProviders map[string]wikiDataProviderDefinition
|
||||
visibilityPolicy *wikiVisibilityDefinitions
|
||||
visibleWikiKeys map[string]bool
|
||||
namespaceTitles map[string]string
|
||||
namespacePaths map[string]string
|
||||
alignmentLinkPattern string
|
||||
alignmentLinkFormat string
|
||||
dialog map[string]string
|
||||
rowsByKey map[string]map[string]any
|
||||
featRows map[string]map[string]any
|
||||
featIDToKey map[int]string
|
||||
skillRows map[string]map[string]any
|
||||
skillIDToKey map[int]string
|
||||
spellRows map[string]map[string]any
|
||||
baseitemRows map[string]map[string]any
|
||||
classRows map[string]map[string]any
|
||||
classIDToKey map[int]string
|
||||
raceRows map[string]map[string]any
|
||||
raceIDToKey map[int]string
|
||||
masterfeatRows map[string]map[string]any
|
||||
classFeatTables map[string]wikiTable
|
||||
classSkillTables map[string]wikiTable
|
||||
classBonusTables map[string]wikiTable
|
||||
classSaveTables map[string]wikiTable
|
||||
classSpellGainTables map[string]wikiTable
|
||||
classSpellKnownTables map[string]wikiTable
|
||||
classSpellbooks map[string]classSpellbookSpec
|
||||
raceFeatTables map[string]wikiTable
|
||||
statuses map[string]map[string]string
|
||||
implementedFeats map[string]struct{}
|
||||
manualSections []wikiManualSection
|
||||
templateDir string
|
||||
wikiTablesPath string
|
||||
wikiTableDefinitions map[string]wikiTableDefinition
|
||||
wikiDataPath string
|
||||
wikiDataProviders map[string]wikiDataProviderDefinition
|
||||
visibilityPolicy *wikiVisibilityDefinitions
|
||||
visibleWikiKeys map[string]bool
|
||||
namespaceTitles map[string]string
|
||||
namespacePaths map[string]string
|
||||
alignmentLinkPattern string
|
||||
alignmentLinkFormat string
|
||||
}
|
||||
|
||||
func buildWiki(p *project.Project, nativeResult BuildResult, force bool, progress func(string)) (wikiResult, error) {
|
||||
@@ -632,24 +635,43 @@ func loadWikiContext(dataDir, sourceDir string) (*wikiContext, error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
classBonusTables, err := loadWikiTables(filepath.Join(dataDir, "classes", "bfeat"))
|
||||
classBonusTables, err := loadWikiTablesFromDirs(filepath.Join(dataDir, "classes", "bonusfeats"), filepath.Join(dataDir, "classes", "bfeat"))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
classSaveTables, err := loadWikiTables(filepath.Join(dataDir, "classes", "savthr"))
|
||||
classSaveTables, err := loadWikiTablesFromDirs(filepath.Join(dataDir, "classes", "savingthrows"), filepath.Join(dataDir, "classes", "savthr"))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
classSpellGainTables, err := loadWikiTables(filepath.Join(dataDir, "classes", "spellsgained"))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
classSpellKnownTables, err := loadWikiTables(filepath.Join(dataDir, "classes", "spellsknown"))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
classSpellbookList, diagnostics := loadClassSpellbookSpecs(filepath.Join(dataDir, "classes", "spellbooks"))
|
||||
if len(diagnostics) > 0 {
|
||||
return nil, fmt.Errorf("load class spellbooks for wiki: %s", diagnosticsTextForError(diagnostics))
|
||||
}
|
||||
classSpellbooks := map[string]classSpellbookSpec{}
|
||||
for _, spec := range classSpellbookList {
|
||||
classSpellbooks[spec.Class] = spec
|
||||
}
|
||||
|
||||
ctx := &wikiContext{
|
||||
dialog: dialog,
|
||||
rowsByKey: map[string]map[string]any{},
|
||||
statuses: map[string]map[string]string{},
|
||||
raceFeatTables: raceFeatTables,
|
||||
classFeatTables: classFeatTables,
|
||||
classSkillTables: classSkillTables,
|
||||
classBonusTables: classBonusTables,
|
||||
classSaveTables: classSaveTables,
|
||||
dialog: dialog,
|
||||
rowsByKey: map[string]map[string]any{},
|
||||
statuses: map[string]map[string]string{},
|
||||
raceFeatTables: raceFeatTables,
|
||||
classFeatTables: classFeatTables,
|
||||
classSkillTables: classSkillTables,
|
||||
classBonusTables: classBonusTables,
|
||||
classSaveTables: classSaveTables,
|
||||
classSpellGainTables: classSpellGainTables,
|
||||
classSpellKnownTables: classSpellKnownTables,
|
||||
classSpellbooks: classSpellbooks,
|
||||
}
|
||||
if ok {
|
||||
ctx.featRows, ctx.featIDToKey = rowsByKeyAndID(featDataset.Rows)
|
||||
@@ -818,6 +840,20 @@ func loadWikiTables(root string) (map[string]wikiTable, error) {
|
||||
return tables, nil
|
||||
}
|
||||
|
||||
func loadWikiTablesFromDirs(roots ...string) (map[string]wikiTable, error) {
|
||||
merged := map[string]wikiTable{}
|
||||
for _, root := range roots {
|
||||
tables, err := loadWikiTables(root)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
for key, table := range tables {
|
||||
merged[key] = table
|
||||
}
|
||||
}
|
||||
return merged, nil
|
||||
}
|
||||
|
||||
func generateEntityPages(outputDir string, ctx *wikiContext, writePage func(pageID, content, title, status string) error) error {
|
||||
if err := generateCategoryPages("classes", ctx.classRows, ctx, writePage); err != nil {
|
||||
return err
|
||||
@@ -1267,6 +1303,13 @@ func (ctx *wikiContext) resolveSkillName(key string) string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func (ctx *wikiContext) resolveSpellName(key string) string {
|
||||
if row := ctx.spellRows[key]; row != nil {
|
||||
return ctx.resolveRowName("spells", row)
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (ctx *wikiContext) resolveClassName(key string) string {
|
||||
if row := ctx.classRows[key]; row != nil {
|
||||
return ctx.resolveRowName("classes", row)
|
||||
|
||||
Reference in New Issue
Block a user