mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-12 03:31:07 +01:00
[Feature] Item Resource Support (#328)
* Initial * Resource setup finished * Fixed so that costs can be used * Corrected standard resources * Actions can only use item resources from their parent item * Fixed up dice * Fixed resource dice positioning * Fixed parsing of resource.max * Fixed styling on settings tab * Added manual input for Dice Resources * Lightmode fixes * Fixed Feature spellcasting modifier * Bugfix for item input to resourceDiceDialog * Item fix for TokenInput * PR Fixes
This commit is contained in:
parent
eefa116d9a
commit
4be3e6179c
53 changed files with 972 additions and 329 deletions
|
|
@ -1,3 +1,5 @@
|
|||
import { itemAbleRollParse } from '../helpers/utils.mjs';
|
||||
|
||||
export default class DhActiveEffect extends ActiveEffect {
|
||||
get isSuppressed() {
|
||||
// If this is a copied effect from an attachment, never suppress it
|
||||
|
|
@ -24,16 +26,18 @@ export default class DhActiveEffect extends ActiveEffect {
|
|||
*/
|
||||
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);
|
||||
return (
|
||||
(item.type === 'armor' || item.type === 'weapon') &&
|
||||
item.system?.attached &&
|
||||
Array.isArray(item.system.attached) &&
|
||||
item.system.attached.includes(this.parent.uuid)
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -51,11 +55,7 @@ export default class DhActiveEffect extends ActiveEffect {
|
|||
}
|
||||
|
||||
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)
|
||||
);
|
||||
change.value = itemAbleRollParse(change.value, model, change.effect.parent);
|
||||
super.applyField(model, change, field);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue