Files
DiceCloud/app/imports/api/engine/actions/applyProperty.js
Stefan Zermatten ee0e764294 Refactored entire action engine
Triggers needed action context to function outside of the action engine
proper, so now it's been abstracted into its own class
2022-08-13 00:22:32 +02:00

31 lines
1.0 KiB
JavaScript

import action from './applyPropertyByType/applyAction.js';
import adjustment from './applyPropertyByType/applyAdjustment.js';
import branch from './applyPropertyByType/applyBranch.js';
import buff from './applyPropertyByType/applyBuff.js';
import damage from './applyPropertyByType/applyDamage.js';
import note from './applyPropertyByType/applyNote.js';
import roll from './applyPropertyByType/applyRoll.js';
import savingThrow from './applyPropertyByType/applySavingThrow.js';
import toggle from './applyPropertyByType/applyToggle.js';
import { applyNodeTriggers } from '/imports/api/engine/actions/applyTriggers.js';
const applyPropertyByType = {
action,
adjustment,
branch,
buff,
damage,
note,
roll,
savingThrow,
spell: action,
toggle,
};
export default function applyProperty(node, actionContext, ...rest) {
applyNodeTriggers(node, actionContext, 'before');
actionContext.scope[`#${node.node.type}`] = node.node;
applyPropertyByType[node.node.type]?.(node, actionContext, ...rest);
applyNodeTriggers(node, actionContext, 'after');
}