diff --git a/app/imports/api/creature/computation/computeEndStepProperty.js b/app/imports/api/creature/computation/computeEndStepProperty.js index a38c3e5a..3ae9924a 100644 --- a/app/imports/api/creature/computation/computeEndStepProperty.js +++ b/app/imports/api/creature/computation/computeEndStepProperty.js @@ -16,6 +16,8 @@ export default function computeEndStepProperty(prop, memo){ case 'spellList': computeSpellList(prop, memo); break; + case 'propertySlot': + computeSlot(prop, memo); } } @@ -94,3 +96,13 @@ function computeSpellList(prop, memo){ delete prop.maxPreparedErrors; } } + +function computeSlot(prop, memo){ + let {value, errors} = evaluateCalculation(prop.slotCondition, memo); + prop.slotConditionResult = value; + if (errors.length){ + prop.slotConditionErrors = errors; + } else { + delete prop.slotConditionErrors; + } +} diff --git a/app/imports/api/creature/computation/recomputeCreature.js b/app/imports/api/creature/computation/recomputeCreature.js index ca0323ca..088a9a7f 100644 --- a/app/imports/api/creature/computation/recomputeCreature.js +++ b/app/imports/api/creature/computation/recomputeCreature.js @@ -49,6 +49,7 @@ const calculationPropertyTypes = [ 'savingThrow', 'spellList', 'spell', + 'propertySlot', ]; export function recomputeCreatureById(creatureId){ diff --git a/app/imports/api/creature/computation/writeAlteredProperties.js b/app/imports/api/creature/computation/writeAlteredProperties.js index 6a8129fc..9c34d071 100644 --- a/app/imports/api/creature/computation/writeAlteredProperties.js +++ b/app/imports/api/creature/computation/writeAlteredProperties.js @@ -13,6 +13,7 @@ import { ComputedOnlyAttackSchema } from '/imports/api/properties/Attacks.js'; import { ComputedOnlySavingThrowSchema } from '/imports/api/properties/SavingThrows.js'; import { ComputedOnlySpellListSchema } from '/imports/api/properties/SpellLists.js'; import { ComputedOnlySpellSchema } from '/imports/api/properties/Spells.js'; +import { ComputedOnlySlotSchema } from '/imports/api/properties/Slots.js'; const schemasByType = { 'skill': ComputedOnlySkillSchema, @@ -24,6 +25,7 @@ const schemasByType = { 'savingThrow': ComputedOnlySavingThrowSchema, 'spellList': ComputedOnlySpellListSchema, 'spell': ComputedOnlySpellSchema, + 'propertySlot': ComputedOnlySlotSchema, }; export default function writeAlteredProperties(memo){ diff --git a/app/imports/api/properties/Slots.js b/app/imports/api/properties/Slots.js index 949330d0..c3b5a994 100644 --- a/app/imports/api/properties/Slots.js +++ b/app/imports/api/properties/Slots.js @@ -1,6 +1,19 @@ import SimpleSchema from 'simpl-schema'; +import ErrorSchema from '/imports/api/properties/subSchemas/ErrorSchema.js'; let SlotSchema = new SimpleSchema({ + name: { + type: String, + optional: true, + }, + description: { + type: String, + optional: true, + }, + slotType: { + type: String, + optional: true, + }, slotTags: { type: Array, defaultValue: [], @@ -8,6 +21,43 @@ let SlotSchema = new SimpleSchema({ 'slotTags.$': { type: String, }, + quantityExpected: { + type: SimpleSchema.Integer, + defaultValue: 1, + }, + ignored: { + type: Boolean, + optional: true, + }, + slotCondition: { + type: String, + optional: true, + }, + // How many properties have been selected to fill this slot + quantityFilled: { + type: SimpleSchema.Integer, + defaultValue: 0, + }, }); -export { SlotSchema }; +const ComputedOnlySlotSchema = new SimpleSchema({ + // The computed result of the effect + slotConditionResult: { + type: SimpleSchema.oneOf(Number, String, Boolean), + optional: true, + }, + // The errors encountered while computing the result + slotConditionErrors: { + type: Array, + optional: true, + }, + 'slotConditionErrors.$':{ + type: ErrorSchema, + }, +}); + +const ComputedSlotSchema = new SimpleSchema() + .extend(ComputedOnlySlotSchema) + .extend(SlotSchema); + +export { SlotSchema, ComputedSlotSchema, ComputedOnlySlotSchema }; diff --git a/app/imports/api/properties/computedPropertySchemasIndex.js b/app/imports/api/properties/computedPropertySchemasIndex.js index c7167b49..d171a995 100644 --- a/app/imports/api/properties/computedPropertySchemasIndex.js +++ b/app/imports/api/properties/computedPropertySchemasIndex.js @@ -17,7 +17,7 @@ import { ProficiencySchema } from '/imports/api/properties/Proficiencies.js'; import { RollSchema } from '/imports/api/properties/Rolls.js'; import { ComputedSavingThrowSchema } from '/imports/api/properties/SavingThrows.js'; import { ComputedSkillSchema } from '/imports/api/properties/Skills.js'; -import { SlotSchema } from '/imports/api/properties/Slots.js'; +import { ComputedSlotSchema } from '/imports/api/properties/Slots.js'; import { ComputedSpellSchema } from '/imports/api/properties/Spells.js'; import { ComputedSpellListSchema } from '/imports/api/properties/SpellLists.js'; import { ToggleSchema } from '/imports/api/properties/Toggles.js'; @@ -39,7 +39,7 @@ const propertySchemasIndex = { roll: RollSchema, savingThrow: ComputedSavingThrowSchema, skill: ComputedSkillSchema, - slot: SlotSchema, + propertySlot: ComputedSlotSchema, spellList: ComputedSpellListSchema, spell: ComputedSpellSchema, toggle: ToggleSchema, diff --git a/app/imports/api/properties/propertySchemasIndex.js b/app/imports/api/properties/propertySchemasIndex.js index 088430d3..af7b31e3 100644 --- a/app/imports/api/properties/propertySchemasIndex.js +++ b/app/imports/api/properties/propertySchemasIndex.js @@ -39,7 +39,7 @@ const propertySchemasIndex = { roll: RollSchema, savingThrow: SavingThrowSchema, skill: SkillSchema, - slot: SlotSchema, + propertySlot: SlotSchema, spellList: SpellListSchema, spell: SpellSchema, toggle: ToggleSchema, diff --git a/app/imports/constants/PROPERTIES.js b/app/imports/constants/PROPERTIES.js index 43bfdab9..78828b06 100644 --- a/app/imports/constants/PROPERTIES.js +++ b/app/imports/constants/PROPERTIES.js @@ -71,6 +71,10 @@ const PROPERTIES = Object.freeze({ icon: '$vuetify.icons.skill', name: 'Skill' }, + propertySlot: { + icon: 'tab_unselected', + name: 'Slot' + }, spellList: { icon: '$vuetify.icons.spell_list', name: 'Spell list' diff --git a/app/imports/ui/properties/forms/SlotForm.vue b/app/imports/ui/properties/forms/SlotForm.vue new file mode 100644 index 00000000..dee3c005 --- /dev/null +++ b/app/imports/ui/properties/forms/SlotForm.vue @@ -0,0 +1,99 @@ + + + diff --git a/app/imports/ui/properties/forms/shared/propertyFormIndex.js b/app/imports/ui/properties/forms/shared/propertyFormIndex.js index 7235408c..0dcb0a98 100644 --- a/app/imports/ui/properties/forms/shared/propertyFormIndex.js +++ b/app/imports/ui/properties/forms/shared/propertyFormIndex.js @@ -16,6 +16,7 @@ import ProficiencyForm from '/imports/ui/properties/forms/ProficiencyForm.vue'; import RollForm from '/imports/ui/properties/forms/RollForm.vue'; import SavingThrowForm from '/imports/ui/properties/forms/SavingThrowForm.vue'; import SkillForm from '/imports/ui/properties/forms/SkillForm.vue'; +import SlotForm from '/imports/ui/properties/forms/SlotForm.vue'; import SpellListForm from '/imports/ui/properties/forms/SpellListForm.vue'; import SpellForm from '/imports/ui/properties/forms/SpellForm.vue'; import ToggleForm from '/imports/ui/properties/forms/ToggleForm.vue'; @@ -39,6 +40,7 @@ export default { roll: RollForm, savingThrow: SavingThrowForm, skill: SkillForm, + propertySlot: SlotForm, spellList: SpellListForm, spell: SpellForm, toggle: ToggleForm, diff --git a/app/imports/ui/properties/shared/PropertySelector.vue b/app/imports/ui/properties/shared/PropertySelector.vue index e7b44ff0..66698f72 100644 --- a/app/imports/ui/properties/shared/PropertySelector.vue +++ b/app/imports/ui/properties/shared/PropertySelector.vue @@ -1,20 +1,45 @@