From e7f73d0e542a84a3d5bd6fc83fb185614c8e0715 Mon Sep 17 00:00:00 2001 From: Stefan Zermatten Date: Wed, 17 Aug 2022 09:39:45 +0200 Subject: [PATCH] Stopped crystalizing variables in nested buffs --- .../engine/actions/applyPropertyByType/applyBuff.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/app/imports/api/engine/actions/applyPropertyByType/applyBuff.js b/app/imports/api/engine/actions/applyPropertyByType/applyBuff.js index b6e7d682..965ef8b3 100644 --- a/app/imports/api/engine/actions/applyPropertyByType/applyBuff.js +++ b/app/imports/api/engine/actions/applyPropertyByType/applyBuff.js @@ -21,10 +21,14 @@ export default function applyBuff(node, actionContext){ // Then copy the decendants of the buff to the targets let propList = [prop]; - function addChildrenToPropList(children){ + function addChildrenToPropList(children, { skipCrystalize } = {}){ children.forEach(child => { + if (skipCrystalize) child.node._skipCrystalize = true; propList.push(child.node); - addChildrenToPropList(child.children); + // recursively add the child's children, but don't crystalize nested buffs + addChildrenToPropList(child.children, { + skipCrystalize: skipCrystalize || child.node.type === 'buff' + }); }); } addChildrenToPropList(node.children); @@ -88,6 +92,10 @@ function copyNodeListToTarget(propList, target, oldParent){ */ function crystalizeVariables({propList, actionContext}){ propList.forEach(prop => { + if (prop._skipCrystalize) { + delete prop._skipCrystalize; + return; + } computedSchemas[prop.type].computedFields().forEach( calcKey => { applyFnToKey(prop, calcKey, (prop, key) => { const calcObj = get(prop, key);