[Feature] 1033 - Consume Quantity On Use (#1106)

* Initial migration

* Updated compendium YML

* Added Quantity as a possible cost

* Added quantity consumption to all Compendium Consumables

* .

* Added DestroyOnEmpty property
This commit is contained in:
WBHarry 2025-08-28 18:29:17 +02:00 committed by GitHub
parent 9dd773001d
commit 8fd63d5963
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
397 changed files with 1276 additions and 930 deletions

View file

@ -659,13 +659,22 @@ export default class DhpActor extends Actor {
};
resources.forEach(r => {
if (r.keyIsID) {
updates.items[r.key] = {
target: r.target,
resources: {
'system.resource.value': r.target.system.resource.value + r.value
}
};
if (r.itemId) {
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':