Fix issue #35: Dragonroll frontend: item modifications
All checks were successful
Test / test (push) Successful in 2s

This commit is contained in:
Gitea OpenCode Agent
2026-10-14 18:08:19 +00:00
parent 2c78ad039a
commit 22c6403736
15 changed files with 404 additions and 20 deletions

View File

@@ -461,7 +461,9 @@ function dragonrollActorId(actor) {
function serializeFoundryActor(actor) {
const data = {
...toPlainData(actor),
items: actor.items?.contents?.map(toPlainData) || [],
// Embedded items go through serializeFoundryItem so their icons become
// absolute URLs too: Dragonroll renders them outside of Foundry.
items: (actor.items?.contents?.map(serializeFoundryItem) || []).filter(Boolean),
};
if (data.img && !/^(https?:|data:|\/\/)/i.test(data.img)) {
data.img = new URL(data.img, window.location.origin).toString();
@@ -760,6 +762,7 @@ function makeFoundryItemData(entry) {
const data = {
name: String(entry.name || "").trim(),
type,
img: getDragonrollImageUrl(entry.image) || undefined,
system: {
quantity: Number(entry.quantity) || 1,
weight: Number(entry.weight) || 0,
@@ -773,13 +776,18 @@ function makeFoundryItemData(entry) {
}
function foundryItemUpdateData(entry) {
return {
const updates = {
name: String(entry.name || "").trim(),
"system.quantity": Number(entry.quantity) || 1,
"system.weight": Number(entry.weight) || 0,
"system.rarity": RARITY_TO_FOUNDRY_VALUE[entry.rarity] || "common",
"system.description.value": entry.description || "",
};
// An icon the campaign picked in Dragonroll travels back to Foundry; no icon
// there means leave the world's own choice alone, not erase it.
const image = getDragonrollImageUrl(entry.image);
if (image) updates.img = image;
return updates;
}
async function applyDragonrollItem(item, entry) {