From 417ff6e2100f8977e2828d9aa77eed6ab6d329ed Mon Sep 17 00:00:00 2001 From: Stefan Zermatten Date: Mon, 18 Oct 2021 13:46:38 +0200 Subject: [PATCH] Buffs no longer have the "applied" field, it was redundant Because children of actions are always inactive in the new engine, buffs that are children of actions are inactive while buffs elsewhere on the character sheet are active, making it redundant to keep the extra field --- .../actions/applyPropertyByType/applyBuff.js | 1 - .../buildComputation/computeInactiveStatus.js | 1 - .../parseCalculationFields.js | 3 +- .../tests/computeInactiveStatus.testFn.js | 28 ------- app/imports/api/properties/Buffs.js | 5 -- app/imports/ui/properties/forms/BuffForm.vue | 73 +++---------------- 6 files changed, 13 insertions(+), 98 deletions(-) diff --git a/app/imports/api/engine/actions/applyPropertyByType/applyBuff.js b/app/imports/api/engine/actions/applyPropertyByType/applyBuff.js index 405d48c8..af4210f6 100644 --- a/app/imports/api/engine/actions/applyPropertyByType/applyBuff.js +++ b/app/imports/api/engine/actions/applyPropertyByType/applyBuff.js @@ -15,7 +15,6 @@ export default function applyBuff(node, {creature, targets, scope, log}){ let buffTargets = prop.target === 'self' ? [creature] : targets; // Then copy the decendants of the buff to the targets - prop.applied = true; let propList = [prop]; function addChildrenToPropList(children){ children.forEach(child => { diff --git a/app/imports/api/engine/computation/buildComputation/computeInactiveStatus.js b/app/imports/api/engine/computation/buildComputation/computeInactiveStatus.js index 06847b46..2eb41428 100644 --- a/app/imports/api/engine/computation/buildComputation/computeInactiveStatus.js +++ b/app/imports/api/engine/computation/buildComputation/computeInactiveStatus.js @@ -19,7 +19,6 @@ export default function computeInactiveStatus(node){ function isActive(prop){ if (prop.disabled) return false; switch (prop.type){ - case 'buff': return !!prop.applied; case 'item': return !!prop.equipped; case 'spell': return !!prop.prepared || !!prop.alwaysPrepared; case 'note': return false; diff --git a/app/imports/api/engine/computation/buildComputation/parseCalculationFields.js b/app/imports/api/engine/computation/buildComputation/parseCalculationFields.js index 20244a8c..0daeb792 100644 --- a/app/imports/api/engine/computation/buildComputation/parseCalculationFields.js +++ b/app/imports/api/engine/computation/buildComputation/parseCalculationFields.js @@ -21,8 +21,9 @@ function discoverInlineCalculationFields(prop, schemas){ prop._computationDetails.inlineCalculations.push(inlineCalcObj); // Extract the calculations and store them on the property let string = inlineCalcObj.text; + // If there is no text, delete the whole field if (!string){ - delete inlineCalcObj.hash; + unset(prop, calcKey); return; } const inlineCalcHash = cyrb53(inlineCalcObj.text); diff --git a/app/imports/api/engine/computation/buildComputation/tests/computeInactiveStatus.testFn.js b/app/imports/api/engine/computation/buildComputation/tests/computeInactiveStatus.testFn.js index 19754fb9..ed210c76 100644 --- a/app/imports/api/engine/computation/buildComputation/tests/computeInactiveStatus.testFn.js +++ b/app/imports/api/engine/computation/buildComputation/tests/computeInactiveStatus.testFn.js @@ -8,12 +8,6 @@ export default function(){ const byAncestor = (propId, note) => assertDeactivatedByAncestor(computation, propId, note); const active = (propId, note) => assertActive(computation, propId, note); - // Buffs - bySelf('buffNotAppliedId'); - byAncestor('buffNotAppliedChildId'); - active('buffAppliedId'); - active('buffAppliedChildId'); - // Items active('itemUnequippedId', 'Unequipped items should be active'); byAncestor('itemUnequippedChildId', 'Children of unequipped items should be inactive'); @@ -53,28 +47,6 @@ function assertActive(computation, propId, note){ } var testProperties = [ - // Buffs - clean({ - _id: 'buffNotAppliedId', - type: 'buff', - ancestors: [{id: 'charId'}], - }), - clean({ - _id: 'buffNotAppliedChildId', - type: 'folder', - ancestors: [{id: 'charId'}, {id: 'buffNotAppliedId'}], - }), - clean({ - _id: 'buffAppliedId', - type: 'buff', - applied: true, - ancestors: [{id: 'charId'}], - }), - clean({ - _id: 'buffAppliedChildId', - type: 'folder', - ancestors: [{id: 'charId'}, {id: 'buffAppliedId'}], - }), // Items clean({ _id: 'itemUnequippedId', diff --git a/app/imports/api/properties/Buffs.js b/app/imports/api/properties/Buffs.js index 4fc01a7a..6bacabb9 100644 --- a/app/imports/api/properties/Buffs.js +++ b/app/imports/api/properties/Buffs.js @@ -17,11 +17,6 @@ let BuffSchema = createPropertySchema({ type: 'fieldToCompute', optional: true, }, - applied: { - type: Boolean, - defaultValue: false, - index: 1, - }, target: { type: String, allowedValues: [ diff --git a/app/imports/ui/properties/forms/BuffForm.vue b/app/imports/ui/properties/forms/BuffForm.vue index da60eadf..f55f05b0 100644 --- a/app/imports/ui/properties/forms/BuffForm.vue +++ b/app/imports/ui/properties/forms/BuffForm.vue @@ -7,26 +7,6 @@ :error-messages="errors.name" @change="change('name', ...arguments)" /> - - -
- - When buffs are applied they become active on a creature. - Turn this off if the buff needs to be applied to a target by an action - or spell. - -
-
-