Improved slot schema, added ui for slots

This commit is contained in:
Stefan Zermatten
2020-06-29 14:15:49 +02:00
parent e1ddfb2cab
commit 6ddea8a8ab
10 changed files with 215 additions and 20 deletions

View File

@@ -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;
}
}

View File

@@ -49,6 +49,7 @@ const calculationPropertyTypes = [
'savingThrow',
'spellList',
'spell',
'propertySlot',
];
export function recomputeCreatureById(creatureId){

View File

@@ -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){

View File

@@ -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 };

View File

@@ -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,

View File

@@ -39,7 +39,7 @@ const propertySchemasIndex = {
roll: RollSchema,
savingThrow: SavingThrowSchema,
skill: SkillSchema,
slot: SlotSchema,
propertySlot: SlotSchema,
spellList: SpellListSchema,
spell: SpellSchema,
toggle: ToggleSchema,