its a desert

This commit is contained in:
psitacus 2025-07-09 01:14:54 -06:00
parent b269e58585
commit 99aca056c8
3 changed files with 90 additions and 70 deletions

View file

@ -1,5 +1,5 @@
import DHBaseItemSheet from '../api/base-item.mjs';
import { copyAttachmentEffectsToActor, removeAttachmentFromItem } from '../../../helpers/attachmentHelper.mjs';
import { copyAttachmentEffectsToActor, removeAttachmentFromItem, prepareAttachmentContext, addAttachmentToItem } from '../../../helpers/attachmentHelper.mjs';
export default class ArmorSheet extends DHBaseItemSheet {
/**@inheritdoc */
@ -57,17 +57,7 @@ export default class ArmorSheet extends DHBaseItemSheet {
context.features = this.document.system.features.map(x => x.value);
break;
case 'attachments':
const attachedUUIDs = this.document.system.attached;
context.attachedItems = await Promise.all(
attachedUUIDs.map(async uuid => {
const item = await fromUuid(uuid);
return {
uuid: uuid,
name: item?.name || 'Unknown Item',
img: item?.img || 'icons/svg/item-bag.svg'
};
})
);
context.attachedItems = await prepareAttachmentContext(this.document);
break;
}
@ -98,29 +88,11 @@ export default class ArmorSheet extends DHBaseItemSheet {
const item = await Item.implementation.fromDropData(data);
if (!item) return;
const currentAttached = this.document.system.attached;
const newUUID = item.uuid;
if (currentAttached.includes(newUUID)) {
ui.notifications.warn(`${item.name} is already attached to this armor.`);
return;
}
const updatedAttached = [...currentAttached, newUUID];
await this.document.update({
'system.attached': updatedAttached
await addAttachmentToItem({
parentItem: this.document,
droppedItem: item,
parentType: 'armor'
});
const actor = this.document.parent;
if (actor && item.effects.size > 0 && this.document.system.equipped) {
await copyAttachmentEffectsToActor({
parentItem: this.document,
attachedItem: item,
attachedUuid: newUUID,
parentType: 'armor'
});
}
}
/**