Native topdata migration summary - Replaced the legacy 2dabuilder runtime path with the native topdata builder. - Native build, validate, compare, and convert flows now cover the canonical topdata pipeline. - compare-topdata is now a native self-check; legacy reference-builder runtime usage was removed. - Parts generation follows the native asset-scan contract and uses sow-assets via project asset resolution. - Generated feat families, class-feat injects, masterfeat/successor expansion, and dataset-derived feat generation were brought to parity and regression-covered. - Remaining mirrored datasets were migrated into native-owned canonical data while preserving lock IDs. - normalize-topdata bridge behavior and migration-era ownership markers were removed. - Documentation was rewritten around the native workflow and active contracts were cleaned up. - Final hardening pass removed stale validator assumptions and cleaned ignored/generated artifacts for PR readiness. Reviewed-on: https://gitea.westgate.pw/ShadowsOverWestgate/sow-tools/pulls/2 Co-authored-by: vickydotbat <vickydotbat@tutamail.com> Co-committed-by: vickydotbat <vickydotbat@tutamail.com>
104 lines
2.6 KiB
Go
104 lines
2.6 KiB
Go
package topdata
|
|
|
|
import (
|
|
"encoding/json"
|
|
"os"
|
|
"path/filepath"
|
|
)
|
|
|
|
func importLegacySpells(referenceBuilderDir, dataDir string, legacyTLK *legacyTLKData) (int, error) {
|
|
_ = legacyTLK
|
|
|
|
legacyDir := filepath.Join(referenceBuilderDir, "data", "spells")
|
|
if _, err := os.Stat(legacyDir); err != nil {
|
|
if os.IsNotExist(err) {
|
|
return 0, nil
|
|
}
|
|
return 0, err
|
|
}
|
|
|
|
targetDir := filepath.Join(dataDir, "spells")
|
|
targetBasePath := filepath.Join(targetDir, "base.json")
|
|
targetLockPath := filepath.Join(targetDir, "lock.json")
|
|
targetModulesDir := filepath.Join(targetDir, "modules")
|
|
moduleNames := []string{
|
|
"specialattacks.json",
|
|
"ovr_fixduplicates.json",
|
|
filepath.Join("bardicmusic", "fascinate.json"),
|
|
filepath.Join("bardicmusic", "inspirecompetence.json"),
|
|
filepath.Join("bardicmusic", "inspirecourage.json"),
|
|
filepath.Join("bardicmusic", "inspiregreatness.json"),
|
|
filepath.Join("bardicmusic", "inspireheroics.json"),
|
|
filepath.Join("bardicmusic", "songoffreedom.json"),
|
|
}
|
|
targetModulePaths := make([]string, 0, len(moduleNames))
|
|
for _, name := range moduleNames {
|
|
targetModulePaths = append(targetModulePaths, filepath.Join(targetModulesDir, name))
|
|
}
|
|
if fileExists(targetBasePath) && fileExists(targetLockPath) {
|
|
allModulesPresent := true
|
|
for _, path := range targetModulePaths {
|
|
if !fileExists(path) {
|
|
allModulesPresent = false
|
|
break
|
|
}
|
|
}
|
|
if allModulesPresent {
|
|
return 0, nil
|
|
}
|
|
}
|
|
|
|
baseObj, err := loadJSONObject(filepath.Join(legacyDir, "base.json"))
|
|
if err != nil {
|
|
return 0, err
|
|
}
|
|
baseObj["output"] = "spells.2da"
|
|
|
|
lockObj, err := loadJSONObject(filepath.Join(legacyDir, "lock.json"))
|
|
if err != nil {
|
|
return 0, err
|
|
}
|
|
|
|
moduleObjs := make([]map[string]any, 0, len(moduleNames))
|
|
for _, name := range moduleNames {
|
|
obj, err := loadJSONObject(filepath.Join(legacyDir, "modules", name))
|
|
if err != nil {
|
|
return 0, err
|
|
}
|
|
moduleObjs = append(moduleObjs, obj)
|
|
}
|
|
|
|
if err := os.MkdirAll(targetModulesDir, 0o755); err != nil {
|
|
return 0, err
|
|
}
|
|
|
|
writes := []struct {
|
|
path string
|
|
obj map[string]any
|
|
}{
|
|
{path: targetBasePath, obj: baseObj},
|
|
{path: targetLockPath, obj: lockObj},
|
|
}
|
|
for i, path := range targetModulePaths {
|
|
if err := os.MkdirAll(filepath.Dir(path), 0o755); err != nil {
|
|
return 0, err
|
|
}
|
|
writes = append(writes, struct {
|
|
path string
|
|
obj map[string]any
|
|
}{path: path, obj: moduleObjs[i]})
|
|
}
|
|
|
|
for _, write := range writes {
|
|
raw, err := json.MarshalIndent(write.obj, "", " ")
|
|
if err != nil {
|
|
return 0, err
|
|
}
|
|
raw = append(raw, '\n')
|
|
if err := os.WriteFile(write.path, raw, 0o644); err != nil {
|
|
return 0, err
|
|
}
|
|
}
|
|
return len(writes), nil
|
|
}
|