mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-17 07:36:26 +01:00
Added DestroyOnEmpty property
This commit is contained in:
parent
4dfc18f727
commit
7082cc009f
65 changed files with 87 additions and 20 deletions
|
|
@ -2125,7 +2125,8 @@
|
|||
}
|
||||
},
|
||||
"Consumable": {
|
||||
"consumeOnUse": "Consume On Use"
|
||||
"consumeOnUse": "Consume On Use",
|
||||
"destroyOnEmpty": "Destroy On Empty"
|
||||
},
|
||||
"DomainCard": {
|
||||
"type": "Type",
|
||||
|
|
|
|||
|
|
@ -199,14 +199,16 @@ export default class CostField extends fields.ArrayField {
|
|||
switch (r.key) {
|
||||
case CONFIG.DH.GENERAL.itemAbilityCosts.resource.id:
|
||||
return {
|
||||
'system.resource.value': r.target.system.resource.value + r.value
|
||||
path: 'system.resource.value',
|
||||
value: r.target.system.resource.value + r.value
|
||||
};
|
||||
case CONFIG.DH.GENERAL.itemAbilityCosts.quantity.id:
|
||||
return {
|
||||
'system.quantity': r.target.system.quantity + r.value
|
||||
path: 'system.quantity',
|
||||
value: r.target.system.quantity + r.value
|
||||
};
|
||||
default:
|
||||
return {};
|
||||
return { path: '', value: undefined };
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
import BaseDataItem from './base.mjs';
|
||||
import { ActionField } from '../fields/actionField.mjs';
|
||||
|
||||
export default class DHConsumable extends BaseDataItem {
|
||||
/** @inheritDoc */
|
||||
|
|
@ -19,7 +18,8 @@ export default class DHConsumable extends BaseDataItem {
|
|||
const fields = foundry.data.fields;
|
||||
return {
|
||||
...super.defineSchema(),
|
||||
consumeOnUse: new fields.BooleanField({ initial: false })
|
||||
consumeOnUse: new fields.BooleanField({ initial: true }),
|
||||
destroyOnEmpty: new fields.BooleanField({ initial: true })
|
||||
};
|
||||
}
|
||||
|
||||
|
|
@ -27,14 +27,4 @@ export default class DHConsumable extends BaseDataItem {
|
|||
|
||||
/**@override */
|
||||
static DEFAULT_ICON = 'systems/daggerheart/assets/icons/documents/items/round-potion.svg';
|
||||
|
||||
async _preUpdate(changes, options, userId) {
|
||||
const allowed = await super._preUpdate(changes, options, userId);
|
||||
if (allowed === false) return;
|
||||
|
||||
if (changes.system?.quantity !== undefined && Number(changes.system.quantity) === 0) {
|
||||
this.parent.delete();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -660,10 +660,21 @@ export default class DhpActor extends Actor {
|
|||
|
||||
resources.forEach(r => {
|
||||
if (r.itemId) {
|
||||
updates.items[r.key] = {
|
||||
target: r.target,
|
||||
resources: game.system.api.fields.ActionFields.CostField.getItemIdCostUpdate(r)
|
||||
};
|
||||
const { path, value } = game.system.api.fields.ActionFields.CostField.getItemIdCostUpdate(r);
|
||||
|
||||
if (
|
||||
r.key === 'quantity' &&
|
||||
r.target.type === 'consumable' &&
|
||||
value === 0 &&
|
||||
r.target.system.destroyOnEmpty
|
||||
) {
|
||||
r.target.delete();
|
||||
} else {
|
||||
updates.items[r.key] = {
|
||||
target: r.target,
|
||||
resources: { [path]: value }
|
||||
};
|
||||
}
|
||||
} else {
|
||||
switch (r.key) {
|
||||
case 'fear':
|
||||
|
|
|
|||
|
|
@ -40,6 +40,7 @@
|
|||
}
|
||||
},
|
||||
"consumeOnUse": true,
|
||||
"destroyOnEmpty": true,
|
||||
"attribution": {
|
||||
"source": "Daggerheart SRD",
|
||||
"page": 61,
|
||||
|
|
|
|||
|
|
@ -48,6 +48,7 @@
|
|||
}
|
||||
},
|
||||
"consumeOnUse": true,
|
||||
"destroyOnEmpty": true,
|
||||
"attribution": {
|
||||
"source": "Daggerheart SRD",
|
||||
"page": 61,
|
||||
|
|
|
|||
|
|
@ -45,6 +45,7 @@
|
|||
}
|
||||
},
|
||||
"consumeOnUse": true,
|
||||
"destroyOnEmpty": true,
|
||||
"attribution": {
|
||||
"source": "Daggerheart SRD",
|
||||
"page": 60,
|
||||
|
|
|
|||
|
|
@ -45,6 +45,7 @@
|
|||
}
|
||||
},
|
||||
"consumeOnUse": true,
|
||||
"destroyOnEmpty": true,
|
||||
"attribution": {
|
||||
"source": "Daggerheart SRD",
|
||||
"page": 62,
|
||||
|
|
|
|||
|
|
@ -40,6 +40,7 @@
|
|||
}
|
||||
},
|
||||
"consumeOnUse": true,
|
||||
"destroyOnEmpty": true,
|
||||
"attribution": {
|
||||
"source": "Daggerheart SRD",
|
||||
"page": 61,
|
||||
|
|
|
|||
|
|
@ -45,6 +45,7 @@
|
|||
}
|
||||
},
|
||||
"consumeOnUse": true,
|
||||
"destroyOnEmpty": true,
|
||||
"attribution": {
|
||||
"source": "Daggerheart SRD",
|
||||
"page": 60,
|
||||
|
|
|
|||
|
|
@ -40,6 +40,7 @@
|
|||
}
|
||||
},
|
||||
"consumeOnUse": true,
|
||||
"destroyOnEmpty": true,
|
||||
"attribution": {
|
||||
"source": "Daggerheart SRD",
|
||||
"page": 62,
|
||||
|
|
|
|||
|
|
@ -40,6 +40,7 @@
|
|||
}
|
||||
},
|
||||
"consumeOnUse": true,
|
||||
"destroyOnEmpty": true,
|
||||
"attribution": {
|
||||
"source": "Daggerheart SRD",
|
||||
"page": 61,
|
||||
|
|
|
|||
|
|
@ -40,6 +40,7 @@
|
|||
}
|
||||
},
|
||||
"consumeOnUse": true,
|
||||
"destroyOnEmpty": true,
|
||||
"attribution": {
|
||||
"source": "Daggerheart SRD",
|
||||
"page": 61,
|
||||
|
|
|
|||
|
|
@ -45,6 +45,7 @@
|
|||
}
|
||||
},
|
||||
"consumeOnUse": true,
|
||||
"destroyOnEmpty": true,
|
||||
"attribution": {
|
||||
"source": "Daggerheart SRD",
|
||||
"page": 60,
|
||||
|
|
|
|||
|
|
@ -40,6 +40,7 @@
|
|||
}
|
||||
},
|
||||
"consumeOnUse": true,
|
||||
"destroyOnEmpty": true,
|
||||
"attribution": {
|
||||
"source": "Daggerheart SRD",
|
||||
"page": 61,
|
||||
|
|
|
|||
|
|
@ -45,6 +45,7 @@
|
|||
}
|
||||
},
|
||||
"consumeOnUse": true,
|
||||
"destroyOnEmpty": true,
|
||||
"attribution": {
|
||||
"source": "Daggerheart SRD",
|
||||
"page": 60,
|
||||
|
|
|
|||
|
|
@ -45,6 +45,7 @@
|
|||
}
|
||||
},
|
||||
"consumeOnUse": true,
|
||||
"destroyOnEmpty": true,
|
||||
"attribution": {
|
||||
"source": "Daggerheart SRD",
|
||||
"page": 62,
|
||||
|
|
|
|||
|
|
@ -89,6 +89,7 @@
|
|||
}
|
||||
},
|
||||
"consumeOnUse": true,
|
||||
"destroyOnEmpty": true,
|
||||
"attribution": {
|
||||
"source": "Daggerheart SRD",
|
||||
"page": 61,
|
||||
|
|
|
|||
|
|
@ -71,6 +71,7 @@
|
|||
}
|
||||
},
|
||||
"consumeOnUse": true,
|
||||
"destroyOnEmpty": true,
|
||||
"attribution": {
|
||||
"source": "Daggerheart SRD",
|
||||
"page": 61,
|
||||
|
|
|
|||
|
|
@ -45,6 +45,7 @@
|
|||
}
|
||||
},
|
||||
"consumeOnUse": true,
|
||||
"destroyOnEmpty": true,
|
||||
"attribution": {
|
||||
"source": "Daggerheart SRD",
|
||||
"page": 60,
|
||||
|
|
|
|||
|
|
@ -134,6 +134,7 @@
|
|||
}
|
||||
},
|
||||
"consumeOnUse": true,
|
||||
"destroyOnEmpty": true,
|
||||
"attribution": {
|
||||
"source": "Daggerheart SRD",
|
||||
"page": 62,
|
||||
|
|
|
|||
|
|
@ -45,6 +45,7 @@
|
|||
}
|
||||
},
|
||||
"consumeOnUse": true,
|
||||
"destroyOnEmpty": true,
|
||||
"attribution": {
|
||||
"source": "Daggerheart SRD",
|
||||
"page": 61,
|
||||
|
|
|
|||
|
|
@ -45,6 +45,7 @@
|
|||
}
|
||||
},
|
||||
"consumeOnUse": true,
|
||||
"destroyOnEmpty": true,
|
||||
"attribution": {
|
||||
"source": "Daggerheart SRD",
|
||||
"page": 61,
|
||||
|
|
|
|||
|
|
@ -45,6 +45,7 @@
|
|||
}
|
||||
},
|
||||
"consumeOnUse": true,
|
||||
"destroyOnEmpty": true,
|
||||
"attribution": {
|
||||
"source": "Daggerheart SRD",
|
||||
"page": 60,
|
||||
|
|
|
|||
|
|
@ -45,6 +45,7 @@
|
|||
}
|
||||
},
|
||||
"consumeOnUse": true,
|
||||
"destroyOnEmpty": true,
|
||||
"attribution": {
|
||||
"source": "Daggerheart SRD",
|
||||
"page": 62,
|
||||
|
|
|
|||
|
|
@ -84,6 +84,7 @@
|
|||
}
|
||||
},
|
||||
"consumeOnUse": true,
|
||||
"destroyOnEmpty": true,
|
||||
"attribution": {
|
||||
"source": "Daggerheart SRD",
|
||||
"page": 61,
|
||||
|
|
|
|||
|
|
@ -45,6 +45,7 @@
|
|||
}
|
||||
},
|
||||
"consumeOnUse": true,
|
||||
"destroyOnEmpty": true,
|
||||
"attribution": {
|
||||
"source": "Daggerheart SRD",
|
||||
"page": 61,
|
||||
|
|
|
|||
|
|
@ -40,6 +40,7 @@
|
|||
}
|
||||
},
|
||||
"consumeOnUse": true,
|
||||
"destroyOnEmpty": true,
|
||||
"attribution": {
|
||||
"source": "Daggerheart SRD",
|
||||
"page": 61,
|
||||
|
|
|
|||
|
|
@ -91,6 +91,7 @@
|
|||
}
|
||||
},
|
||||
"consumeOnUse": true,
|
||||
"destroyOnEmpty": true,
|
||||
"attribution": {
|
||||
"source": "Daggerheart SRD",
|
||||
"page": 61,
|
||||
|
|
|
|||
|
|
@ -45,6 +45,7 @@
|
|||
}
|
||||
},
|
||||
"consumeOnUse": true,
|
||||
"destroyOnEmpty": true,
|
||||
"attribution": {
|
||||
"source": "Daggerheart SRD",
|
||||
"page": 60,
|
||||
|
|
|
|||
|
|
@ -71,6 +71,7 @@
|
|||
}
|
||||
},
|
||||
"consumeOnUse": true,
|
||||
"destroyOnEmpty": true,
|
||||
"attribution": {
|
||||
"source": "Daggerheart SRD",
|
||||
"page": 61,
|
||||
|
|
|
|||
|
|
@ -40,6 +40,7 @@
|
|||
}
|
||||
},
|
||||
"consumeOnUse": true,
|
||||
"destroyOnEmpty": true,
|
||||
"attribution": {
|
||||
"source": "Daggerheart SRD",
|
||||
"page": 61,
|
||||
|
|
|
|||
|
|
@ -40,6 +40,7 @@
|
|||
}
|
||||
},
|
||||
"consumeOnUse": true,
|
||||
"destroyOnEmpty": true,
|
||||
"attribution": {
|
||||
"source": "Daggerheart SRD",
|
||||
"page": 62,
|
||||
|
|
|
|||
|
|
@ -89,6 +89,7 @@
|
|||
}
|
||||
},
|
||||
"consumeOnUse": true,
|
||||
"destroyOnEmpty": true,
|
||||
"attribution": {
|
||||
"source": "Daggerheart SRD",
|
||||
"page": 61,
|
||||
|
|
|
|||
|
|
@ -45,6 +45,7 @@
|
|||
}
|
||||
},
|
||||
"consumeOnUse": true,
|
||||
"destroyOnEmpty": true,
|
||||
"attribution": {
|
||||
"source": "Daggerheart SRD",
|
||||
"page": 61,
|
||||
|
|
|
|||
|
|
@ -45,6 +45,7 @@
|
|||
}
|
||||
},
|
||||
"consumeOnUse": true,
|
||||
"destroyOnEmpty": true,
|
||||
"attribution": {
|
||||
"source": "Daggerheart SRD",
|
||||
"page": 61,
|
||||
|
|
|
|||
|
|
@ -45,6 +45,7 @@
|
|||
}
|
||||
},
|
||||
"consumeOnUse": true,
|
||||
"destroyOnEmpty": true,
|
||||
"attribution": {
|
||||
"source": "Daggerheart SRD",
|
||||
"page": 61,
|
||||
|
|
|
|||
|
|
@ -45,6 +45,7 @@
|
|||
}
|
||||
},
|
||||
"consumeOnUse": true,
|
||||
"destroyOnEmpty": true,
|
||||
"attribution": {
|
||||
"source": "Daggerheart SRD",
|
||||
"page": 61,
|
||||
|
|
|
|||
|
|
@ -45,6 +45,7 @@
|
|||
}
|
||||
},
|
||||
"consumeOnUse": true,
|
||||
"destroyOnEmpty": true,
|
||||
"attribution": {
|
||||
"source": "Daggerheart SRD",
|
||||
"page": 61,
|
||||
|
|
|
|||
|
|
@ -84,6 +84,7 @@
|
|||
}
|
||||
},
|
||||
"consumeOnUse": true,
|
||||
"destroyOnEmpty": true,
|
||||
"attribution": {
|
||||
"source": "Daggerheart SRD",
|
||||
"page": 61,
|
||||
|
|
|
|||
|
|
@ -84,6 +84,7 @@
|
|||
}
|
||||
},
|
||||
"consumeOnUse": true,
|
||||
"destroyOnEmpty": true,
|
||||
"attribution": {
|
||||
"source": "Daggerheart SRD",
|
||||
"page": 61,
|
||||
|
|
|
|||
|
|
@ -45,6 +45,7 @@
|
|||
}
|
||||
},
|
||||
"consumeOnUse": true,
|
||||
"destroyOnEmpty": true,
|
||||
"attribution": {
|
||||
"source": "Daggerheart SRD",
|
||||
"page": 61,
|
||||
|
|
|
|||
|
|
@ -84,6 +84,7 @@
|
|||
}
|
||||
},
|
||||
"consumeOnUse": true,
|
||||
"destroyOnEmpty": true,
|
||||
"attribution": {
|
||||
"source": "Daggerheart SRD",
|
||||
"page": 60,
|
||||
|
|
|
|||
|
|
@ -84,6 +84,7 @@
|
|||
}
|
||||
},
|
||||
"consumeOnUse": true,
|
||||
"destroyOnEmpty": true,
|
||||
"attribution": {
|
||||
"source": "Daggerheart SRD",
|
||||
"page": 60,
|
||||
|
|
|
|||
|
|
@ -40,6 +40,7 @@
|
|||
}
|
||||
},
|
||||
"consumeOnUse": true,
|
||||
"destroyOnEmpty": true,
|
||||
"attribution": {
|
||||
"source": "Daggerheart SRD",
|
||||
"page": 62,
|
||||
|
|
|
|||
|
|
@ -45,6 +45,7 @@
|
|||
}
|
||||
},
|
||||
"consumeOnUse": true,
|
||||
"destroyOnEmpty": true,
|
||||
"attribution": {
|
||||
"source": "Daggerheart SRD",
|
||||
"page": 61,
|
||||
|
|
|
|||
|
|
@ -45,6 +45,7 @@
|
|||
}
|
||||
},
|
||||
"consumeOnUse": true,
|
||||
"destroyOnEmpty": true,
|
||||
"attribution": {
|
||||
"source": "Daggerheart SRD",
|
||||
"page": 61,
|
||||
|
|
|
|||
|
|
@ -45,6 +45,7 @@
|
|||
}
|
||||
},
|
||||
"consumeOnUse": true,
|
||||
"destroyOnEmpty": true,
|
||||
"attribution": {
|
||||
"source": "Daggerheart SRD",
|
||||
"page": 61,
|
||||
|
|
|
|||
|
|
@ -45,6 +45,7 @@
|
|||
}
|
||||
},
|
||||
"consumeOnUse": true,
|
||||
"destroyOnEmpty": true,
|
||||
"attribution": {
|
||||
"source": "Daggerheart SRD",
|
||||
"page": 60,
|
||||
|
|
|
|||
|
|
@ -45,6 +45,7 @@
|
|||
}
|
||||
},
|
||||
"consumeOnUse": true,
|
||||
"destroyOnEmpty": true,
|
||||
"attribution": {
|
||||
"source": "Daggerheart SRD",
|
||||
"page": 61,
|
||||
|
|
|
|||
|
|
@ -40,6 +40,7 @@
|
|||
}
|
||||
},
|
||||
"consumeOnUse": true,
|
||||
"destroyOnEmpty": true,
|
||||
"attribution": {
|
||||
"source": "Daggerheart SRD",
|
||||
"page": 61,
|
||||
|
|
|
|||
|
|
@ -45,6 +45,7 @@
|
|||
}
|
||||
},
|
||||
"consumeOnUse": true,
|
||||
"destroyOnEmpty": true,
|
||||
"attribution": {
|
||||
"source": "Daggerheart SRD",
|
||||
"page": 62,
|
||||
|
|
|
|||
|
|
@ -85,6 +85,7 @@
|
|||
}
|
||||
},
|
||||
"consumeOnUse": true,
|
||||
"destroyOnEmpty": true,
|
||||
"attribution": {
|
||||
"source": "Daggerheart SRD",
|
||||
"page": 62,
|
||||
|
|
|
|||
|
|
@ -85,6 +85,7 @@
|
|||
}
|
||||
},
|
||||
"consumeOnUse": true,
|
||||
"destroyOnEmpty": true,
|
||||
"attribution": {
|
||||
"source": "Daggerheart SRD",
|
||||
"page": 61,
|
||||
|
|
|
|||
|
|
@ -84,6 +84,7 @@
|
|||
}
|
||||
},
|
||||
"consumeOnUse": true,
|
||||
"destroyOnEmpty": true,
|
||||
"attribution": {
|
||||
"source": "Daggerheart SRD",
|
||||
"page": 61,
|
||||
|
|
|
|||
|
|
@ -71,6 +71,7 @@
|
|||
}
|
||||
},
|
||||
"consumeOnUse": true,
|
||||
"destroyOnEmpty": true,
|
||||
"attribution": {
|
||||
"source": "Daggerheart SRD",
|
||||
"page": 62,
|
||||
|
|
|
|||
|
|
@ -45,6 +45,7 @@
|
|||
}
|
||||
},
|
||||
"consumeOnUse": true,
|
||||
"destroyOnEmpty": true,
|
||||
"attribution": {
|
||||
"source": "Daggerheart SRD",
|
||||
"page": 60,
|
||||
|
|
|
|||
|
|
@ -64,6 +64,7 @@
|
|||
}
|
||||
},
|
||||
"consumeOnUse": true,
|
||||
"destroyOnEmpty": true,
|
||||
"attribution": {
|
||||
"source": "Daggerheart SRD",
|
||||
"page": 61,
|
||||
|
|
|
|||
|
|
@ -159,6 +159,7 @@
|
|||
}
|
||||
},
|
||||
"consumeOnUse": true,
|
||||
"destroyOnEmpty": true,
|
||||
"attribution": {
|
||||
"source": "Daggerheart SRD",
|
||||
"page": 62,
|
||||
|
|
|
|||
|
|
@ -91,6 +91,7 @@
|
|||
}
|
||||
},
|
||||
"consumeOnUse": true,
|
||||
"destroyOnEmpty": true,
|
||||
"attribution": {
|
||||
"source": "Daggerheart SRD",
|
||||
"page": 60,
|
||||
|
|
|
|||
|
|
@ -85,6 +85,7 @@
|
|||
}
|
||||
},
|
||||
"consumeOnUse": true,
|
||||
"destroyOnEmpty": true,
|
||||
"attribution": {
|
||||
"source": "Daggerheart SRD",
|
||||
"page": 60,
|
||||
|
|
|
|||
|
|
@ -40,6 +40,7 @@
|
|||
}
|
||||
},
|
||||
"consumeOnUse": true,
|
||||
"destroyOnEmpty": true,
|
||||
"attribution": {
|
||||
"source": "Daggerheart SRD",
|
||||
"page": 61,
|
||||
|
|
|
|||
|
|
@ -45,6 +45,7 @@
|
|||
}
|
||||
},
|
||||
"consumeOnUse": true,
|
||||
"destroyOnEmpty": true,
|
||||
"attribution": {
|
||||
"source": "Daggerheart SRD",
|
||||
"page": 60,
|
||||
|
|
|
|||
|
|
@ -45,6 +45,7 @@
|
|||
}
|
||||
},
|
||||
"consumeOnUse": true,
|
||||
"destroyOnEmpty": true,
|
||||
"attribution": {
|
||||
"source": "Daggerheart SRD",
|
||||
"page": 61,
|
||||
|
|
|
|||
|
|
@ -10,5 +10,8 @@
|
|||
|
||||
<span>{{localize "DAGGERHEART.ITEMS.Consumable.consumeOnUse"}}</span>
|
||||
{{formField systemFields.consumeOnUse value=source.system.consumeOnUse}}
|
||||
|
||||
<span>{{localize "DAGGERHEART.ITEMS.Consumable.destroyOnEmpty"}}</span>
|
||||
{{formField systemFields.destroyOnEmpty value=source.system.destroyOnEmpty}}
|
||||
</fieldset>
|
||||
</section>
|
||||
Loading…
Add table
Add a link
Reference in a new issue