Attributes of type spell slot now store their slot level
This commit is contained in:
@@ -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 ||
|
||||
|
||||
@@ -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: {
|
||||
|
||||
@@ -47,6 +47,14 @@
|
||||
:menu-props="{auto: true, lazy: true}"
|
||||
@change="change('hitDiceSize', ...arguments)"
|
||||
/>
|
||||
<text-field
|
||||
v-if="model.attributeType === 'spellSlot'"
|
||||
label="Spell slot level"
|
||||
:value="model.spellSlotLevelCalculation"
|
||||
:error-messages="errors.spellSlotLevelCalculation"
|
||||
@change="change('spellSlotLevelCalculation', ...arguments)"
|
||||
/>
|
||||
<calculation-error-list :errors="model.spellSlotLevelErrors" />
|
||||
<text-area
|
||||
label="Description"
|
||||
:value="model.description"
|
||||
|
||||
Reference in New Issue
Block a user