mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-17 15:39:02 +01:00
Added DestroyOnEmpty property
This commit is contained in:
parent
4dfc18f727
commit
7082cc009f
65 changed files with 87 additions and 20 deletions
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue