Fixed saving throw tag targeted effects

They will now roll dice effects before saving
This commit is contained in:
Stefan Zermatten
2022-11-19 19:15:53 +02:00
parent a568cdfb1e
commit dcfb380e57
2 changed files with 8 additions and 3 deletions

View File

@@ -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) {

View File

@@ -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) {