From 893f2aa835787b77f4585cf6ff9bbc05cc6bd821 Mon Sep 17 00:00:00 2001 From: Vincent Vandemeulebrouck Date: Sun, 11 Apr 2021 23:02:53 +0200 Subject: [PATCH] Minor cleanup ActiveEffect --- module/actor.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/module/actor.js b/module/actor.js index a3efca07..18ba9bb0 100644 --- a/module/actor.js +++ b/module/actor.js @@ -3502,7 +3502,9 @@ export class RdDActor extends Actor { const ids = Array.from(this.effects?.values()) .filter(it => it.data.flags.core?.statusId == id) .map(it => it.id); - this.deleteEmbeddedDocuments('ActiveEffect', ids); + if (ids.length > 0) { + this.deleteEmbeddedDocuments('ActiveEffect', ids); + } } /* -------------------------------------------- */ @@ -3521,8 +3523,9 @@ export class RdDActor extends Actor { /* -------------------------------------------- */ async addStatusEffect(statusEffect) { - const effet = duplicate(statusEffect); + const effet = Misc.data(statusEffect); this.deleteStatusEffectById(effet.id); + effet.flags = effet.flags ?? { core: {} }; effet.flags.core.statusId = effet.id; await this.createEmbeddedDocuments('ActiveEffect', [effet]); }