From 049b4a9592c4bf2d6711ea46e766ce3959551a6f Mon Sep 17 00:00:00 2001 From: cha0s Date: Sun, 8 Sep 2019 08:11:51 -0500 Subject: [PATCH] fix: careful with tickingPromises --- common/combat/vulnerable.trait.js | 3 ++- common/traits/tool.trait.js | 8 ++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/common/combat/vulnerable.trait.js b/common/combat/vulnerable.trait.js index 318dcf1..4a87261 100644 --- a/common/combat/vulnerable.trait.js +++ b/common/combat/vulnerable.trait.js @@ -72,7 +72,8 @@ export class Vulnerable extends Trait { }); const tickingPromise = this._tookDamageActions.tickingPromise( context - ).then(() => { + ); + tickingPromise.then(() => { context.destroy(); }); this.damageTickingPromises.push(tickingPromise); diff --git a/common/traits/tool.trait.js b/common/traits/tool.trait.js index 126c9d1..c5d9bec 100644 --- a/common/traits/tool.trait.js +++ b/common/traits/tool.trait.js @@ -243,16 +243,20 @@ export class Tool extends decorate(Trait) { const promises = this.targets.map((target) => { // Set up. const context = this.createTargetContext(target); - return this.toolSetup.tickingPromise(context).then(() => { + const tickingPromise = this.toolSetup.tickingPromise(context); + tickingPromise.then(() => { // Check condition. if (!this.toolCondition.get(context)) { return; } // Execute actions. - return this.toolActions.tickingPromise(context).then(() => { + const tickingPromise = this.toolActions.tickingPromise(context); + tickingPromise.then(() => { context.destroy(); }); + return tickingPromise; }); + return tickingPromise; }) return TickingPromise.all(promises); },