fix: careful with tickingPromises

This commit is contained in:
cha0s 2019-09-08 08:11:51 -05:00
parent 53aae792cb
commit 049b4a9592
2 changed files with 8 additions and 3 deletions

View File

@ -72,7 +72,8 @@ export class Vulnerable extends Trait {
});
const tickingPromise = this._tookDamageActions.tickingPromise(
context
).then(() => {
);
tickingPromise.then(() => {
context.destroy();
});
this.damageTickingPromises.push(tickingPromise);

View File

@ -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);
},