diff --git a/src/scripts/magic-item/OwnedMagicItem.js b/src/scripts/magic-item/OwnedMagicItem.js index 0a77348..a494f0c 100644 --- a/src/scripts/magic-item/OwnedMagicItem.js +++ b/src/scripts/magic-item/OwnedMagicItem.js @@ -136,25 +136,25 @@ export class OwnedMagicItem extends MagicItem { return destroyed; } - onShortRest() { + async onShortRest() { if (this.rechargeable && this.rechargeUnit === MAGICITEMS.SHORT_REST) { - return this.doRecharge(); + return await this.doRecharge(); } } - onLongRest() { + async onLongRest() { if (this.rechargeable && [MAGICITEMS.LONG_REST, MAGICITEMS.SHORT_REST].includes(this.rechargeUnit)) { - return this.doRecharge(); + return await this.doRecharge(); } } - onNewDay() { + async onNewDay() { if (this.rechargeable && [MAGICITEMS.DAILY, MAGICITEMS.DAWN, MAGICITEMS.SUNSET].includes(this.rechargeUnit)) { - return this.doRecharge(); + return await this.doRecharge(); } } - doRecharge() { + async doRecharge() { let amount = 0, updated = 0, msg = `Magic Item: ${this.rechargeableLabel}
`; @@ -167,7 +167,7 @@ export class OwnedMagicItem extends MagicItem { } if (this.rechargeType === MAGICITEMS.FORMULA_RECHARGE) { let r = new Roll(this.recharge); - r.evaluate({ async: false }); + await r.evaluate(); amount = r.total; msg += `${prefix}: ${r.result} = ${r.total} ${postfix}`; } diff --git a/src/scripts/magicitemactor.js b/src/scripts/magicitemactor.js index 234da8c..aacf808 100644 --- a/src/scripts/magicitemactor.js +++ b/src/scripts/magicitemactor.js @@ -95,7 +95,7 @@ export class MagicItemActor { shortRest(original, me) { return async function () { let result = await original.apply(me.actor, arguments); - me.onShortRest(result); + await me.onShortRest(result); return result; }; } @@ -109,7 +109,7 @@ export class MagicItemActor { longRest(original, me) { return async function () { let result = await original.apply(me.actor, arguments); - me.onLongRest(result); + await me.onLongRest(result); return result; }; } @@ -151,10 +151,10 @@ export class MagicItemActor { * * @param result */ - onShortRest(result) { + async onShortRest(result) { if (result) { - this.items.forEach((item) => { - item.onShortRest(); + this.items.forEach(async (item) => { + await item.onShortRest(); if (result.newDay) item.onNewDay(); }); this.fireChange(); @@ -167,10 +167,10 @@ export class MagicItemActor { * * @param result */ - onLongRest(result) { + async onLongRest(result) { if (result) { - this.items.forEach((item) => { - item.onLongRest(); + this.items.forEach(async (item) => { + await item.onLongRest(); if (result.newDay) item.onNewDay(); }); this.fireChange();