Moved action system to new tree format

This commit is contained in:
Thaum Rystra
2023-09-28 14:49:32 +02:00
parent e6963ec865
commit 3bd2806bc6
15 changed files with 25 additions and 26 deletions

View File

@@ -5,7 +5,7 @@ import { applyNodeTriggers } from '/imports/api/engine/actions/applyTriggers';
export default function applyAdjustment(node, actionContext) {
applyNodeTriggers(node, 'before', actionContext);
const prop = node.node;
const prop = node.doc
const damageTargets = prop.target === 'self' ? [actionContext.creature] : actionContext.targets;
if (!prop.amount) {

View File

@@ -8,7 +8,7 @@ export default function applyBranch(node, actionContext) {
applyNodeTriggers(node, 'before', actionContext);
const scope = actionContext.scope;
const targets = actionContext.targets;
const prop = node.node;
const prop = node.doc
switch (prop.branchType) {
case 'if':
recalculateCalculation(prop.condition, actionContext);

View File

@@ -17,7 +17,7 @@ import recalculateInlineCalculations from './shared/recalculateInlineCalculation
export default function applyBuff(node, actionContext) {
applyNodeTriggers(node, 'before', actionContext);
const prop = node.node;
const prop = node.doc
let buffTargets = prop.target === 'self' ? [actionContext.creature] : actionContext.targets;
// Mark the buff as dirty for recalculation

View File

@@ -11,7 +11,7 @@ export default function applyBuffRemover(node, actionContext) {
// Apply triggers
applyNodeTriggers(node, 'before', actionContext);
const prop = node.node;
const prop = node.doc
// Log Name
if (prop.name && !prop.silent) {

View File

@@ -15,7 +15,7 @@ import applySavingThrow from '/imports/api/engine/actions/applyPropertyByType/ap
export default function applyDamage(node, actionContext) {
applyNodeTriggers(node, 'before', actionContext);
const prop = node.node;
const prop = node.doc
const scope = actionContext.scope;
// Skip if there is no parse node to work with

View File

@@ -6,7 +6,7 @@ import { adjustQuantityWork } from '/imports/api/creature/creatureProperties/met
export default function applyItemAsAmmo(node, actionContext) {
// The item node should come without children, since it is not part of the original action tree
const prop = node.node;
const prop = node.doc
// Get all the item's descendant properties
const properties = getPropertyDecendants(actionContext.creature._id, prop._id);
properties.sort((a, b) => a.order - b.order);

View File

@@ -4,7 +4,7 @@ import { applyNodeTriggers } from '/imports/api/engine/actions/applyTriggers';
export default function applyNote(node, actionContext) {
applyNodeTriggers(node, 'before', actionContext);
const prop = node.node;
const prop = node.doc
// Log Name, summary
let content = { name: prop.name };

View File

@@ -6,7 +6,7 @@ import { applyNodeTriggers } from '/imports/api/engine/actions/applyTriggers';
export default function applyRoll(node, actionContext) {
applyNodeTriggers(node, 'before', actionContext);
const prop = node.node;
const prop = node.doc
if (prop.roll?.calculation) {
const logValue = [];

View File

@@ -8,7 +8,7 @@ import { applyUnresolvedEffects } from '/imports/api/engine/actions/doCheck.js';
export default function applySavingThrow(node, actionContext) {
applyNodeTriggers(node, 'before', actionContext);
const prop = node.node;
const prop = node.doc
const originalTargets = actionContext.targets;
let saveTargets = prop.target === 'self' ? [actionContext.creature] : actionContext.targets;

View File

@@ -4,7 +4,7 @@ import applyChildren from '/imports/api/engine/actions/applyPropertyByType/share
export default function applyToggle(node, actionContext) {
applyNodeTriggers(node, 'before', actionContext);
const prop = node.node;
const prop = node.doc
recalculateCalculation(prop.condition, actionContext);
if (prop.condition?.value) {
return applyChildren(node, actionContext);