Tested and fixed proficiencies by tag
This commit is contained in:
@@ -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']
|
||||
}),
|
||||
];
|
||||
Reference in New Issue
Block a user