diff --git a/app/imports/api/creature/properties/Buffs.js b/app/imports/api/creature/properties/Buffs.js index 4c9c9cbf..2985b4f6 100644 --- a/app/imports/api/creature/properties/Buffs.js +++ b/app/imports/api/creature/properties/Buffs.js @@ -14,6 +14,13 @@ import updateSchemaMixin from '/imports/api/creature/mixins/updateSchemaMixin.js let Buffs = new Mongo.Collection('buffs'); let BuffSchema = new SimpleSchema({ + _id: { + type: String, + regEx: SimpleSchema.RegEx.Id, + autoValue(){ + if (!this.isSet) return Random.id(); + } + }, name: { type: String, optional: true, @@ -23,9 +30,8 @@ let BuffSchema = new SimpleSchema({ optional: true, }, duration: { - type: SimpleSchema.Integer, + type: String, optional: true, - min: 0, }, }); diff --git a/app/imports/api/creature/properties/Effects.js b/app/imports/api/creature/properties/Effects.js index c166b674..0e5691eb 100644 --- a/app/imports/api/creature/properties/Effects.js +++ b/app/imports/api/creature/properties/Effects.js @@ -18,6 +18,13 @@ let Effects = new Mongo.Collection('effects'); * that modify their final value or presentation in some way */ let EffectSchema = schema({ + _id: { + type: String, + regEx: SimpleSchema.RegEx.Id, + autoValue(){ + if (!this.isSet) return Random.id(); + } + }, name: { type: String, optional: true, diff --git a/app/imports/api/creature/subSchemas/AdjustmentSchema.js b/app/imports/api/creature/subSchemas/AdjustmentSchema.js index 8d56c8f0..c23393d1 100644 --- a/app/imports/api/creature/subSchemas/AdjustmentSchema.js +++ b/app/imports/api/creature/subSchemas/AdjustmentSchema.js @@ -7,8 +7,7 @@ const AdjustmentSchema = new SimpleSchema({ type: String, regEx: SimpleSchema.RegEx.Id, autoValue(){ - if (this.isSet) return; - return Random.id(); + if (!this.isSet) return Random.id(); } }, // The roll that determines how much to damage the attribute diff --git a/app/imports/ui/StoryBook.vue b/app/imports/ui/StoryBook.vue index 83f1bfe2..9956334b 100644 --- a/app/imports/ui/StoryBook.vue +++ b/app/imports/ui/StoryBook.vue @@ -45,7 +45,7 @@ import ColorPicker from '/imports/ui/components/ColorPicker.Story.vue'; import ColumnLayout from "/imports/ui/components/ColumnLayout.Story.vue"; import DialogStack from '/imports/ui/dialogStack/DialogStack.Story.vue'; - import EffectEdit from '/imports/ui/creature/properties/effects/EffectEdit.Story.vue'; + import EffectForm from '/imports/ui/creature/properties/effects/EffectForm.Story.vue'; import EffectEditExpansionList from '/imports/ui/creature/properties/effects/EffectEditExpansionList.Story.vue'; import FeatureCard from '/imports/ui/creature/properties/features/FeatureCard.Story.vue'; import HealthBar from '/imports/ui/creature/properties/attributes/HealthBar.Story.vue'; @@ -66,7 +66,7 @@ ColorPicker, ColumnLayout, DialogStack, - EffectEdit, + EffectForm, EffectEditExpansionList, FeatureCard, HealthBar, diff --git a/app/imports/ui/components/forms/schemaFormMixin.js b/app/imports/ui/components/forms/schemaFormMixin.js index c42debb1..25579a02 100644 --- a/app/imports/ui/components/forms/schemaFormMixin.js +++ b/app/imports/ui/components/forms/schemaFormMixin.js @@ -2,6 +2,18 @@ * Forms that take in a schema and a model of the current data, manages smart * inputs, and sends update events when valid data model changes must occur */ +import { get, toPath } from 'lodash'; +function resolvePath(model, path){ + let arrayPath = toPath(path); + if (arrayPath.length === 1){ + return { object: model, key: arrayPath[0] }; + } + let objectPath = arrayPath.slice(0, -1); + let key = arrayPath.slice(-1); + let object = get(model, objectPath); + return {object, key}; +}; + const schemaFormMixin = { data(){ return { valid: true, @@ -26,26 +38,19 @@ const schemaFormMixin = { }, }, methods: { - change(modifier, ack){ - for (let key in modifier){ - this.$set(this.model, key, modifier[key]) - } + // Sets the value at the given path + change({path, value, ack}){ + let {object, key} = resolvePath(this.model, path); + this.$set(object, key, value); if (ack) ack(); }, - push(modifier, ack){ - for (let key in modifier){ - this.model[key].push(modifier[key]); - } + push({path, value, ack}){ + get(this.model, path).push(value); if (ack) ack(); }, - changeAtIndex(field, index, modifier, ack){ - for (let key in modifier){ - this.$set(this.model[field][index], key, modifier[key]) - } - if (ack) ack(); - }, - removeAtIndex(field, index, ack){ - this.model[field].splice(index, 1); + pull({path, ack}){ + let {object, key} = resolvePath(this.model, path); + object.splice(key, 1); if (ack) ack(); }, }, diff --git a/app/imports/ui/components/global/TextArea.vue b/app/imports/ui/components/global/TextArea.vue index c53c6fc6..490a9acb 100644 --- a/app/imports/ui/components/global/TextArea.vue +++ b/app/imports/ui/components/global/TextArea.vue @@ -8,6 +8,7 @@ @input="input" @focus="focused = true" @blur="focused = false" + box /> diff --git a/app/imports/ui/creature/properties/actions/ActionForm.vue b/app/imports/ui/creature/properties/actions/ActionForm.vue index 55836bf5..c19328a8 100644 --- a/app/imports/ui/creature/properties/actions/ActionForm.vue +++ b/app/imports/ui/creature/properties/actions/ActionForm.vue @@ -3,7 +3,7 @@ @@ -13,7 +13,7 @@ :value="model.type" :error-messages="errors.type" :menu-props="{auto: true, lazy: true}" - @change="(type, ack) => $emit('change', {type}, ack)" + @change="(value, ack) => $emit('change', {path: ['type'], value, ack})" :hint="actionTypeHints[model.type]" :debounce-time="debounceTime" /> @@ -26,7 +26,7 @@ :value="model.target" :error-messages="errors.target" :menu-props="{auto: true, lazy: true}" - @change="(target, ack) => $emit('change', {target}, ack)" + @change="(value, ack) => $emit('change', {path: ['target'], value, ack})" :debounce-time="debounceTime" />
@@ -35,7 +35,7 @@ hint="How many times this action can be used before needing to be reset" style="flex-basis: 300px;" :value="model.uses" - @change="(uses, ack) => $emit('change', {uses}, ack)" + @change="(value, ack) => $emit('change', {path: ['uses'], value, ack})" :error-messages="errors.uses" :debounce-time="debounceTime" /> @@ -45,7 +45,7 @@ hint="How many times this action has already been used" style="flex-basis: 300px;" :value="model.usesUsed" - @change="(uses, ack) => $emit('change', {uses}, ack)" + @change="(value, ack) => $emit('change', {path: ['usesUsed'], value, ack})" :error-messages="errors.uses" :debounce-time="debounceTime" /> @@ -58,11 +58,11 @@ :value="model.reset" :error-messages="errors.reset" :menu-props="{auto: true, lazy: true}" - @change="(reset, ack) => $emit('change', {reset}, ack)" + @change="(value, ack) => $emit('change', {path: ['reset'], value, ack})" :debounce-time="debounceTime" /> - +
Adjustments can be used to automatically spend resources or deal damage when taking an action. @@ -71,9 +71,22 @@ + + +
+ Buffs apply temporary effects to characters when taking an action. +
+
@@ -83,14 +96,19 @@ + + diff --git a/app/imports/ui/creature/properties/buffs/BuffListForm.vue b/app/imports/ui/creature/properties/buffs/BuffListForm.vue new file mode 100644 index 00000000..bbbc9d1e --- /dev/null +++ b/app/imports/ui/creature/properties/buffs/BuffListForm.vue @@ -0,0 +1,77 @@ + + + + + diff --git a/app/imports/ui/creature/properties/effects/EffectEditExpansionList.vue b/app/imports/ui/creature/properties/effects/EffectEditExpansionList.vue index 49eb2cb7..cd98183d 100644 --- a/app/imports/ui/creature/properties/effects/EffectEditExpansionList.vue +++ b/app/imports/ui/creature/properties/effects/EffectEditExpansionList.vue @@ -14,7 +14,7 @@ :class="{'primary--text': expanded === index}" v-bind="effect" /> - + + + + + + + diff --git a/app/imports/ui/library/LibraryNodeInsertForm.vue b/app/imports/ui/library/LibraryNodeInsertForm.vue index 04ade5b1..32fbca85 100644 --- a/app/imports/ui/library/LibraryNodeInsertForm.vue +++ b/app/imports/ui/library/LibraryNodeInsertForm.vue @@ -3,14 +3,14 @@
Add {{propertyName}}