From 32e5b0a9f6c46950e7ed2fc272c111899aa324fd Mon Sep 17 00:00:00 2001 From: Stefan Zermatten Date: Fri, 14 Apr 2023 12:02:46 +0200 Subject: [PATCH] fixed: props all have slotQuantityFilled now --- .../creature/creatureProperties/CreatureProperties.js | 6 ++++++ .../tests/computeSlotQuantityFilled.testFn.js | 10 +++++----- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/app/imports/api/creature/creatureProperties/CreatureProperties.js b/app/imports/api/creature/creatureProperties/CreatureProperties.js index ff301a79..c3957dfd 100644 --- a/app/imports/api/creature/creatureProperties/CreatureProperties.js +++ b/app/imports/api/creature/creatureProperties/CreatureProperties.js @@ -46,6 +46,12 @@ let CreaturePropertySchema = new SimpleSchema({ regEx: SimpleSchema.RegEx.Id, optional: true, }, + // Fill more than one quantity in a slot, like feats and ability score + // improvements, filtered out of UI if there isn't space in quantityExpected + slotQuantityFilled: { + type: SimpleSchema.Integer, + optional: true, // Undefined implies 1 + }, }); const DenormalisedOnlyCreaturePropertySchema = new SimpleSchema({ diff --git a/app/imports/api/engine/computation/buildComputation/tests/computeSlotQuantityFilled.testFn.js b/app/imports/api/engine/computation/buildComputation/tests/computeSlotQuantityFilled.testFn.js index 8a8af817..79abf23b 100644 --- a/app/imports/api/engine/computation/buildComputation/tests/computeSlotQuantityFilled.testFn.js +++ b/app/imports/api/engine/computation/buildComputation/tests/computeSlotQuantityFilled.testFn.js @@ -2,7 +2,7 @@ import { buildComputationFromProps } from '/imports/api/engine/computation/build import { assert } from 'chai'; import clean from '../../utility/cleanProp.testFn.js'; -export default function(){ +export default function () { const computation = buildComputationFromProps(testProperties); const totalFilled = computation.propsById['slotId'].totalFilled; assert.equal(totalFilled, 4); @@ -13,7 +13,7 @@ var testProperties = [ clean({ _id: 'slotId', type: 'propertySlot', - ancestors: [{id: 'charId'}], + ancestors: [{ id: 'charId' }], }), // Children clean({ @@ -21,16 +21,16 @@ var testProperties = [ type: 'slotFiller', slotQuantityFilled: 3, slotFillerType: 'item', - ancestors: [{id: 'charId'}, {id: 'slotId'}], + ancestors: [{ id: 'charId' }, { id: 'slotId' }], }), clean({ _id: 'slotChildId', type: 'item', - ancestors: [{id: 'charId'}, {id: 'slotId'}], + ancestors: [{ id: 'charId' }, { id: 'slotId' }], }), clean({ _id: 'slotGrandchildId', type: 'effect', - ancestors: [{id: 'charId'}, {id: 'slotId'}, {id: 'slotChildId'}], + ancestors: [{ id: 'charId' }, { id: 'slotId' }, { id: 'slotChildId' }], }), ];