Improved slot schema, added ui for slots
This commit is contained in:
@@ -16,6 +16,8 @@ export default function computeEndStepProperty(prop, memo){
|
|||||||
case 'spellList':
|
case 'spellList':
|
||||||
computeSpellList(prop, memo);
|
computeSpellList(prop, memo);
|
||||||
break;
|
break;
|
||||||
|
case 'propertySlot':
|
||||||
|
computeSlot(prop, memo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -94,3 +96,13 @@ function computeSpellList(prop, memo){
|
|||||||
delete prop.maxPreparedErrors;
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -49,6 +49,7 @@ const calculationPropertyTypes = [
|
|||||||
'savingThrow',
|
'savingThrow',
|
||||||
'spellList',
|
'spellList',
|
||||||
'spell',
|
'spell',
|
||||||
|
'propertySlot',
|
||||||
];
|
];
|
||||||
|
|
||||||
export function recomputeCreatureById(creatureId){
|
export function recomputeCreatureById(creatureId){
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import { ComputedOnlyAttackSchema } from '/imports/api/properties/Attacks.js';
|
|||||||
import { ComputedOnlySavingThrowSchema } from '/imports/api/properties/SavingThrows.js';
|
import { ComputedOnlySavingThrowSchema } from '/imports/api/properties/SavingThrows.js';
|
||||||
import { ComputedOnlySpellListSchema } from '/imports/api/properties/SpellLists.js';
|
import { ComputedOnlySpellListSchema } from '/imports/api/properties/SpellLists.js';
|
||||||
import { ComputedOnlySpellSchema } from '/imports/api/properties/Spells.js';
|
import { ComputedOnlySpellSchema } from '/imports/api/properties/Spells.js';
|
||||||
|
import { ComputedOnlySlotSchema } from '/imports/api/properties/Slots.js';
|
||||||
|
|
||||||
const schemasByType = {
|
const schemasByType = {
|
||||||
'skill': ComputedOnlySkillSchema,
|
'skill': ComputedOnlySkillSchema,
|
||||||
@@ -24,6 +25,7 @@ const schemasByType = {
|
|||||||
'savingThrow': ComputedOnlySavingThrowSchema,
|
'savingThrow': ComputedOnlySavingThrowSchema,
|
||||||
'spellList': ComputedOnlySpellListSchema,
|
'spellList': ComputedOnlySpellListSchema,
|
||||||
'spell': ComputedOnlySpellSchema,
|
'spell': ComputedOnlySpellSchema,
|
||||||
|
'propertySlot': ComputedOnlySlotSchema,
|
||||||
};
|
};
|
||||||
|
|
||||||
export default function writeAlteredProperties(memo){
|
export default function writeAlteredProperties(memo){
|
||||||
|
|||||||
@@ -1,6 +1,19 @@
|
|||||||
import SimpleSchema from 'simpl-schema';
|
import SimpleSchema from 'simpl-schema';
|
||||||
|
import ErrorSchema from '/imports/api/properties/subSchemas/ErrorSchema.js';
|
||||||
|
|
||||||
let SlotSchema = new SimpleSchema({
|
let SlotSchema = new SimpleSchema({
|
||||||
|
name: {
|
||||||
|
type: String,
|
||||||
|
optional: true,
|
||||||
|
},
|
||||||
|
description: {
|
||||||
|
type: String,
|
||||||
|
optional: true,
|
||||||
|
},
|
||||||
|
slotType: {
|
||||||
|
type: String,
|
||||||
|
optional: true,
|
||||||
|
},
|
||||||
slotTags: {
|
slotTags: {
|
||||||
type: Array,
|
type: Array,
|
||||||
defaultValue: [],
|
defaultValue: [],
|
||||||
@@ -8,6 +21,43 @@ let SlotSchema = new SimpleSchema({
|
|||||||
'slotTags.$': {
|
'slotTags.$': {
|
||||||
type: String,
|
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 };
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ import { ProficiencySchema } from '/imports/api/properties/Proficiencies.js';
|
|||||||
import { RollSchema } from '/imports/api/properties/Rolls.js';
|
import { RollSchema } from '/imports/api/properties/Rolls.js';
|
||||||
import { ComputedSavingThrowSchema } from '/imports/api/properties/SavingThrows.js';
|
import { ComputedSavingThrowSchema } from '/imports/api/properties/SavingThrows.js';
|
||||||
import { ComputedSkillSchema } from '/imports/api/properties/Skills.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 { ComputedSpellSchema } from '/imports/api/properties/Spells.js';
|
||||||
import { ComputedSpellListSchema } from '/imports/api/properties/SpellLists.js';
|
import { ComputedSpellListSchema } from '/imports/api/properties/SpellLists.js';
|
||||||
import { ToggleSchema } from '/imports/api/properties/Toggles.js';
|
import { ToggleSchema } from '/imports/api/properties/Toggles.js';
|
||||||
@@ -39,7 +39,7 @@ const propertySchemasIndex = {
|
|||||||
roll: RollSchema,
|
roll: RollSchema,
|
||||||
savingThrow: ComputedSavingThrowSchema,
|
savingThrow: ComputedSavingThrowSchema,
|
||||||
skill: ComputedSkillSchema,
|
skill: ComputedSkillSchema,
|
||||||
slot: SlotSchema,
|
propertySlot: ComputedSlotSchema,
|
||||||
spellList: ComputedSpellListSchema,
|
spellList: ComputedSpellListSchema,
|
||||||
spell: ComputedSpellSchema,
|
spell: ComputedSpellSchema,
|
||||||
toggle: ToggleSchema,
|
toggle: ToggleSchema,
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ const propertySchemasIndex = {
|
|||||||
roll: RollSchema,
|
roll: RollSchema,
|
||||||
savingThrow: SavingThrowSchema,
|
savingThrow: SavingThrowSchema,
|
||||||
skill: SkillSchema,
|
skill: SkillSchema,
|
||||||
slot: SlotSchema,
|
propertySlot: SlotSchema,
|
||||||
spellList: SpellListSchema,
|
spellList: SpellListSchema,
|
||||||
spell: SpellSchema,
|
spell: SpellSchema,
|
||||||
toggle: ToggleSchema,
|
toggle: ToggleSchema,
|
||||||
|
|||||||
@@ -71,6 +71,10 @@ const PROPERTIES = Object.freeze({
|
|||||||
icon: '$vuetify.icons.skill',
|
icon: '$vuetify.icons.skill',
|
||||||
name: 'Skill'
|
name: 'Skill'
|
||||||
},
|
},
|
||||||
|
propertySlot: {
|
||||||
|
icon: 'tab_unselected',
|
||||||
|
name: 'Slot'
|
||||||
|
},
|
||||||
spellList: {
|
spellList: {
|
||||||
icon: '$vuetify.icons.spell_list',
|
icon: '$vuetify.icons.spell_list',
|
||||||
name: 'Spell list'
|
name: 'Spell list'
|
||||||
|
|||||||
99
app/imports/ui/properties/forms/SlotForm.vue
Normal file
99
app/imports/ui/properties/forms/SlotForm.vue
Normal file
@@ -0,0 +1,99 @@
|
|||||||
|
<template lang="html">
|
||||||
|
<div class="spell-form">
|
||||||
|
<text-field
|
||||||
|
ref="focusFirst"
|
||||||
|
label="Name"
|
||||||
|
:value="model.name"
|
||||||
|
:error-messages="errors.name"
|
||||||
|
@change="change('name', ...arguments)"
|
||||||
|
/>
|
||||||
|
<smart-select
|
||||||
|
label="Type"
|
||||||
|
style="flex-basis: 300px;"
|
||||||
|
:items="slotTypes"
|
||||||
|
:value="model.slotType"
|
||||||
|
:error-messages="errors.slotType"
|
||||||
|
@change="change('slotType', ...arguments)"
|
||||||
|
/>
|
||||||
|
<smart-combobox
|
||||||
|
label="Tags"
|
||||||
|
hint="The slot must be filled with a property which has all the listed tags"
|
||||||
|
multiple
|
||||||
|
chips
|
||||||
|
deletable-chips
|
||||||
|
:value="model.slotTags"
|
||||||
|
:error-messages="errors.slotTags"
|
||||||
|
@change="change('slotTags', ...arguments)"
|
||||||
|
/>
|
||||||
|
<text-field
|
||||||
|
label="Quantity"
|
||||||
|
type="number"
|
||||||
|
min="1"
|
||||||
|
hint="How many matching properties must be used to fill this slot"
|
||||||
|
:value="model.quantityExpected"
|
||||||
|
:error-messages="errors.quantityExpected"
|
||||||
|
@change="change('quantityExpected', ...arguments)"
|
||||||
|
/>
|
||||||
|
<text-field
|
||||||
|
label="Condition"
|
||||||
|
hint="A caclulation to determine if this slot should be active"
|
||||||
|
placeholder="Always active"
|
||||||
|
:value="model.slotCondition"
|
||||||
|
:error-messages="errors.slotCondition"
|
||||||
|
@change="change('slotCondition', ...arguments)"
|
||||||
|
/>
|
||||||
|
<calculation-error-list :errors="model.slotConditionErrors" />
|
||||||
|
<text-area
|
||||||
|
label="Description"
|
||||||
|
:value="model.description"
|
||||||
|
:error-messages="errors.description"
|
||||||
|
@change="change('description', ...arguments)"
|
||||||
|
/>
|
||||||
|
<form-section
|
||||||
|
name="Advanced"
|
||||||
|
standalone
|
||||||
|
>
|
||||||
|
<text-field
|
||||||
|
label="Quantity filled"
|
||||||
|
type="number"
|
||||||
|
min="0"
|
||||||
|
hint="How many properties have already been selected to fill this slot"
|
||||||
|
:value="model.quantityFilled"
|
||||||
|
:error-messages="errors.quantityFilled"
|
||||||
|
@change="change('quantityFilled', ...arguments)"
|
||||||
|
/>
|
||||||
|
<div class="layout row wrap justify-space-between">
|
||||||
|
<smart-switch
|
||||||
|
label="Ignored"
|
||||||
|
style="width: 200px; flex-grow: 0;"
|
||||||
|
class="mx-2"
|
||||||
|
:value="model.ignored"
|
||||||
|
:error-messages="errors.ignored"
|
||||||
|
@change="change('ignored', ...arguments)"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</form-section>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import propertyFormMixin from '/imports/ui/properties/forms/shared/propertyFormMixin.js';
|
||||||
|
import FormSection from '/imports/ui/properties/forms/shared/FormSection.vue';
|
||||||
|
import CalculationErrorList from '/imports/ui/properties/forms/shared/CalculationErrorList.vue';
|
||||||
|
import PROPERTIES from '/imports/constants/PROPERTIES.js';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
components: {
|
||||||
|
FormSection,
|
||||||
|
CalculationErrorList,
|
||||||
|
},
|
||||||
|
mixins: [propertyFormMixin],
|
||||||
|
data(){
|
||||||
|
let slotTypes = [];
|
||||||
|
for (let key in PROPERTIES){
|
||||||
|
slotTypes.push({text: PROPERTIES[key].name, value: key});
|
||||||
|
}
|
||||||
|
return {slotTypes};
|
||||||
|
},
|
||||||
|
};
|
||||||
|
</script>
|
||||||
@@ -16,6 +16,7 @@ import ProficiencyForm from '/imports/ui/properties/forms/ProficiencyForm.vue';
|
|||||||
import RollForm from '/imports/ui/properties/forms/RollForm.vue';
|
import RollForm from '/imports/ui/properties/forms/RollForm.vue';
|
||||||
import SavingThrowForm from '/imports/ui/properties/forms/SavingThrowForm.vue';
|
import SavingThrowForm from '/imports/ui/properties/forms/SavingThrowForm.vue';
|
||||||
import SkillForm from '/imports/ui/properties/forms/SkillForm.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 SpellListForm from '/imports/ui/properties/forms/SpellListForm.vue';
|
||||||
import SpellForm from '/imports/ui/properties/forms/SpellForm.vue';
|
import SpellForm from '/imports/ui/properties/forms/SpellForm.vue';
|
||||||
import ToggleForm from '/imports/ui/properties/forms/ToggleForm.vue';
|
import ToggleForm from '/imports/ui/properties/forms/ToggleForm.vue';
|
||||||
@@ -39,6 +40,7 @@ export default {
|
|||||||
roll: RollForm,
|
roll: RollForm,
|
||||||
savingThrow: SavingThrowForm,
|
savingThrow: SavingThrowForm,
|
||||||
skill: SkillForm,
|
skill: SkillForm,
|
||||||
|
propertySlot: SlotForm,
|
||||||
spellList: SpellListForm,
|
spellList: SpellListForm,
|
||||||
spell: SpellForm,
|
spell: SpellForm,
|
||||||
toggle: ToggleForm,
|
toggle: ToggleForm,
|
||||||
|
|||||||
@@ -1,20 +1,45 @@
|
|||||||
<template lang="html">
|
<template lang="html">
|
||||||
<div>
|
<div>
|
||||||
<v-container fluid grid-list-lg fill-height>
|
<v-container
|
||||||
<v-layout row wrap fill-height>
|
fluid
|
||||||
<v-flex v-for="(property, type) in PROPERTIES" :key="type" sm4 xs6>
|
grid-list-lg
|
||||||
<v-card hover @click="$emit('select', type)" style="height: 100%; overflow: hidden;">
|
fill-height
|
||||||
<div class="layout row align-center justify-center" style="min-height: 70px;">
|
>
|
||||||
<v-icon x-large>{{property.icon}}</v-icon>
|
<v-layout
|
||||||
</div>
|
row
|
||||||
<h3 class="subtitle pb-3" style="text-align: center;">
|
wrap
|
||||||
{{ property.name }}
|
fill-height
|
||||||
</h3>
|
>
|
||||||
</v-card>
|
<v-flex
|
||||||
</v-flex>
|
v-for="(property, type) in PROPERTIES"
|
||||||
</v-layout>
|
:key="type"
|
||||||
</v-container>
|
sm4
|
||||||
</div>
|
xs6
|
||||||
|
>
|
||||||
|
<v-card
|
||||||
|
hover
|
||||||
|
style="height: 100%; overflow: hidden;"
|
||||||
|
@click="$emit('select', type)"
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
class="layout row align-center justify-center"
|
||||||
|
style="min-height: 70px;"
|
||||||
|
>
|
||||||
|
<v-icon x-large>
|
||||||
|
{{ property.icon }}
|
||||||
|
</v-icon>
|
||||||
|
</div>
|
||||||
|
<h3
|
||||||
|
class="subtitle pb-3"
|
||||||
|
style="text-align: center;"
|
||||||
|
>
|
||||||
|
{{ property.name }}
|
||||||
|
</h3>
|
||||||
|
</v-card>
|
||||||
|
</v-flex>
|
||||||
|
</v-layout>
|
||||||
|
</v-container>
|
||||||
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
|||||||
Reference in New Issue
Block a user