@@ -140,6 +140,15 @@ function toText(value: unknown, fallback = '') {
|
||||
return typeof value === 'string' ? value.trim() : fallback;
|
||||
}
|
||||
|
||||
function toRecordArray(value: unknown) {
|
||||
return Array.isArray(value)
|
||||
? value.filter(
|
||||
(entry): entry is Record<string, unknown> =>
|
||||
Boolean(entry) && typeof entry === 'object',
|
||||
)
|
||||
: [];
|
||||
}
|
||||
|
||||
function toStringArray(value: unknown) {
|
||||
return Array.isArray(value)
|
||||
? value
|
||||
@@ -858,10 +867,22 @@ function normalizeCampScene(
|
||||
}
|
||||
|
||||
return {
|
||||
id: toText(value.id, fallback.id),
|
||||
name: toText(value.name, fallback.name),
|
||||
description: toText(value.description, fallback.description),
|
||||
visualDescription: toText(value.visualDescription) || undefined,
|
||||
dangerLevel: toText(value.dangerLevel, fallback.dangerLevel),
|
||||
imageSrc: toText(value.imageSrc) || undefined,
|
||||
sceneNpcIds: toStringArray(value.sceneNpcIds),
|
||||
connections: toRecordArray(value.connections)
|
||||
.map((connection) => ({
|
||||
targetLandmarkId: toText(connection.targetLandmarkId),
|
||||
relativePosition:
|
||||
toText(connection.relativePosition) || toText(connection.position) || 'forward',
|
||||
summary: toText(connection.summary) || toText(connection.description),
|
||||
}))
|
||||
.filter((connection) => connection.targetLandmarkId),
|
||||
narrativeResidues: null,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -950,6 +971,7 @@ function normalizeSceneActBlueprint(
|
||||
? ['opening']
|
||||
: ['climax', 'aftermath'],
|
||||
backgroundImageSrc: toText(value.backgroundImageSrc) || undefined,
|
||||
backgroundAssetId: toText(value.backgroundAssetId) || undefined,
|
||||
encounterNpcIds,
|
||||
primaryNpcId: toText(value.primaryNpcId, encounterNpcIds[0] ?? ''),
|
||||
linkedThreadIds: toStringArray(value.linkedThreadIds),
|
||||
|
||||
Reference in New Issue
Block a user