diff --git a/app/imports/api/engine/actions/applyPropertyByType/applyAction.js b/app/imports/api/engine/actions/applyPropertyByType/applyAction.js index 021370d4..7587f9cc 100644 --- a/app/imports/api/engine/actions/applyPropertyByType/applyAction.js +++ b/app/imports/api/engine/actions/applyPropertyByType/applyAction.js @@ -72,10 +72,10 @@ function applyAttackWithoutTarget({ attack, actionContext }) { name += ' (Disadvantage)'; } if (!criticalMiss) { - scope['$attackHit'] = { value: true } + scope['$attackHit'] = true } if (!criticalHit) { - scope['$attackMiss'] = { value: true }; + scope['$attackMiss'] = true; } actionContext.addLog({ @@ -121,9 +121,9 @@ function applyAttackToTarget({ attack, target, actionContext }) { inline: true, }); if (criticalMiss || result < armor) { - scope['$attackMiss'] = { value: true }; + scope['$attackMiss'] = true; } else { - scope['$attackHit'] = { value: true }; + scope['$attackHit'] = true; } } else { actionContext.addLog({ @@ -163,9 +163,9 @@ function rollAttack(attack, scope) { value = rollDice(1, 20)[0]; resultPrefix = `1d20 [${value}] ${rollModifierText}` } - scope['$attackDiceRoll'] = { value }; + scope['$attackDiceRoll'] = value; const result = value + attack.value; - scope['$attackRoll'] = { value: result }; + scope['$attackRoll'] = result; const { criticalHit, criticalMiss } = applyCrits(value, scope); return { resultPrefix, result, value, criticalHit, criticalMiss }; } @@ -175,11 +175,11 @@ function applyCrits(value, scope) { let criticalHit = value >= criticalHitTarget; let criticalMiss; if (criticalHit) { - scope['$criticalHit'] = { value: true }; + scope['$criticalHit'] = true; } else { criticalMiss = value === 1; if (criticalMiss) { - scope['$criticalMiss'] = { value: true }; + scope['$criticalMiss'] = true; } } return { criticalHit, criticalMiss }; diff --git a/app/imports/api/engine/actions/applyPropertyByType/applyBranch.js b/app/imports/api/engine/actions/applyPropertyByType/applyBranch.js index ce918c4a..e02ac55a 100644 --- a/app/imports/api/engine/actions/applyPropertyByType/applyBranch.js +++ b/app/imports/api/engine/actions/applyPropertyByType/applyBranch.js @@ -3,22 +3,22 @@ import recalculateCalculation from './shared/recalculateCalculation.js'; import rollDice from '/imports/parser/rollDice.js'; import { applyNodeTriggers } from '/imports/api/engine/actions/applyTriggers.js'; -export default function applyBranch(node, actionContext){ +export default function applyBranch(node, actionContext) { applyNodeTriggers(node, 'before', actionContext); - const applyChildren = function(){ + const applyChildren = function () { applyNodeTriggers(node, 'after', actionContext); node.children.forEach(child => applyProperty(child, actionContext)); }; const scope = actionContext.scope; const targets = actionContext.targets; const prop = node.node; - switch(prop.branchType){ + switch (prop.branchType) { case 'if': recalculateCalculation(prop.condition, actionContext); if (prop.condition?.value) applyChildren(); break; case 'index': - if (node.children.length){ + if (node.children.length) { recalculateCalculation(prop.condition, actionContext); if (!isFinite(prop.condition?.value)) { actionContext.addLog({ @@ -35,31 +35,31 @@ export default function applyBranch(node, actionContext){ } break; case 'hit': - if (scope['$attackHit']?.value){ - if (!targets.length && !prop.silent) actionContext.addLog({value: '**On hit**'}); + if (scope['$attackHit']) { + if (!targets.length && !prop.silent) actionContext.addLog({ value: '**On hit**' }); applyChildren(); } break; case 'miss': - if (scope['$attackMiss']?.value){ - if (!targets.length && !prop.silent) actionContext.addLog({value: '**On miss**'}); + if (scope['$attackMiss']) { + if (!targets.length && !prop.silent) actionContext.addLog({ value: '**On miss**' }); applyChildren(); } break; case 'failedSave': - if (scope['$saveFailed']?.value){ - if (!targets.length && !prop.silent) actionContext.addLog({value: '**On failed save**'}); + if (scope['$saveFailed']) { + if (!targets.length && !prop.silent) actionContext.addLog({ value: '**On failed save**' }); applyChildren(); } break; case 'successfulSave': - if (scope['$saveSucceeded']?.value){ - if (!targets.length && !prop.silent) actionContext.addLog({value: '**On save**',}); + if (scope['$saveSucceeded']) { + if (!targets.length && !prop.silent) actionContext.addLog({ value: '**On save**', }); applyChildren(); } break; case 'random': - if (node.children.length){ + if (node.children.length) { let index = rollDice(1, node.children.length)[0] - 1; applyNodeTriggers(node, 'after', actionContext); applyProperty(node.children[index], actionContext); diff --git a/app/imports/api/engine/actions/applyPropertyByType/applyDamage.js b/app/imports/api/engine/actions/applyPropertyByType/applyDamage.js index 83ad5074..366d62f4 100644 --- a/app/imports/api/engine/actions/applyPropertyByType/applyDamage.js +++ b/app/imports/api/engine/actions/applyPropertyByType/applyDamage.js @@ -27,7 +27,7 @@ export default function applyDamage(node, actionContext) { // Choose target let damageTargets = prop.target === 'self' ? [actionContext.creature] : actionContext.targets; // Determine if the hit is critical - let criticalHit = scope['$criticalHit']?.value && + let criticalHit = scope['$criticalHit'] && prop.damageType !== 'healing' // Can't critically heal ; // Double the damage rolls if the hit is critical diff --git a/app/imports/api/engine/actions/applyPropertyByType/applySavingThrow.js b/app/imports/api/engine/actions/applyPropertyByType/applySavingThrow.js index ca760d7a..f9f01ce5 100644 --- a/app/imports/api/engine/actions/applyPropertyByType/applySavingThrow.js +++ b/app/imports/api/engine/actions/applyPropertyByType/applySavingThrow.js @@ -31,8 +31,8 @@ export default function applySavingThrow(node, actionContext) { // If there are no save targets, apply all children as if the save both // succeeeded and failed if (!saveTargets?.length) { - scope['$saveFailed'] = { value: true }; - scope['$saveSucceeded'] = { value: true }; + scope['$saveFailed'] = true; + scope['$saveSucceeded'] = true; applyNodeTriggers(node, 'after', actionContext); return node.children.forEach(child => applyProperty(child, actionContext)); } @@ -90,14 +90,14 @@ export default function applySavingThrow(node, actionContext) { value = values[0]; resultPrefix = `1d20 [ ${value} ] ${rollModifierText}` } - scope['$saveDiceRoll'] = { value }; + scope['$saveDiceRoll'] = value; const result = value + rollModifier || 0; - scope['$saveRoll'] = { value: result }; + scope['$saveRoll'] = result; const saveSuccess = result >= dc; if (saveSuccess) { - scope['$saveSucceeded'] = { value: true }; + scope['$saveSucceeded'] = true; } else { - scope['$saveFailed'] = { value: true }; + scope['$saveFailed'] = true; } if (!prop.silent) actionContext.addLog({ name: saveSuccess ? 'Successful save' : 'Failed save',