Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -2306,6 +2306,10 @@
"label": "Additional Items",
"hint": "These additional items will be added to the creature when one of its items is enchanted, and will be removed if the enchantment is ever removed."
}
},
"static": {
"label": "Static",
"hint": "Prevent this enchantment from being removed via the item context menu."
}
},
"enchant": {
Expand Down
25 changes: 24 additions & 1 deletion module/applications/components/inventory.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -375,9 +375,16 @@ export default class InventoryElement extends (foundry.applications.elements.Ado
}, {
label: "DND5E.ConcentrationBreak",
icon: '<dnd5e-icon src="systems/dnd5e/icons/svg/break-concentration.svg"></dnd5e-icon>',
group: "state",
group: "destructive",
visible: () => this.actor?.concentration?.items.has(item),
onClick: () => this.actor?.endConcentration(item)
}, {
label: "DND5E.ENCHANTMENT.Action.Remove",
icon: '<i class="fa-solid fa-rotate-left fa-fw"></i>',
group: "destructive",
visible: () => item.isOwner && !compendiumLocked
&& item.effects.some(e => e.isAppliedEnchantment && !e.getFlag("dnd5e", "static")),
onClick: (event, target) => this._onAction(target, "removeEnchantment", { event })
}, {
label: `DND5E.ContextMenuAction${item.system.attuned ? "Unattune" : "Attune"}`,
icon: '<i class="fa-solid fa-sun fa-fw"></i>',
Expand Down Expand Up @@ -479,6 +486,7 @@ export default class InventoryElement extends (foundry.applications.elements.Ado
case "identify": return this._onToggleIdentify(item);
case "prepare": return this._onTogglePrepared(item);
case "recharge": return this._onRollRecharge(activity ?? item, { event });
case "removeEnchantment": return this._onRemoveEnchantment(item);
case "toggleCharge": return this._onToggleCharge(item);
case "toggleExpand": return this._onToggleExpand(target, { item });
case "toggleFavorite": return this._onToggleFavorite(item);
Expand Down Expand Up @@ -630,6 +638,21 @@ export default class InventoryElement extends (foundry.applications.elements.Ado

/* -------------------------------------------- */

/**
* Handle removing all applied enchantments from an item.
* @param {Item5e} item The item.
* @returns {Promise}
* @protected
*/
_onRemoveEnchantment(item) {
const ids = item.effects
.filter(e => e.isAppliedEnchantment && !e.getFlag("dnd5e", "static"))
.map(e => e.id);
return item.deleteEmbeddedDocuments("ActiveEffect", ids);
}

/* -------------------------------------------- */

/**
* Handle recharging an item.
* @param {Item5e|Activity} entry The entity being recharged.
Expand Down
3 changes: 2 additions & 1 deletion module/data/activity/enchant-data.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ export default class BaseEnchantActivityData extends BaseActivityData {
activity: new SetField(new DocumentIdField()),
effect: new SetField(new DocumentIdField()),
item: new SetField(new DocumentUUIDField({ type: "Item" }))
})
}),
static: new BooleanField()
})),
enchant: new SchemaField({
self: new BooleanField()
Expand Down
1 change: 1 addition & 0 deletions module/documents/activity/enchant.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ export default class EnchantActivity extends ActivityMixin(BaseEnchantActivityDa

const flags = { enchantmentProfile: profile };
if ( concentration ) flags.dependentOn = concentration.uuid;
if ( this.effects.find(e => e._id === profile)?.static ) flags.static = true;
const enchantmentData = effect.clone({ origin: this.uuid, "flags.dnd5e": flags }).toObject();

/**
Expand Down
2 changes: 2 additions & 0 deletions templates/activity/parts/enchant-enchantments.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@
</div>
<p class="hint">{{ localize "DND5E.ENCHANT.FIELDS.effects.element.level.hint" }}</p>
</div>
{{ formField fields.static name=(concat prefix "static") value=data.static
input=@root.inputs.createCheckboxInput rootId=@root.partId }}
{{#with fields.riders.fields as |fields|}}
{{ formField fields.activity name=(concat ../prefix "riders.activity") options=../activityOptions
rootId=@root.partId }}
Expand Down