mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-12 03:31:07 +01:00
* add basic drag drop window * add better field * make effects copy onto actor on attachment * make items from inventory draggable * working drop from inventory * remove duplication issue * add attachment only flag and logic * add weapons to attachables * remove debug logs * try to make it drier * remove unecessary try catch * remove extra configs * remove superfluous comments * remove spurious defenses * make drier * remove unecessary code * deduplicate and simplify * its a desert * standardize to be more similar to class item code * fix bug of duplicate effects being created * fix localization string * fix bug of item equiping and un equiping * remove this since were not going to be using attachmentonly * update attachment tab with comments * remove attachment only logic in favor of just transfer * change flags * change armor and weapon to be attachableItem * change armor and weapon to be attachableItem * change weapon to use mixin * add mixin to armor * move everything to mixin sheet * refactor code for review comments * cleanup and somehow git is ignoring some changes * see if this picks up the changes now * Import/Export updates --------- Co-authored-by: psitacus <walther.johnson@ucalgary.ca> Co-authored-by: WBHarry <williambjrklund@gmail.com>
84 lines
2.7 KiB
JavaScript
84 lines
2.7 KiB
JavaScript
export default class DhActiveEffect extends ActiveEffect {
|
|
get isSuppressed() {
|
|
// If this is a copied effect from an attachment, never suppress it
|
|
// (These effects have attachmentSource metadata)
|
|
if (this.flags?.daggerheart?.attachmentSource) {
|
|
return false;
|
|
}
|
|
|
|
// Then apply the standard suppression rules
|
|
if (['weapon', 'armor'].includes(this.parent?.type)) {
|
|
return !this.parent.system.equipped;
|
|
}
|
|
|
|
if (this.parent?.type === 'domainCard') {
|
|
return this.parent.system.inVault;
|
|
}
|
|
|
|
return super.isSuppressed;
|
|
}
|
|
|
|
/**
|
|
* Check if the parent item is currently attached to another item
|
|
* @returns {boolean}
|
|
*/
|
|
get isAttached() {
|
|
if (!this.parent || !this.parent.parent) return false;
|
|
|
|
// Check if this item's UUID is in any actor's armor or weapon attachment lists
|
|
const actor = this.parent.parent;
|
|
if (!actor || !actor.items) 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) {
|
|
const update = {};
|
|
if (!data.img) {
|
|
update.img = 'icons/magic/life/heart-cross-blue.webp';
|
|
}
|
|
|
|
if (Object.keys(update).length > 0) {
|
|
await this.updateSource(update);
|
|
}
|
|
|
|
await super._preCreate(data, options, user);
|
|
}
|
|
|
|
static applyField(model, change, field) {
|
|
const isItemTarget = change.value.toLowerCase().startsWith('item.');
|
|
change.value = isItemTarget ? change.value.slice(5) : change.value;
|
|
change.value = Roll.safeEval(
|
|
Roll.replaceFormulaData(change.value, isItemTarget ? change.effect.parent : model)
|
|
);
|
|
super.applyField(model, change, field);
|
|
}
|
|
|
|
async toChat(origin) {
|
|
const cls = getDocumentClass('ChatMessage');
|
|
const systemData = {
|
|
title: game.i18n.localize('DAGGERHEART.CONFIG.ActionType.action'),
|
|
origin: origin,
|
|
img: this.img,
|
|
name: this.name,
|
|
description: this.description,
|
|
actions: []
|
|
};
|
|
const msg = new cls({
|
|
type: 'abilityUse',
|
|
user: game.user.id,
|
|
system: systemData,
|
|
content: await foundry.applications.handlebars.renderTemplate(
|
|
'systems/daggerheart/templates/ui/chat/ability-use.hbs',
|
|
systemData
|
|
)
|
|
});
|
|
|
|
cls.create(msg.toObject());
|
|
}
|
|
}
|