Fixed issue: toggled off point buys still applying

This commit is contained in:
ThaumRystra
2023-11-12 16:38:55 +02:00
parent aaec54f36a
commit b32b6db21a
7 changed files with 100 additions and 24 deletions

View File

@@ -1,59 +1,52 @@
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';
import { propsFromForest } from '/imports/api/properties/tests/propTestBuilder.testFn.js';
export default function(){
export default function () {
const computation = buildComputationFromProps(testProperties);
computeCreatureComputation(computation);
const prop = id => computation.propsById[id];
assert.equal(prop('strengthId').value, 26);
}
var testProperties = [
clean({
_id: 'strengthId',
var testProperties = propsFromForest([
{
variableName: 'strength',
type: 'attribute',
attributeType: 'ability',
baseValue: {
calculation: '8'
},
}),
clean({
_id: 'strength2Id',
}, {
// This strength is later in order, so it will override the other
_id: 'strengthId',
variableName: 'strength',
type: 'attribute',
attributeType: 'ability',
baseValue: {
calculation: '10'
},
}),
clean({
_id: 'strengthBaseId',
}, {
type: 'effect',
operation: 'base',
amount: {
calculation: '10 + 2'
},
stats: ['strength'],
}),
clean({
_id: 'strengthAddId',
}, {
type: 'effect',
operation: 'add',
amount: {
calculation: '1'
},
stats: ['strength'],
}),
clean({
_id: 'strengthMulId',
}, {
type: 'effect',
operation: 'mul',
amount: {
calculation: '2'
},
stats: ['strength'],
}),
];
},
]);

View File

@@ -0,0 +1,38 @@
import { buildComputationFromProps } from '/imports/api/engine/computation/buildCreatureComputation.js';
import { assert } from 'chai';
import computeCreatureComputation from '../../computeCreatureComputation.js';
import { propsFromForest } from '/imports/api/properties/tests/propTestBuilder.testFn.js';
export default function () {
const computation = buildComputationFromProps(testProperties);
computeCreatureComputation(computation);
const prop = id => computation.propsById[id];
assert.equal(prop('strengthId').value, 11, 'Point buys should apply a base value when active');
}
var testProperties = propsFromForest([
{
_id: 'strengthId',
variableName: 'strength',
type: 'attribute',
attributeType: 'ability',
baseValue: {
calculation: '8'
},
}, {
// calculated inactive toggle with point buy under it
// It should not impact the ability score
type: 'toggle',
condition: { calculation: 'false' },
children: [
{
_id: 'inactivePointBuy',
type: 'pointBuy',
values: [{ variableName: 'strength', value: 13 }],
}
]
}, {
type: 'pointBuy',
values: [{ variableName: 'strength', value: 11 }],
}
]);

View File

@@ -7,6 +7,7 @@ import computeInventory from './computeInventory.testFn.js';
import computeDamageMultipliers from './computeDamageMultipliers.testFn.js';
import computeEffects from './computeEffects.testFn.js';
import computeSkills from './computeSkills.testFn.js';
import computePointBuys from './computePointBuys.testFn.js';
import computeProficiencies from './computeProficiencies.testFn.js';
export default [{
@@ -36,6 +37,9 @@ export default [{
}, {
text: 'Computes skills',
fn: computeSkills,
}, {
text: 'Computes point buys',
fn: computePointBuys,
}, {
text: 'Computes proficiencies',
fn: computeProficiencies,