Start of action system re-write

This commit is contained in:
Stefan Zermatten
2021-10-09 12:36:06 +02:00
parent 0097696cc8
commit 0cdec4a429
41 changed files with 783 additions and 119 deletions

View File

@@ -1,13 +0,0 @@
import spendResources from '/imports/api/creature/actions/spendResources.js'
export default function applyAction({prop, log}){
let content = { name: prop.name };
/*
if (prop.summary){
content.value = embedInlineCalculations(
prop.summary, prop.summaryCalculations
);
}*/
log.content.push(content);
spendResources({prop, log});
}

View File

@@ -1,4 +1,4 @@
import roll from '/imports/parser/roll.js';
import rollDice from '/imports/parser/rollDice.js';
export default function applyAttack({
prop,
@@ -6,7 +6,7 @@ export default function applyAttack({
actionContext,
creature,
}){
let value = roll(1, 20)[0];
let value = rollDice(1, 20)[0];
actionContext.attackRoll = {value};
let criticalHitTarget = creature.variables.criticalHitTarget &&
creature.variables.criticalHitTarget.value || 20;

View File

@@ -7,8 +7,8 @@ import applyRoll from '/imports/api/creature/actions/applyRoll.js';
import applyToggle from '/imports/api/creature/actions/applyToggle.js';
import applySave from '/imports/api/creature/actions/applySave.js';
function applyProperty(options){
let prop = options.prop;
function applyProperty(args){
let prop = args.prop;
if (prop.type === 'buff'){
// ignore only applied buffs, don't apply them again
if (prop.applied === true){
@@ -26,28 +26,27 @@ function applyProperty(options){
switch (prop.type){
case 'action':
case 'spell':
applyAction(options);
break;
case 'attack':
applyAction(options);
applyAttack(options);
if (prop.attackRoll && prop.attackRoll.calculation){
applyAttack(args)
}
applyAction(args);
break;
case 'damage':
applyDamage(options);
applyDamage(args);
break;
case 'adjustment':
applyAdjustment(options);
applyAdjustment(args);
break;
case 'buff':
applyBuff(options);
applyBuff(args);
return false;
case 'toggle':
return applyToggle(options);
return applyToggle(args);
case 'roll':
applyRoll(options);
applyRoll(args);
break;
case 'savingThrow':
return applySave(options);
return applySave(args);
}
return true;
}