24
src/services/customWorldTheme.ts
Normal file
24
src/services/customWorldTheme.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
import { CustomWorldProfile, WorldTemplateType, WorldType } from '../types';
|
||||
|
||||
export type CustomWorldThemeMode = 'martial' | 'arcane' | 'machina' | 'tide' | 'rift';
|
||||
|
||||
export function detectCustomWorldThemeMode(
|
||||
profile: Pick<CustomWorldProfile, 'settingText' | 'summary' | 'tone' | 'playerGoal' | 'templateWorldType'>,
|
||||
): CustomWorldThemeMode {
|
||||
const source = `${profile.settingText} ${profile.summary} ${profile.tone} ${profile.playerGoal}`;
|
||||
|
||||
if (/[机关蒸汽齿轮工坊机巧城轨炮舰]/u.test(source)) return 'machina';
|
||||
if (/[海潮港湾船舟湖泊澜雾湾]/u.test(source)) return 'tide';
|
||||
if (/[裂缝裂界边境前线断层界桥灰域]/u.test(source)) return 'rift';
|
||||
if (/[修真仙灵宗门法器道脉秘境云阙]/u.test(source)) return 'arcane';
|
||||
if (/[江湖门派镖局朝廷刀剑侠客旧案]/u.test(source)) return 'martial';
|
||||
|
||||
return profile.templateWorldType === WorldType.XIANXIA ? 'arcane' : 'martial';
|
||||
}
|
||||
|
||||
export function resolveCustomWorldAnchorWorldType(
|
||||
profile: Pick<CustomWorldProfile, 'settingText' | 'summary' | 'tone' | 'playerGoal' | 'templateWorldType'>,
|
||||
): WorldTemplateType {
|
||||
const themeMode = detectCustomWorldThemeMode(profile);
|
||||
return themeMode === 'arcane' || themeMode === 'rift' ? WorldType.XIANXIA : WorldType.WUXIA;
|
||||
}
|
||||
Reference in New Issue
Block a user