mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-17 07:36:26 +01:00
fix bug of duplicate effects being created
This commit is contained in:
parent
16395c9f68
commit
b7a52a88c8
2 changed files with 10 additions and 36 deletions
|
|
@ -6,8 +6,9 @@ export default class DhActiveEffect extends ActiveEffect {
|
|||
return false;
|
||||
}
|
||||
|
||||
// First check for attachment-only effects - these should be suppressed unless attached
|
||||
if (this.isAttachmentOnly && !this.isAttached) {
|
||||
// First check for attachment-only effects - these should ALWAYS be suppressed on the original item
|
||||
// They only work through copied versions when attached
|
||||
if (this.isAttachmentOnly) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -42,17 +43,12 @@ export default class DhActiveEffect extends ActiveEffect {
|
|||
const actor = this.parent.parent;
|
||||
if (!actor || !actor.items) return false;
|
||||
|
||||
try {
|
||||
return actor.items.some(item => {
|
||||
return (item.type === 'armor' || item.type === 'weapon') &&
|
||||
item.system?.attached &&
|
||||
Array.isArray(item.system.attached) &&
|
||||
item.system.attached.includes(this.parent.uuid);
|
||||
});
|
||||
} catch (error) {
|
||||
console.warn('Error checking if item is attached:', error);
|
||||
return false;
|
||||
}
|
||||
return actor.items.some(item => {
|
||||
return (item.type === 'armor' || item.type === 'weapon') &&
|
||||
item.system?.attached &&
|
||||
Array.isArray(item.system.attached) &&
|
||||
item.system.attached.includes(this.parent.uuid);
|
||||
});
|
||||
}
|
||||
|
||||
async _preCreate(data, options, user) {
|
||||
|
|
|
|||
|
|
@ -191,26 +191,4 @@ export async function addAttachmentToItem({ parentItem, droppedItem, parentType
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove an attachment from an item and clean up its effects
|
||||
* @param {Object} options - Configuration options
|
||||
* @param {Item} options.parentItem - The item (armor/weapon) that the item is attached to
|
||||
* @param {string} options.attachedUuid - UUID of the attached item being removed
|
||||
* @param {string} options.parentType - Type of parent item ("armor" or "weapon")
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
export async function removeAttachmentFromItem({ parentItem, attachedUuid, parentType }) {
|
||||
const currentAttached = parentItem.system.attached;
|
||||
|
||||
// Remove the attachment from the parent item's attached array
|
||||
await parentItem.update({
|
||||
'system.attached': currentAttached.filter(uuid => uuid !== attachedUuid)
|
||||
});
|
||||
|
||||
// Remove any effects that came from this attachment
|
||||
await removeAttachmentEffectsFromActor({
|
||||
parentItem,
|
||||
attachedUuid,
|
||||
parentType
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue