From dcfb380e571a66b0a979c003deb1c93e34fab7a9 Mon Sep 17 00:00:00 2001 From: Stefan Zermatten Date: Sat, 19 Nov 2022 19:15:53 +0200 Subject: [PATCH] Fixed saving throw tag targeted effects They will now roll dice effects before saving --- .../actions/applyPropertyByType/applySavingThrow.js | 9 +++++++-- app/imports/api/engine/actions/doCheck.js | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/app/imports/api/engine/actions/applyPropertyByType/applySavingThrow.js b/app/imports/api/engine/actions/applyPropertyByType/applySavingThrow.js index 22de7aa7..ca760d7a 100644 --- a/app/imports/api/engine/actions/applyPropertyByType/applySavingThrow.js +++ b/app/imports/api/engine/actions/applyPropertyByType/applySavingThrow.js @@ -3,6 +3,7 @@ import recalculateCalculation from './shared/recalculateCalculation.js'; import applyProperty from '../applyProperty.js'; import numberToSignedString from '/imports/api/utility/numberToSignedString.js'; import { applyNodeTriggers } from '/imports/api/engine/actions/applyTriggers.js'; +import { applyUnresolvedEffects } from '/imports/api/engine/actions/doCheck.js'; export default function applySavingThrow(node, actionContext) { applyNodeTriggers(node, 'before', actionContext); @@ -59,7 +60,11 @@ export default function applySavingThrow(node, actionContext) { return applyChildren(); } - const rollModifierText = numberToSignedString(save.value, true); + let rollModifierText = numberToSignedString(save.value, true); + let rollModifier = save.value + const { effectBonus, effectString } = applyUnresolvedEffects(save, scope) + rollModifierText += effectString; + rollModifier += effectBonus; let value, values, resultPrefix; if (save.advantage === 1) { @@ -86,7 +91,7 @@ export default function applySavingThrow(node, actionContext) { resultPrefix = `1d20 [ ${value} ] ${rollModifierText}` } scope['$saveDiceRoll'] = { value }; - const result = value + save.value || 0; + const result = value + rollModifier || 0; scope['$saveRoll'] = { value: result }; const saveSuccess = result >= dc; if (saveSuccess) { diff --git a/app/imports/api/engine/actions/doCheck.js b/app/imports/api/engine/actions/doCheck.js index 8e9789a6..3673356b 100644 --- a/app/imports/api/engine/actions/doCheck.js +++ b/app/imports/api/engine/actions/doCheck.js @@ -115,7 +115,7 @@ function rollCheck(prop, actionContext) { }); } -function applyUnresolvedEffects(prop, scope) { +export function applyUnresolvedEffects(prop, scope) { let effectBonus = 0; let effectString = ''; if (!prop.effects) {