This commit is contained in:
2026-04-28 20:25:37 +08:00
parent f0471a4f8d
commit 0f013b6eee
45 changed files with 1117 additions and 1047 deletions
-30
View File
@@ -50,18 +50,6 @@ function toText(value: unknown, fallback: string) {
return normalized || fallback;
}
function toStringArray(value: unknown, fallback: string[]) {
if (!Array.isArray(value)) {
return [...fallback];
}
const normalized = value
.map(item => toOptionalText(item))
.filter(Boolean);
return normalized.length > 0 ? [...new Set(normalized)] : [...fallback];
}
export function coerceWorldAttributeSchema(
raw: unknown,
fallback: WorldAttributeSchema,
@@ -79,7 +67,6 @@ export function coerceWorldAttributeSchema(
schemaVersion: typeof raw.schemaVersion === 'number' && Number.isFinite(raw.schemaVersion) && raw.schemaVersion > 0
? Math.max(1, Math.round(raw.schemaVersion))
: fallback.schemaVersion,
schemaName: toOptionalText(raw.schemaName) || fallback.schemaName,
generatedFrom: {
...fallback.generatedFrom,
worldName: toText(rawGeneratedFrom.worldName, fallback.generatedFrom.worldName),
@@ -93,12 +80,6 @@ export function coerceWorldAttributeSchema(
...fallbackSlot,
slotId: fallbackSlot.slotId,
name: toText(rawSlot.name, fallbackSlot.name),
definition: toText(rawSlot.definition, fallbackSlot.definition),
positiveSignals: toStringArray(rawSlot.positiveSignals, fallbackSlot.positiveSignals),
negativeSignals: toStringArray(rawSlot.negativeSignals, fallbackSlot.negativeSignals),
combatUseText: toText(rawSlot.combatUseText, fallbackSlot.combatUseText),
socialUseText: toText(rawSlot.socialUseText, fallbackSlot.socialUseText),
explorationUseText: toText(rawSlot.explorationUseText, fallbackSlot.explorationUseText),
};
}),
};
@@ -151,17 +132,6 @@ export function validateWorldAttributeSchema(schema: WorldAttributeSchema) {
issues.push(`attribute name "${trimmedName}" contains banned legacy term`);
}
if (!slot.definition.trim()) {
issues.push(`slot ${slot.slotId} is missing a definition`);
}
if (/攻击力|防御力|生命值|法力值/u.test(slot.definition)) {
issues.push(`slot ${slot.slotId} definition is too derivative`);
}
if (!slot.combatUseText.trim() || !slot.socialUseText.trim() || !slot.explorationUseText.trim()) {
issues.push(`slot ${slot.slotId} must describe combat, social, and exploration usage`);
}
});
return issues;