From c6a3619178c9a8c17d6b3b057a906cdbd79cdee3 Mon Sep 17 00:00:00 2001 From: Stefan Zermatten Date: Wed, 17 May 2023 13:50:22 +0200 Subject: [PATCH] Added tag-targeted profs to calculation viewers --- .../computeByType/computeCalculation.js | 19 +++-- .../CreaturePropertyDialog.vue | 1 - .../proficiencies/InlineProficiency.vue | 85 +++++++++++++++++++ .../viewers/shared/PropertyField.vue | 14 ++- 4 files changed, 110 insertions(+), 9 deletions(-) create mode 100644 app/imports/client/ui/properties/components/proficiencies/InlineProficiency.vue diff --git a/app/imports/api/engine/computation/computeComputation/computeByType/computeCalculation.js b/app/imports/api/engine/computation/computeComputation/computeByType/computeCalculation.js index de395906..3f6367c3 100644 --- a/app/imports/api/engine/computation/computeComputation/computeByType/computeCalculation.js +++ b/app/imports/api/engine/computation/computeComputation/computeByType/computeCalculation.js @@ -3,6 +3,9 @@ import evaluateCalculation from '../../utility/evaluateCalculation.js'; export default function computeCalculation(computation, node) { const calcObj = node.data; evaluateCalculation(calcObj, computation.scope); + if (calcObj.effects || calcObj.proficiencies) { + calcObj.baseValue = calcObj.value; + } aggregateCalculationEffects(node, computation); aggregateCalculationProficiencies(node, computation); } @@ -36,7 +39,6 @@ function aggregateCalculationEffects(node, computation) { true // enumerate only outbound links ); if (calcObj.effects && typeof calcObj.value === 'number') { - calcObj.baseValue = calcObj.value; calcObj.effects.forEach(effect => { if ( effect.operation === 'add' && @@ -71,23 +73,28 @@ function aggregateCalculationProficiencies(node, computation) { }, true // enumerate only outbound links ); - if (calcObj.proficiencies) { + if (calcObj.proficiencies && typeof calcObj.value === 'number') { calcObj.proficiency = 0; + let currentProf; calcObj.proficiencies.forEach(prof => { if (prof.value > calcObj.proficiency) { + if (currentProf) currentProf.overridden = true; calcObj.proficiency = prof.value; + } else { + prof.overridden = true; } }); // Get the character's proficiency bonus to apply let profBonus = computation.scope['proficiencyBonus']?.value || 0; - + calcObj.proficiencyBonus = profBonus; + let totalBonus; // Multiply the proficiency bonus by the actual proficiency if (calcObj.proficiency === 0.49) { // Round down proficiency bonus in the special case - calcObj.proficiencyBonus = Math.floor(profBonus * 0.5); + totalBonus = Math.floor(profBonus * 0.5); } else { - calcObj.proficiencyBonus = Math.ceil(profBonus * calcObj.proficiency); + totalBonus = Math.ceil(profBonus * calcObj.proficiency); } - calcObj.value += calcObj.proficiencyBonus; + calcObj.value += totalBonus; } } diff --git a/app/imports/client/ui/creature/creatureProperties/CreaturePropertyDialog.vue b/app/imports/client/ui/creature/creatureProperties/CreaturePropertyDialog.vue index fa813936..a485608c 100644 --- a/app/imports/client/ui/creature/creatureProperties/CreaturePropertyDialog.vue +++ b/app/imports/client/ui/creature/creatureProperties/CreaturePropertyDialog.vue @@ -211,7 +211,6 @@ export default { }, change(arg) { const { path, value, ack } = arg; - console.log('creaturePropDialogChangeHandler', arg); if (path && path[0] === 'equipped'){ equipItem.call({_id: this.currentId, equipped: value}, ack); return; diff --git a/app/imports/client/ui/properties/components/proficiencies/InlineProficiency.vue b/app/imports/client/ui/properties/components/proficiencies/InlineProficiency.vue new file mode 100644 index 00000000..72ee4c01 --- /dev/null +++ b/app/imports/client/ui/properties/components/proficiencies/InlineProficiency.vue @@ -0,0 +1,85 @@ + + + + + diff --git a/app/imports/client/ui/properties/viewers/shared/PropertyField.vue b/app/imports/client/ui/properties/viewers/shared/PropertyField.vue index 9daf1d04..af86f555 100644 --- a/app/imports/client/ui/properties/viewers/shared/PropertyField.vue +++ b/app/imports/client/ui/properties/viewers/shared/PropertyField.vue @@ -49,7 +49,7 @@
@@ -70,6 +70,14 @@ :model="effect" @click="clickEffect(effect._id)" /> +
@@ -77,12 +85,14 @@