From 1f64558100fd07c8903aa99ba0c69ab149e623cd Mon Sep 17 00:00:00 2001 From: Guillaume Derval Date: Sat, 7 Aug 2021 23:13:46 +0200 Subject: [PATCH] Fixed items/buffs/... refresh after casting a spell --- .../api/creature/actions/castSpellWithSlot.js | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/app/imports/api/creature/actions/castSpellWithSlot.js b/app/imports/api/creature/actions/castSpellWithSlot.js index 1b1408ff..9e2b3570 100644 --- a/app/imports/api/creature/actions/castSpellWithSlot.js +++ b/app/imports/api/creature/actions/castSpellWithSlot.js @@ -9,6 +9,8 @@ import { recomputeCreatureByDoc } from '/imports/api/creature/computation/method import { doActionWork } from '/imports/api/creature/actions/doAction.js'; import getRootCreatureAncestor from '/imports/api/creature/creatureProperties/getRootCreatureAncestor.js'; import getAncestorContext from '/imports/api/creature/actions/getAncestorContext.js'; +import recomputeInventory from '/imports/api/creature/denormalise/recomputeInventory'; +import recomputeInactiveProperties from '/imports/api/creature/denormalise/recomputeInactiveProperties'; const castSpellWithSlot = new ValidatedMethod({ name: 'creatureProperties.castSpellWithSlot', @@ -64,16 +66,24 @@ const castSpellWithSlot = new ValidatedMethod({ } let actionContext = getAncestorContext(spell); - doActionWork({ + doActionWork({ action: spell, actionContext: {slotLevel, ...actionContext}, creature, targets: target ? [target] : [], method: this, }); - // Note this only recomputes the top-level creature, not the nearest one - recomputeCreatureByDoc(creature); + + // Note these lines only recompute the top-level creature, not the nearest one + // The acting creature might have a new item + recomputeInventory(creature._id); + // The spell might add properties which need to be activated + recomputeInactiveProperties(creature._id); + recomputeCreatureByDoc(creature); + if (target){ + recomputeInventory(target._id); + recomputeInactiveProperties(target._id); recomputeCreatureByDoc(target); } },