Added spellcasting ability to spell lists
This commit is contained in:
@@ -5,6 +5,7 @@ import skill from './computeByType/computeSkill.js';
|
||||
import pointBuy from './computeByType/computePointBuy.js';
|
||||
import propertySlot from './computeByType/computeSlot.js';
|
||||
import container from './computeByType/computeContainer.js';
|
||||
import spellList from './computeByType/computeSpellList.js';
|
||||
import _calculation from './computeByType/computeCalculation.js';
|
||||
|
||||
export default Object.freeze({
|
||||
@@ -17,4 +18,5 @@ export default Object.freeze({
|
||||
pointBuy,
|
||||
propertySlot,
|
||||
spell: action,
|
||||
spellList,
|
||||
});
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
export default function computeSpelllist(computation, node) {
|
||||
const prop = node.data;
|
||||
|
||||
const ability = computation.scope[prop.ability];
|
||||
prop.abilityMod = ability?.modifier || 0;
|
||||
}
|
||||
@@ -17,6 +17,12 @@ let SpellListSchema = createPropertySchema({
|
||||
type: 'fieldToCompute',
|
||||
optional: true,
|
||||
},
|
||||
// The variable name of the ability this spell relies on
|
||||
ability: {
|
||||
type: String,
|
||||
optional: true,
|
||||
max: STORAGE_LIMITS.variableName,
|
||||
},
|
||||
// Calculation of The attack roll bonus used by spell attacks in this list
|
||||
attackRollBonus: {
|
||||
type: 'fieldToCompute',
|
||||
@@ -38,6 +44,12 @@ const ComputedOnlySpellListSchema = createPropertySchema({
|
||||
type: 'computedOnlyField',
|
||||
optional: true,
|
||||
},
|
||||
// Computed value determined by the ability
|
||||
abilityMod: {
|
||||
type: SimpleSchema.Integer,
|
||||
optional: true,
|
||||
removeBeforeCompute: true,
|
||||
},
|
||||
attackRollBonus: {
|
||||
type: 'computedOnlyField',
|
||||
optional: true,
|
||||
|
||||
@@ -6,6 +6,12 @@
|
||||
<div>
|
||||
Spell Save DC: {{ model.dc && model.dc.value }}
|
||||
</div>
|
||||
<div v-if="model.ability">
|
||||
Spell casting ability: {{ model.ability }}
|
||||
</div>
|
||||
<div v-if="model.ability">
|
||||
Spell casting ability modifier: {{ model.abilityMod }}
|
||||
</div>
|
||||
<div>
|
||||
Spell Attack Bonus: {{ model.attackRollBonus && model.attackRollBonus.value }}
|
||||
</div>
|
||||
|
||||
@@ -27,6 +27,15 @@
|
||||
$emit('change', {path: ['maxPrepared', ...path], value, ack})"
|
||||
/>
|
||||
|
||||
<smart-combobox
|
||||
label="Spellcasting ability"
|
||||
:value="model.ability"
|
||||
hint="Which ability is used to cast spells in this spell list"
|
||||
:items="abilityScoreList"
|
||||
:error-messages="errors.ability"
|
||||
@change="changeAbility"
|
||||
/>
|
||||
|
||||
<computed-field
|
||||
label="Spell save DC"
|
||||
hint="The spell save DC of spells in this list"
|
||||
@@ -67,9 +76,46 @@
|
||||
|
||||
<script lang="js">
|
||||
import propertyFormMixin from '/imports/ui/properties/forms/shared/propertyFormMixin.js';
|
||||
import createListOfProperties from '/imports/ui/properties/forms/shared/lists/createListOfProperties.js';
|
||||
|
||||
export default {
|
||||
mixins: [propertyFormMixin],
|
||||
meteor: {
|
||||
abilityScoreList() {
|
||||
return createListOfProperties({
|
||||
type: 'attribute',
|
||||
attributeType: 'ability',
|
||||
});
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
changeAbility(value, ack) {
|
||||
this.$emit('change', { path: ['ability'], value, ack })
|
||||
const oldValue = this.model.ability;
|
||||
|
||||
const attackRollBonus = this.model.attackRollBonus?.calculation;
|
||||
if (
|
||||
!attackRollBonus ||
|
||||
attackRollBonus === `proficiencyBonus + ${oldValue}.modifier`
|
||||
) {
|
||||
this.$emit('change', {
|
||||
path: ['attackRollBonus', 'calculation'],
|
||||
value: `proficiencyBonus + ${value}.modifier`
|
||||
});
|
||||
}
|
||||
|
||||
const dc = this.model.dc?.calculation;
|
||||
if (
|
||||
!dc ||
|
||||
dc === `8 + proficiencyBonus + ${oldValue}.modifier`
|
||||
) {
|
||||
this.$emit('change', {
|
||||
path: ['dc', 'calculation'],
|
||||
value: `8 + proficiencyBonus + ${value}.modifier`
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
|
||||
@@ -13,6 +13,18 @@
|
||||
center
|
||||
:calculation="model.maxPrepared"
|
||||
/>
|
||||
<property-field
|
||||
name="Spellcasting ability"
|
||||
mono
|
||||
:value="model.ability"
|
||||
/>
|
||||
<property-field
|
||||
name="Spellcasting ability modifier"
|
||||
large
|
||||
center
|
||||
signed
|
||||
:value="model.abilityMod"
|
||||
/>
|
||||
<property-field
|
||||
name="Spell Save DC"
|
||||
large
|
||||
|
||||
@@ -41,7 +41,7 @@
|
||||
>
|
||||
<slot>
|
||||
<template v-if="value !== undefined">
|
||||
{{ value }}
|
||||
{{ valueText }}
|
||||
</template>
|
||||
<template v-else-if="calculation !== undefined">
|
||||
{{ calculationText }}
|
||||
@@ -117,6 +117,13 @@ export default {
|
||||
if (!this.calculation) return;
|
||||
return typeof this.calculation.value === 'string'
|
||||
},
|
||||
valueText() {
|
||||
if (this.signed) {
|
||||
return numberToSignedString(this.value);
|
||||
} else {
|
||||
return this.value;
|
||||
}
|
||||
},
|
||||
calculationText(){
|
||||
const calculation = this.calculation;
|
||||
if (!calculation) {
|
||||
|
||||
@@ -18,6 +18,10 @@ Allows [inline calculations](/docs/inline-calculations).
|
||||
|
||||
A [computed field](/docs/computed-fields) that determines how many spells can be considered ready to cast in this spell list.
|
||||
|
||||
### Spell casting ability
|
||||
|
||||
The spellcasting ablity for this spell list. The variable name of the ability can be accessed using `#spellList.ability` and the ability modifier with `#spellList.abilityMod`. Setting this field will automatically update Spell save DC and Attack roll bonus if they aren't set manually.
|
||||
|
||||
### Spell save DC
|
||||
|
||||
A [computed field](/docs/computed-fields) that determines the DC of saving throws in this spell list. Spells can access the DC of their spell list using `#spellList.dc`
|
||||
|
||||
Reference in New Issue
Block a user