This commit is contained in:
35
src/services/storyEngine/contentDiffReport.ts
Normal file
35
src/services/storyEngine/contentDiffReport.ts
Normal file
@@ -0,0 +1,35 @@
|
||||
import type {
|
||||
CampaignPack,
|
||||
CustomWorldProfile,
|
||||
} from '../../types';
|
||||
|
||||
export interface ContentDiffReport {
|
||||
summary: string;
|
||||
changedFields: string[];
|
||||
}
|
||||
|
||||
export function buildContentDiffReport(params: {
|
||||
previousProfile: CustomWorldProfile | null | undefined;
|
||||
nextProfile: CustomWorldProfile | null | undefined;
|
||||
previousCampaignPack?: CampaignPack | null;
|
||||
nextCampaignPack?: CampaignPack | null;
|
||||
}) {
|
||||
const changedFields: string[] = [];
|
||||
if (params.previousProfile?.summary !== params.nextProfile?.summary) changedFields.push('profile.summary');
|
||||
if (params.previousProfile?.scenarioPackId !== params.nextProfile?.scenarioPackId) changedFields.push('profile.scenarioPackId');
|
||||
if (params.previousProfile?.campaignPackId !== params.nextProfile?.campaignPackId) changedFields.push('profile.campaignPackId');
|
||||
if (params.previousCampaignPack?.authoringStyle !== params.nextCampaignPack?.authoringStyle) {
|
||||
changedFields.push('campaignPack.authoringStyle');
|
||||
}
|
||||
if (params.previousCampaignPack?.actTemplates.length !== params.nextCampaignPack?.actTemplates.length) {
|
||||
changedFields.push('campaignPack.actTemplates');
|
||||
}
|
||||
|
||||
return {
|
||||
summary:
|
||||
changedFields.length > 0
|
||||
? `当前版本相较上个版本改动了 ${changedFields.length} 个关键 narrative 字段。`
|
||||
: '当前版本与上个版本相比没有明显 narrative 结构差异。',
|
||||
changedFields,
|
||||
} satisfies ContentDiffReport;
|
||||
}
|
||||
Reference in New Issue
Block a user