Files
Genarrative/src/data/worldAttributeSchemas.ts
2026-04-28 20:25:37 +08:00

114 lines
2.7 KiB
TypeScript

import { resolveCustomWorldRuleProfile } from '../services/customWorldOwnedSettingLayers';
import type {CustomWorldProfile, WorldAttributeSchema} from '../types';
import {WorldType} from '../types';
export const WORLD_TEMPLATE_ATTRIBUTE_SCHEMAS: Record<
Exclude<WorldType, WorldType.CUSTOM>,
WorldAttributeSchema
> = {
[WorldType.WUXIA]: {
id: 'schema:wuxia:v1',
worldId: WorldType.WUXIA,
schemaVersion: 1,
generatedFrom: {
worldType: WorldType.WUXIA,
worldName: '武侠',
settingSummary: '江湖、门派、旧案与人情纠葛并存。',
tone: '克制、紧张、讲究局势与心气。',
conflictCore: '在人情、威压与旧案之间立住自身。',
},
slots: [
{
slotId: 'axis_a',
name: '骨势',
},
{
slotId: 'axis_b',
name: '身法',
},
{
slotId: 'axis_c',
name: '眼脉',
},
{
slotId: 'axis_d',
name: '心焰',
},
{
slotId: 'axis_e',
name: '尘缘',
},
{
slotId: 'axis_f',
name: '玄息',
},
],
},
[WorldType.XIANXIA]: {
id: 'schema:xianxia:v1',
worldId: WorldType.XIANXIA,
schemaVersion: 1,
generatedFrom: {
worldType: WorldType.XIANXIA,
worldName: '仙侠',
settingSummary: '灵潮、宗门、禁制、秘境与道途交织。',
tone: '空灵、危险、带着灾变与大道压迫。',
conflictCore: '在裂变与因果之间稳住自我与道途。',
},
slots: [
{
slotId: 'axis_a',
name: '道骨',
},
{
slotId: 'axis_b',
name: '灵行',
},
{
slotId: 'axis_c',
name: '识海',
},
{
slotId: 'axis_d',
name: '劫纹',
},
{
slotId: 'axis_e',
name: '心契',
},
{
slotId: 'axis_f',
name: '玄息',
},
],
},
};
export function getTemplateWorldAttributeSchema(
worldType: Exclude<WorldType, WorldType.CUSTOM>,
) {
return WORLD_TEMPLATE_ATTRIBUTE_SCHEMAS[worldType];
}
export function getWorldAttributeSchema(
worldType: WorldType | null | undefined,
customWorldProfile?: CustomWorldProfile | null,
) {
if (worldType === WorldType.CUSTOM && customWorldProfile) {
try {
return (
resolveCustomWorldRuleProfile(customWorldProfile)?.attributeSchema
?? customWorldProfile.attributeSchema
);
} catch {
return customWorldProfile.attributeSchema;
}
}
if (worldType === WorldType.XIANXIA) {
return WORLD_TEMPLATE_ATTRIBUTE_SCHEMAS[WorldType.XIANXIA];
}
return WORLD_TEMPLATE_ATTRIBUTE_SCHEMAS[WorldType.WUXIA];
}