Tested and fixed damage multiplier computations
This commit is contained in:
@@ -186,9 +186,9 @@ function combineSkill(stat, aggregator, memo){
|
||||
function combineDamageMultiplier(stat){
|
||||
if (stat.immunityCount) return 0;
|
||||
let result;
|
||||
if (stat.ressistanceCount && !stat.vulnerabilityCount){
|
||||
if (stat.resistanceCount && !stat.vulnerabilityCount){
|
||||
result = 0.5;
|
||||
} else if (!stat.ressistanceCount && stat.vulnerabilityCount){
|
||||
} else if (!stat.resistanceCount && stat.vulnerabilityCount){
|
||||
result = 2;
|
||||
} else {
|
||||
result = 1;
|
||||
|
||||
@@ -68,7 +68,9 @@ function linkAttribute(dependencyGraph, prop){
|
||||
|
||||
function linkDamageMultiplier(dependencyGraph, prop){
|
||||
prop.damageTypes.forEach(damageType => {
|
||||
dependencyGraph.addLink(`${damageType}Multiplier`, prop._id, prop.type);
|
||||
// Remove all non-letter characters from the damage name
|
||||
const damageName = damageType.replace(/[^a-z]/gi, '')
|
||||
dependencyGraph.addLink(`${damageName}Multiplier`, prop._id, prop.type);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -69,18 +69,17 @@ function combineMultiplierAggregator(node){
|
||||
if (aggregator.immunityCount){
|
||||
value = 0;
|
||||
} else if (
|
||||
aggregator.ressistanceCount &&
|
||||
aggregator.resistanceCount &&
|
||||
!aggregator.vulnerabilityCount
|
||||
){
|
||||
value = 0.5;
|
||||
} else if (
|
||||
!aggregator.ressistanceCount &&
|
||||
!aggregator.resistanceCount &&
|
||||
aggregator.vulnerabilityCount
|
||||
){
|
||||
value = 2;
|
||||
} else {
|
||||
value = 1;
|
||||
}
|
||||
|
||||
node.data.damageMultiplyValue = value;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
import { buildComputationFromProps } from '/imports/api/creature/computation/newEngine/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 scope = id => computation.scope[id];
|
||||
assert.equal(scope('blugeoningMultiplier').value, 1);
|
||||
assert.equal(scope('customDamageMultiplier').value, 0.5);
|
||||
assert.equal(scope('slashingMultiplier').value, 0);
|
||||
}
|
||||
|
||||
var testProperties = [
|
||||
clean({
|
||||
_id: 'resistanceId',
|
||||
type: 'damageMultiplier',
|
||||
damageTypes: ['blugeoning', 'customDamage'],
|
||||
value: 0.5,
|
||||
}),
|
||||
clean({
|
||||
_id: 'vulnerabilityId',
|
||||
type: 'damageMultiplier',
|
||||
damageTypes: ['blugeoning'],
|
||||
value: 2,
|
||||
}),
|
||||
clean({
|
||||
_id: 'slashResistId',
|
||||
type: 'damageMultiplier',
|
||||
damageTypes: ['slashing'],
|
||||
value: 0.5,
|
||||
}),
|
||||
clean({
|
||||
_id: 'slashInvulnId',
|
||||
type: 'damageMultiplier',
|
||||
damageTypes: ['slashing'],
|
||||
value: 0,
|
||||
}),
|
||||
];
|
||||
@@ -8,7 +8,6 @@ export default function(){
|
||||
computeCreatureComputation(computation);
|
||||
const prop = id => computation.propsById[id];
|
||||
const scope = id => computation.scope[id].value;
|
||||
console.log(computation.scope);
|
||||
|
||||
assert.equal(scope('weightEquipment'), 2);
|
||||
assert.equal(scope('valueEquipment'), 3);
|
||||
|
||||
@@ -3,8 +3,9 @@ import computeAttribute from './computeAttribute.testFn.js';
|
||||
import computeClasses from './computeClasses.testFn.js';
|
||||
import computeConstants from './computeConstants.testFn.js';
|
||||
import computeInventory from './computeInventory.testFn.js';
|
||||
import computeDamageMultipliers from './computeDamageMultipliers.testFn.js';
|
||||
|
||||
export default [/*{
|
||||
export default [{
|
||||
text: 'Computes actions',
|
||||
fn: computeAction,
|
||||
},{
|
||||
@@ -16,7 +17,10 @@ export default [/*{
|
||||
},{
|
||||
text: 'Computes constants',
|
||||
fn: computeConstants,
|
||||
},*/{
|
||||
},{
|
||||
text: 'Computes inventory',
|
||||
fn: computeInventory,
|
||||
},{
|
||||
text: 'Computes damage multipliers',
|
||||
fn: computeDamageMultipliers,
|
||||
}];
|
||||
|
||||
Reference in New Issue
Block a user