diff --git a/app/imports/api/creature/computation/combineStat.js b/app/imports/api/creature/computation/combineStat.js
index 6192c31d..873eade2 100644
--- a/app/imports/api/creature/computation/combineStat.js
+++ b/app/imports/api/creature/computation/combineStat.js
@@ -1,9 +1,10 @@
import computeStat from '/imports/api/creature/computation/computeStat.js';
import applyToggles from '/imports/api/creature/computation/applyToggles.js';
+import evaluateCalculation from '/imports/api/creature/computation/evaluateCalculation.js';
export default function combineStat(stat, aggregator, memo){
if (stat.type === 'attribute'){
- combineAttribute(stat, aggregator);
+ combineAttribute(stat, aggregator, memo);
} else if (stat.type === 'skill'){
combineSkill(stat, aggregator, memo);
} else if (stat.type === 'damageMultiplier'){
@@ -28,13 +29,18 @@ function getAggregatorResult(stat, aggregator){
return result;
}
-function combineAttribute(stat, aggregator){
+function combineAttribute(stat, aggregator, memo){
stat.value = getAggregatorResult(stat, aggregator);
stat.baseValue = aggregator.statBaseValue;
stat.baseValueErrors = aggregator.baseValueErrors;
if (stat.attributeType === 'ability') {
stat.modifier = Math.floor((stat.value - 10) / 2);
}
+ if (stat.attributeType === 'spellSlot'){
+ let {value, errors} = evaluateCalculation(stat.spellSlotLevelCalculation, memo);
+ stat.spellSlotLevelValue = value,
+ stat.spellSlotLevelErrors = errors;
+ }
stat.currentValue = stat.value - (stat.damage || 0);
stat.hide = aggregator.hasNoEffects &&
stat.baseValue === undefined ||
diff --git a/app/imports/api/properties/Attributes.js b/app/imports/api/properties/Attributes.js
index 1b35640a..87042284 100644
--- a/app/imports/api/properties/Attributes.js
+++ b/app/imports/api/properties/Attributes.js
@@ -39,6 +39,11 @@ let AttributeSchema = new SimpleSchema({
type: String,
allowedValues: ['d4', 'd6', 'd8', 'd10', 'd12', 'd20'],
optional: true,
+ },
+ // For type spellSlot, the level needs to be stored separately
+ spellSlotLevelCalculation: {
+ type: String,
+ optional: true,
},
// The starting value, before effects
baseValueCalculation: {
@@ -81,6 +86,18 @@ let ComputedOnlyAttributeSchema = new SimpleSchema({
},
'baseValueErrors.$': {
type: ErrorSchema,
+ },
+ // The result of spellSlotLevelCalculation
+ spellSlotLevelValue: {
+ type: SimpleSchema.oneOf(Number, String, Boolean),
+ optional: true,
+ },
+ spellSlotLevelErrors: {
+ type: Array,
+ optional: true,
+ },
+ 'spellSlotLevelErrors.$': {
+ type: ErrorSchema,
},
// The computed value of the attribute
value: {
diff --git a/app/imports/ui/properties/forms/AttributeForm.vue b/app/imports/ui/properties/forms/AttributeForm.vue
index b2ae4b77..c238df43 100644
--- a/app/imports/ui/properties/forms/AttributeForm.vue
+++ b/app/imports/ui/properties/forms/AttributeForm.vue
@@ -47,6 +47,14 @@
:menu-props="{auto: true, lazy: true}"
@change="change('hitDiceSize', ...arguments)"
/>
+
+