Deploy deepseek 2
Some checks failed
Test / test (push) Failing after 2s
Build and Deploy Nuxt / build (push) Successful in 1m51s

This commit is contained in:
2026-10-19 19:04:28 +02:00
parent b5d5e570d5
commit 1ec29121e1
45 changed files with 3438 additions and 166 deletions

View File

@@ -111,23 +111,27 @@ function foundryCurrency(system) {
return Object.fromEntries(CURRENCIES.map((key) => [key, Math.max(0, numberOr(coins[key], 0))]));
}
// The character's traits as the world writes them: the free-text details field some
// system releases keep, or its trait items, which are how a monster's traits and a
// character's racial and class features are written. `undefined` says the world holds
// no traits to show.
function foundryTraits(source, items) {
// The character's features: D&D 5e files species, background, class and monster features
// under the `feat` item type, each with its text and picture on the item. They are what
// the sheet's traits tab lists, one row per feature.
function foundryFeatures(items) {
return items
.filter((item) => item.type === 'feat')
.map((item) => ({
name: asText(item.name).trim(),
description: plainText(item.system?.description?.value ?? item.system?.description),
icon: asText(item.img).trim()
}))
.filter((feature) => feature.name);
}
// The free-form traits text: the details field some system releases keep, or what the
// campaign wrote and the module carries back on its flag. `undefined` says the world
// holds no text of its own, which keeps a live edit from clearing the campaign's.
function foundryTraits(source, savedDragonrollFields, replace) {
const text = plainText(source.system?.details?.trait);
if (text) return text;
const features = items
.filter((item) => item.type === 'feat' && stringList(item.system?.featType?.value ?? item.system?.featType)
.some((type) => asText(type).toLowerCase().startsWith('tr')))
.map((item) => {
const name = asText(item.name).trim();
const description = plainText(item.system?.description?.value ?? item.system?.description);
return name ? `${name}\n${description}`.trim() : '';
})
.filter(Boolean);
return features.length ? features.join('\n\n') : undefined;
const campaignTraits = replace ? '' : asText(savedDragonrollFields.traits);
return text || campaignTraits || undefined;
}
// `replace` is a forced actor sync from the module's context menu (Syndria98/dragonroll#96):
@@ -188,7 +192,11 @@ function foundryActorToCharacter(foundryActor, replace = false) {
icon: asText(item.img).trim()
}))
.filter((item) => item.name),
spells: items.filter((item) => item.type === 'spell').map((item) => asText(item.name)).filter(Boolean).join('\n')
spells: items.filter((item) => item.type === 'spell').map((item) => asText(item.name)).filter(Boolean).join('\n'),
// The features themselves, icons and all: the traits tab draws them like the
// inventory, and a live edit sends the world's whole item list, so a feature the
// GM removed in Foundry goes here too.
features: foundryFeatures(items)
};
// What the world says about each of these, when it says anything: leaving a field
@@ -206,9 +214,8 @@ function foundryActorToCharacter(foundryActor, replace = false) {
if (languages) fields.languages = languages;
const currency = foundryCurrency(system);
if (currency) fields.currency = currency;
const worldTraits = foundryTraits(foundryActor, items);
const campaignTraits = replace ? '' : asText(savedDragonrollFields.traits);
if (worldTraits || campaignTraits) fields.traits = worldTraits || campaignTraits;
const worldTraits = foundryTraits(foundryActor, savedDragonrollFields, replace);
if (worldTraits) fields.traits = worldTraits;
// A replace writes the fields a live edit would leave out when the world says
// nothing, so the campaign's toggles, lists and text for this actor go with it and