This commit is contained in:
@@ -1,30 +1,4 @@
|
||||
function numberOr(value, fallback) {
|
||||
const number = Number(value);
|
||||
return Number.isFinite(number) ? number : fallback;
|
||||
}
|
||||
|
||||
function asText(value) {
|
||||
return typeof value === 'string' ? value : '';
|
||||
}
|
||||
|
||||
function plainText(value) {
|
||||
return asText(value)
|
||||
.replace(/<br\s*\/?>/gi, '\n')
|
||||
.replace(/<\/p\s*>/gi, '\n')
|
||||
.replace(/<[^>]*>/g, ' ')
|
||||
.replace(/ /gi, ' ')
|
||||
.replace(/&/gi, '&')
|
||||
.replace(/</gi, '<')
|
||||
.replace(/>/gi, '>')
|
||||
.replace(/\s+\n/g, '\n')
|
||||
.trim();
|
||||
}
|
||||
|
||||
function traitList(value) {
|
||||
if (Array.isArray(value)) return value.map(asText).filter(Boolean);
|
||||
if (typeof value === 'string') return [value];
|
||||
return [];
|
||||
}
|
||||
const { numberOr, asText, plainText, stringList } = require('./foundry-fields');
|
||||
|
||||
function foundryActorToCharacter(foundryActor) {
|
||||
const system = foundryActor.system || {};
|
||||
@@ -40,10 +14,10 @@ function foundryActorToCharacter(foundryActor) {
|
||||
const savedDragonrollFields = foundryActor.flags?.['dragonroll-foundry'] || {};
|
||||
const savedDragonrollType = savedDragonrollFields.actorType;
|
||||
const foundryProficiencies = [
|
||||
...traitList(traits.languages?.value),
|
||||
...traitList(traits.armor?.value),
|
||||
...traitList(traits.weapon?.value),
|
||||
...traitList(traits.tool?.value)
|
||||
...stringList(traits.languages?.value),
|
||||
...stringList(traits.armor?.value),
|
||||
...stringList(traits.weapon?.value),
|
||||
...stringList(traits.tool?.value)
|
||||
].join(', ');
|
||||
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user