This commit is contained in:
2026-04-25 13:44:48 +08:00
parent 03acbc5cb1
commit 2ebb7bf253
44 changed files with 1003 additions and 250 deletions

View File

@@ -3,6 +3,7 @@ import { afterEach, describe, expect, it } from 'vitest';
import { buildExpandedCustomWorldProfile } from '../services/customWorldBuilder';
import { AnimationState } from '../types';
import {
buildCustomWorldPlayableCharacters,
buildCustomWorldRuntimeCharacters,
getCharacterById,
resolveEncounterRecruitCharacter,
@@ -109,19 +110,9 @@ describe('characterPresets custom world runtime characters', () => {
tone: '潮湿、压抑、克制',
playerGoal: '查清夜港失踪案和潮路背后的势力牵连。',
templateWorldType: 'WUXIA',
playableNpcs: Array.from({ length: 5 }, (_, index) => ({
...createRole(index),
templateCharacterId:
index === 0
? 'sword-princess'
: index === 1
? 'archer-hero'
: index === 2
? 'girl-hero'
: index === 3
? 'punch-hero'
: 'fighter-4',
})),
playableNpcs: Array.from({ length: 5 }, (_, index) =>
createRole(index),
),
storyNpcs: [
{
...createRole(10),
@@ -260,4 +251,38 @@ describe('characterPresets custom world runtime characters', () => {
expect(recruitCharacter?.id).toBe(storyRole!.id);
expect(recruitCharacter?.name).toBe('沈雾');
});
it('uses draft playable role image directly before generated animations exist', () => {
const profile = buildExpandedCustomWorldProfile(
{
name: '潮雾列岛',
subtitle: '灯塔未眠',
summary: '围绕潮雾、灯塔和失踪航路展开的世界。',
tone: '冷峻、潮湿、悬疑',
playerGoal: '找到灯塔失踪航路。',
templateWorldType: 'WUXIA',
playableNpcs: [
{
...createRole(0),
id: 'playable-lighthouse-keeper',
imageSrc: '/generated-characters/lighthouse-keeper/portrait.png',
generatedVisualAssetId: 'assetobj-lighthouse-keeper',
generatedAnimationSetId: undefined,
animationMap: undefined,
},
],
},
'玩家想测试灯塔守望者草稿。',
);
const [playableCharacter] = buildCustomWorldPlayableCharacters(profile);
expect(playableCharacter?.portrait).toBe(
'/generated-characters/lighthouse-keeper/portrait.png',
);
expect(playableCharacter?.avatar).toBe(
'/generated-characters/lighthouse-keeper/portrait.png',
);
expect(playableCharacter?.animationMap).toBeUndefined();
});
});