Fixed effects not applying to damage in actions
This commit is contained in:
@@ -205,10 +205,12 @@ describe('Interrupt action system', function () {
|
|||||||
function createAction(prop, targetIds?) {
|
function createAction(prop, targetIds?) {
|
||||||
const action: EngineAction = {
|
const action: EngineAction = {
|
||||||
creatureId: prop.root.id,
|
creatureId: prop.root.id,
|
||||||
rootPropId: prop._id,
|
|
||||||
results: [],
|
results: [],
|
||||||
taskCount: 0,
|
taskCount: 0,
|
||||||
targetIds,
|
task: {
|
||||||
|
prop,
|
||||||
|
targetIds,
|
||||||
|
}
|
||||||
};
|
};
|
||||||
return EngineActions.insertAsync(action);
|
return EngineActions.insertAsync(action);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,8 +8,8 @@ import {
|
|||||||
} from '/imports/api/engine/action/functions/actionEngineTest.testFn';
|
} from '/imports/api/engine/action/functions/actionEngineTest.testFn';
|
||||||
|
|
||||||
const [
|
const [
|
||||||
creatureId, targetCreatureId, targetCreature2Id, damageTargetId, damageSelfId, targetCreatureHitPointsId, targetCreature2HitPointsId, selfHitPointsId
|
creatureId, targetCreatureId, targetCreature2Id, damageTargetId, damageSelfId, targetCreatureHitPointsId, targetCreature2HitPointsId, selfHitPointsId, damageWithEffectsId, effectId, effect2Id,
|
||||||
] = getRandomIds(100);
|
] = getRandomIds(20);
|
||||||
|
|
||||||
const actionTestCreature = {
|
const actionTestCreature = {
|
||||||
_id: creatureId,
|
_id: creatureId,
|
||||||
@@ -34,6 +34,29 @@ const actionTestCreature = {
|
|||||||
variableName: 'hitPoints',
|
variableName: 'hitPoints',
|
||||||
baseValue: { calculation: '20' },
|
baseValue: { calculation: '20' },
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
_id: damageWithEffectsId,
|
||||||
|
type: 'damage',
|
||||||
|
target: 'target',
|
||||||
|
amount: { calculation: '1d13 + 3' },
|
||||||
|
tags: ['tag']
|
||||||
|
},
|
||||||
|
{
|
||||||
|
_id: effectId,
|
||||||
|
type: 'effect',
|
||||||
|
operation: 'add',
|
||||||
|
amount: { calculation: '1' },
|
||||||
|
targetByTags: true,
|
||||||
|
targetTags: ['tag'],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
_id: effect2Id,
|
||||||
|
type: 'effect',
|
||||||
|
operation: 'mul',
|
||||||
|
amount: { calculation: '2' },
|
||||||
|
targetByTags: true,
|
||||||
|
targetTags: ['tag'],
|
||||||
|
},
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -187,4 +210,35 @@ describe('Apply Damage Properties', function () {
|
|||||||
],
|
],
|
||||||
}]);
|
}]);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it.only('Applies effects when doing damage', async function () {
|
||||||
|
const action = await runActionById(damageWithEffectsId, [targetCreatureId]);
|
||||||
|
assert.exists(action);
|
||||||
|
assert.deepEqual(allMutations(action), [{
|
||||||
|
contents: [
|
||||||
|
{
|
||||||
|
inline: true,
|
||||||
|
name: 'Damage',
|
||||||
|
value: '(1d13 [7] + 4) * 2',
|
||||||
|
}
|
||||||
|
],
|
||||||
|
targetIds: [targetCreatureId],
|
||||||
|
}, {
|
||||||
|
contents: [
|
||||||
|
{
|
||||||
|
inline: true,
|
||||||
|
name: 'Attribute damaged',
|
||||||
|
value: '−22 Hit Points',
|
||||||
|
}
|
||||||
|
],
|
||||||
|
targetIds: [targetCreatureId],
|
||||||
|
updates: [
|
||||||
|
{
|
||||||
|
propId: targetCreatureHitPointsId,
|
||||||
|
type: 'attribute',
|
||||||
|
inc: { damage: 22, value: -22 },
|
||||||
|
},
|
||||||
|
],
|
||||||
|
}]);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -82,10 +82,12 @@ export async function runActionById(propId, targetIds?, userInput = inputProvide
|
|||||||
function createAction(prop: any, targetIds?: string[]) {
|
function createAction(prop: any, targetIds?: string[]) {
|
||||||
const action: EngineAction = {
|
const action: EngineAction = {
|
||||||
creatureId: prop.root.id,
|
creatureId: prop.root.id,
|
||||||
rootPropId: prop._id,
|
|
||||||
results: [],
|
results: [],
|
||||||
taskCount: 0,
|
taskCount: 0,
|
||||||
targetIds,
|
task: {
|
||||||
|
prop,
|
||||||
|
targetIds: targetIds || [],
|
||||||
|
}
|
||||||
};
|
};
|
||||||
return EngineActions.insertAsync(action);
|
return EngineActions.insertAsync(action);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ export default async function recalculateCalculation(
|
|||||||
// Resolve the modified valueNode, use the same context
|
// Resolve the modified valueNode, use the same context
|
||||||
const {
|
const {
|
||||||
result: finalResult
|
result: finalResult
|
||||||
} = await resolve(parseLevel, calcObj.parseNode, scope, context);
|
} = await resolve(parseLevel, calcObj.valueNode, scope, context);
|
||||||
|
|
||||||
// Store the errors
|
// Store the errors
|
||||||
calcObj.errors = context.errors;
|
calcObj.errors = context.errors;
|
||||||
|
|||||||
@@ -133,7 +133,7 @@ export function aggregateCalculationEffects(calcObj, getEffectFromId) {
|
|||||||
// Multiply
|
// Multiply
|
||||||
if (aggregator.mul) {
|
if (aggregator.mul) {
|
||||||
// Wrap the previous node in brackets if it's another operator
|
// Wrap the previous node in brackets if it's another operator
|
||||||
if (calcObj.parseType === 'operator') {
|
if (calcObj.valueNode.parseType === 'operator') {
|
||||||
calcObj.valueNode = parenthesis.create({
|
calcObj.valueNode = parenthesis.create({
|
||||||
content: calcObj.valueNode
|
content: calcObj.valueNode
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user