36 lines
1.4 KiB
TypeScript
36 lines
1.4 KiB
TypeScript
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;
|
|
}
|