Skip to content

Commit

Permalink
🐛 correzione converter fromPack
Browse files Browse the repository at this point in the history
  • Loading branch information
n1xx1 committed Oct 11, 2024
1 parent 60cdcb7 commit 5973f7d
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/converter-from-pack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const sourceIdRegex =
// parse a sourceId reference (supports sub-items) and
// return the matching translation and mapping
function findTranslationSource(
sourceId: string
sourceId: string,
): null | [any, CompendiumMapping] {
const m = sourceId.match(sourceIdRegex);
if (!m) {
Expand Down Expand Up @@ -92,14 +92,17 @@ export const fromPackPf2: Converter<any[]> = (items, translations) => {
}
}

const sourceId = translationSource ?? data.flags?.core?.sourceId;
const sourceId =
translationSource ??
data.flags?.core?.sourceId ??
data._stats?.compendiumSource;
if (sourceId) {
const found = findTranslationSource(sourceId);
if (found) {
const [translationData1, mapping] = found;
translationData = mergeObject(
mapping.map(data, translationData1),
translationData
translationData,
);
}
} else if (data.type === "melee" || data.type === "ranged") {
Expand All @@ -112,7 +115,7 @@ export const fromPackPf2: Converter<any[]> = (items, translations) => {
data,
mergeObject(equipmentTranslation, translationData ?? {}, {
inplace: false,
})
}),
);
} else if (data.type === "spellcastingEntry") {
const spellcastingEntryName = spellcastingEntries[data.name];
Expand All @@ -139,9 +142,9 @@ export const fromPackPf2: Converter<any[]> = (items, translations) => {
},
},
},
{ inplace: false }
{ inplace: false },
),
{ inplace: false }
{ inplace: false },
);
});
};

0 comments on commit 5973f7d

Please sign in to comment.