feat: add stat-modifiers role for automatic stat generation
Introduces a new `stat-modifiers` CSV role that simplifies the creation of template stats and their associated modifier stats. A single CSV block now automatically generates: - A template stat definition. - Multiple modifier stat definitions (prefixed with the template ID). - The corresponding template table. This reduces the need for manual YAML definitions for every modifier associated with a template.
This commit is contained in:
@@ -12,6 +12,7 @@ import {
|
||||
parseStatYaml,
|
||||
parseStatCsv,
|
||||
parseTemplateCsv,
|
||||
parseStatModifiers,
|
||||
type StatDef,
|
||||
type StatTemplate,
|
||||
} from "./stat-parser.js";
|
||||
@@ -111,6 +112,14 @@ export function processBlocks(
|
||||
);
|
||||
}
|
||||
|
||||
if (attrs.role === "stat-modifiers") {
|
||||
const id = attrs.id || `_mod_${contentHash(body)}`;
|
||||
const result = parseStatModifiers(body, fileRelativePath, id);
|
||||
blocks.stats.push(result.statDef);
|
||||
blocks.stats.push(...result.modifierDefs);
|
||||
blocks.statTemplates.push(result.template);
|
||||
}
|
||||
|
||||
if (attrs.role === "spark-table") {
|
||||
const parsed = parseSparkTableCsv(body, fileRelativePath, slugger);
|
||||
if (parsed) blocks.sparkTables.push(parsed);
|
||||
|
||||
Reference in New Issue
Block a user