Tested and fixed proficiencies by tag
This commit is contained in:
@@ -272,6 +272,9 @@ function linkProficiencies(dependencyGraph, prop, computation) {
|
|||||||
// The stats depend on the proficiency
|
// The stats depend on the proficiency
|
||||||
if (prop.inactive) return;
|
if (prop.inactive) return;
|
||||||
if (prop.targetByTags) {
|
if (prop.targetByTags) {
|
||||||
|
// Tag targeted proficiencies depend on the creature's proficiencyBonus,
|
||||||
|
// since they add it directly to the targeted field
|
||||||
|
dependencyGraph.addLink(prop._id, 'proficiencyBonus', 'skillProficiencyBonus');
|
||||||
getEffectTagTargets(prop, computation).forEach(targetId => {
|
getEffectTagTargets(prop, computation).forEach(targetId => {
|
||||||
const targetProp = computation.propsById[targetId];
|
const targetProp = computation.propsById[targetId];
|
||||||
if (
|
if (
|
||||||
|
|||||||
@@ -61,8 +61,7 @@ function aggregateCalculationProficiencies(node, computation) {
|
|||||||
if (!linkedNode.data) return;
|
if (!linkedNode.data) return;
|
||||||
// Ignore inactive props
|
// Ignore inactive props
|
||||||
if (linkedNode.data.inactive) return;
|
if (linkedNode.data.inactive) return;
|
||||||
|
// Collate proficiencies
|
||||||
// Collate effects
|
|
||||||
calcObj.proficiencies = calcObj.proficiencies || [];
|
calcObj.proficiencies = calcObj.proficiencies || [];
|
||||||
calcObj.proficiencies.push({
|
calcObj.proficiencies.push({
|
||||||
_id: linkedNode.data._id,
|
_id: linkedNode.data._id,
|
||||||
|
|||||||
@@ -0,0 +1,64 @@
|
|||||||
|
import { buildComputationFromProps } from '/imports/api/engine/computation/buildCreatureComputation.js';
|
||||||
|
import { assert } from 'chai';
|
||||||
|
import computeCreatureComputation from '../../computeCreatureComputation.js';
|
||||||
|
import clean from '../../utility/cleanProp.testFn.js';
|
||||||
|
|
||||||
|
export default function () {
|
||||||
|
const computation = buildComputationFromProps(testProperties);
|
||||||
|
computeCreatureComputation(computation);
|
||||||
|
const prop = id => computation.propsById[id];
|
||||||
|
assert.equal(
|
||||||
|
prop('strengthId').value, 8,
|
||||||
|
'The proficiency bonus should not change the strength score'
|
||||||
|
);
|
||||||
|
assert.equal(
|
||||||
|
prop('strengthId').modifier, -1,
|
||||||
|
'The proficiency bonus should not change the strength modifier'
|
||||||
|
);
|
||||||
|
assert.exists(prop('actionId').attackRoll.proficiencies, 'The proficiency aggregator should be here')
|
||||||
|
assert.exists(prop('actionId').attackRoll.proficiencies[0], 'The proficiency should be here')
|
||||||
|
// attack roll = strength.mod + proficiencyBonus/2 rounded down
|
||||||
|
// = -1 + 13/2 = -1 + 6 = 5
|
||||||
|
assert.equal(
|
||||||
|
prop('actionId').attackRoll.value, 5,
|
||||||
|
'The proficiency should apply correctly to modify the attack roll'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
var testProperties = [
|
||||||
|
clean({
|
||||||
|
_id: 'strengthId',
|
||||||
|
variableName: 'strength',
|
||||||
|
type: 'attribute',
|
||||||
|
attributeType: 'ability',
|
||||||
|
baseValue: {
|
||||||
|
calculation: '8'
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
clean({
|
||||||
|
_id: 'actionId',
|
||||||
|
type: 'action',
|
||||||
|
ancestors: [{ id: 'charId' }],
|
||||||
|
attackRoll: {
|
||||||
|
calculation: 'strength.modifier',
|
||||||
|
},
|
||||||
|
tags: ['rapier', 'martial weapon', 'weapon', 'attack']
|
||||||
|
}),
|
||||||
|
clean({
|
||||||
|
_id: 'profBonusId',
|
||||||
|
type: 'attribute',
|
||||||
|
variableName: 'proficiencyBonus',
|
||||||
|
ancestors: [{ id: 'charId' }],
|
||||||
|
baseValue: {
|
||||||
|
calculation: '13'
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
clean({
|
||||||
|
_id: 'tagTargetedProficiency',
|
||||||
|
type: 'proficiency',
|
||||||
|
stats: ['strength'], // Should be ignored, we are targeting by tags
|
||||||
|
value: 0.49,
|
||||||
|
targetByTags: true,
|
||||||
|
targetTags: ['martial weapon']
|
||||||
|
}),
|
||||||
|
];
|
||||||
@@ -6,29 +6,33 @@ import computeInventory from './computeInventory.testFn.js';
|
|||||||
import computeDamageMultipliers from './computeDamageMultipliers.testFn.js';
|
import computeDamageMultipliers from './computeDamageMultipliers.testFn.js';
|
||||||
import computeEffects from './computeEffects.testFn.js';
|
import computeEffects from './computeEffects.testFn.js';
|
||||||
import computeSkills from './computeSkills.testFn.js';
|
import computeSkills from './computeSkills.testFn.js';
|
||||||
|
import computeProficiencies from './computeProficiencies.testFn.js';
|
||||||
|
|
||||||
export default [{
|
export default [{
|
||||||
text: 'Computes actions',
|
text: 'Computes actions',
|
||||||
fn: computeAction,
|
fn: computeAction,
|
||||||
},{
|
}, {
|
||||||
text: 'Computes attributes',
|
text: 'Computes attributes',
|
||||||
fn: computeAttribute,
|
fn: computeAttribute,
|
||||||
},{
|
}, {
|
||||||
text: 'Computes classes',
|
text: 'Computes classes',
|
||||||
fn: computeClasses,
|
fn: computeClasses,
|
||||||
},{
|
}, {
|
||||||
text: 'Computes constants',
|
text: 'Computes constants',
|
||||||
fn: computeConstants,
|
fn: computeConstants,
|
||||||
},{
|
}, {
|
||||||
text: 'Computes inventory',
|
text: 'Computes inventory',
|
||||||
fn: computeInventory,
|
fn: computeInventory,
|
||||||
},{
|
}, {
|
||||||
text: 'Computes damage multipliers',
|
text: 'Computes damage multipliers',
|
||||||
fn: computeDamageMultipliers,
|
fn: computeDamageMultipliers,
|
||||||
},{
|
}, {
|
||||||
text: 'Computes effects',
|
text: 'Computes effects',
|
||||||
fn: computeEffects,
|
fn: computeEffects,
|
||||||
},{
|
}, {
|
||||||
text: 'Computes skills',
|
text: 'Computes skills',
|
||||||
fn: computeSkills,
|
fn: computeSkills,
|
||||||
|
}, {
|
||||||
|
text: 'Computes proficiencies',
|
||||||
|
fn: computeProficiencies,
|
||||||
}];
|
}];
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ let ProficiencySchema = new SimpleSchema({
|
|||||||
optional: true,
|
optional: true,
|
||||||
max: STORAGE_LIMITS.variableName,
|
max: STORAGE_LIMITS.variableName,
|
||||||
},
|
},
|
||||||
// Which tags the effect is applied to
|
// Which tags the proficiency is applied to
|
||||||
targetTags: {
|
targetTags: {
|
||||||
type: Array,
|
type: Array,
|
||||||
optional: true,
|
optional: true,
|
||||||
|
|||||||
Reference in New Issue
Block a user