diff --git a/rpg-docs/Model/Character/Spells.js b/rpg-docs/Model/Character/Spells.js index f406c6bc..a5be9d03 100644 --- a/rpg-docs/Model/Character/Spells.js +++ b/rpg-docs/Model/Character/Spells.js @@ -6,7 +6,7 @@ Schemas.Spell = new SimpleSchema({ prepared: {type: String, defaultValue: "unprepared", allowedValues: ["prepared","unprepared","always"]}, name: {type: String}, description: {type: String, optional: true}, - castingTime: {type: String, optional: true}, + castingTime: {type: String, defaultValue: "action"}, range: {type: String, optional: true}, duration: {type: String, optional: true}, "components.verbal": {type: Boolean, defaultValue: false}, @@ -14,7 +14,9 @@ Schemas.Spell = new SimpleSchema({ "components.material": {type: String, optional: true}, "components.concentration": {type: Boolean, defaultValue: false}, ritual: {type: Boolean, defaultValue: false}, - level: {type: Number, defaultValue: 0} + level: {type: Number, defaultValue: 0}, + school: {type: String, defaultValue: "Abjuration", allowedValues: magicSchools}, + color: {type: String, allowedValues: _.keys(colorOptions), defaultValue: "green"} }); Spells.attachSchema(Schemas.Spell); diff --git a/rpg-docs/Model/Inventory/Items.js b/rpg-docs/Model/Inventory/Items.js index b63b8eec..d79c77f2 100644 --- a/rpg-docs/Model/Inventory/Items.js +++ b/rpg-docs/Model/Inventory/Items.js @@ -14,7 +14,8 @@ Schemas.Item = new SimpleSchema({ defaultValue: "none", allowedValues: ["none", "head", "armor", "arms", "hands", "held", "feet"] }, - equipped: {type: Boolean, defaultValue: false} + equipped: {type: Boolean, defaultValue: false}, + color: {type: String, allowedValues: _.keys(colorOptions), defaultValue: "green"} }); Items.attachSchema(Schemas.Item); diff --git a/rpg-docs/client/globalHelpers/colorClass.js b/rpg-docs/client/globalHelpers/colorClass.js index 3ea0df97..8b7700e3 100644 --- a/rpg-docs/client/globalHelpers/colorClass.js +++ b/rpg-docs/client/globalHelpers/colorClass.js @@ -1,3 +1,7 @@ Template.registerHelper("colorClass", function(color){ return color? getColorClass(color) : getColorClass(this.color); }); + +Template.registerHelper("hexColor", function(color){ + return colorOptions[color].color; +}); diff --git a/rpg-docs/client/views/GeneralCSS/general.css b/rpg-docs/client/views/GeneralCSS/general.css index b48a33d5..22dc52f3 100644 --- a/rpg-docs/client/views/GeneralCSS/general.css +++ b/rpg-docs/client/views/GeneralCSS/general.css @@ -132,3 +132,7 @@ paper-fab-menu /deep/ .container { padding-left: 16px; font-weight: 500; } + +.fullwidth { + width: 100%; +} diff --git a/rpg-docs/client/views/character/inventory/inventory.css b/rpg-docs/client/views/character/inventory/inventory.css index 61058be5..2560b07c 100644 --- a/rpg-docs/client/views/character/inventory/inventory.css +++ b/rpg-docs/client/views/character/inventory/inventory.css @@ -42,6 +42,14 @@ letter-spacing: 0.010em; } +.inventoryItem core-icon, .inventoryItem paper-icon-button { + color: rgba(0,0,0,0.54); +} + +.inventoryItem core-icon { + margin-right: 16px; +} + .inventoryItem /deep/ .button-content { -webkit-flex: 1; flex: 1; diff --git a/rpg-docs/client/views/character/inventory/itemDialog/itemDialog.html b/rpg-docs/client/views/character/inventory/itemDialog/itemDialog.html index 92c2c21c..2d987168 100644 --- a/rpg-docs/client/views/character/inventory/itemDialog/itemDialog.html +++ b/rpg-docs/client/views/character/inventory/itemDialog/itemDialog.html @@ -13,7 +13,7 @@
- + {{# if ne1 quantity}}{{/if}} {{# if canEquip}} diff --git a/rpg-docs/client/views/character/spells/spellDialog/spellDialog.html b/rpg-docs/client/views/character/spells/spellDialog/spellDialog.html new file mode 100644 index 00000000..cf29d241 --- /dev/null +++ b/rpg-docs/client/views/character/spells/spellDialog/spellDialog.html @@ -0,0 +1,89 @@ + \ No newline at end of file diff --git a/rpg-docs/client/views/character/spells/spellDialog/spellDialog.js b/rpg-docs/client/views/character/spells/spellDialog/spellDialog.js new file mode 100644 index 00000000..72b72fb4 --- /dev/null +++ b/rpg-docs/client/views/character/spells/spellDialog/spellDialog.js @@ -0,0 +1,138 @@ +var spellLevels = [ + { name: "Cantrips", level: 0 }, + { name: "Level 1", level: 1 }, + { name: "Level 2", level: 2 }, + { name: "Level 3", level: 3 }, + { name: "Level 4", level: 4 }, + { name: "Level 5", level: 5 }, + { name: "Level 6", level: 6 }, + { name: "Level 7", level: 7 }, + { name: "Level 8", level: 8 }, + { name: "Level 9", level: 9 }, +]; + +Template.spellDialog.rendered = function(){ + var self = this; + //update all autogrows after they've been filled + var pata = this.$("paper-autogrow-textarea"); + pata.each(function(index, el){ + el.update($(el).children().get(0)); + }) + //update all input fields as well + var input = this.$("paper-input"); + input.each(function(index, el){ + el.valueChanged(); + }) + //after the dialog is built, open it + if (!this.alreadyRendered){ + Session.set("global.ui.detailShow", true); + this.alreadyRendered = true; + } +} + +Template.spellDialog.events({ + "tap #backButton": function(){ + GlobalUI.closeDetail(); + }, + "tap #deleteSpell": function(){ + Spells.remove(this._id); + GlobalUI.closeDetail(); + }, + //TODO clean up String -> num here so they don't need casting by Schema.clean + //TODO validate input (integer, non-negative, etc) for these inputs and give validation errors + "change #spellNameInput, input #spellNameInput": function(event){ + var value = event.currentTarget.value + Spells.update(this._id, {$set: {name: value}}); + }, + "change #castingTimeInput": function(event){ + var value = event.currentTarget.value + Spells.update(this._id, {$set: {castingTime: value}}); + }, + "change #rangeInput": function(event){ + var value = event.currentTarget.value + Spells.update(this._id, {$set: {range: value}}); + }, + "change #durationInput": function(event){ + var value = event.currentTarget.value + Spells.update(this._id, {$set: {duration: value}}); + }, + "change #materialInput": function(event){ + var value = event.currentTarget.value + Spells.update(this._id, {$set: {"components.material": value}}); + }, + "change #descriptionInput": function(event){ + var value = event.currentTarget.value + Spells.update(this._id, {$set: {"description": value}}); + }, + "core-select #listDropdown": function(event){ + var detail = event.originalEvent.detail; + if(!detail.isSelected) return; + var value = detail.item.getAttribute("name"); + Spells.update(this._id, {$set: {listId: value}}); + }, + "core-select #levelDropdown": function(event){ + var detail = event.originalEvent.detail; + if(!detail.isSelected) return; + var value = detail.item.getAttribute("name"); + Spells.update(this._id, {$set: {level: value}}); + }, + "core-select #schoolDropdown": function(event){ + var detail = event.originalEvent.detail; + if(!detail.isSelected) return; + var value = detail.item.getAttribute("name"); + Spells.update(this._id, {$set: {school: value}}); + }, + "core-select #preparedDropdown": function(event){ + var detail = event.originalEvent.detail; + if(!detail.isSelected) return; + var value = detail.item.getAttribute("name"); + Spells.update(this._id, {$set: {prepared: value}}); + }, + "core-select .colorDropdown": function(event){ + var detail = event.originalEvent.detail; + if(!detail.isSelected) return; + var value = detail.item.getAttribute("name"); + Spells.update(this._id, {$set: {color: value}}); + }, + "change #verbalCheckbox": function(event){ + var value = event.currentTarget.checked; + Spells.update(this._id, {$set: {"components.verbal": value}}); + }, + "change #somaticCheckbox": function(event){ + var value = event.currentTarget.checked; + Spells.update(this._id, {$set: {"components.somatic": value}}); + }, + "change #concentrationCheckbox": function(event){ + var value = event.currentTarget.checked; + Spells.update(this._id, {$set: {"components.concentration": value}}); + }, + "change #ritualCheckbox": function(event){ + var value = event.currentTarget.checked; + Spells.update(this._id, {$set: {"ritual": value}}); + }, +}); + +Template.spellDialog.helpers({ + spell: function(){ + return Spells.findOne(this.spellId); + }, + colorClass: function(){ + return getColorClass(this.color) + }, + spellLists: function(){ + return SpellLists.find({charId: this.charId}, {fields: {name: 1}}); + }, + magicSchools: function(){ + return magicSchools; + }, + spellLevels: function(){ + return spellLevels; + }, + preparedOptions: function(){ + return [ + {name: "Prepared", value: "prepared"}, + {name: "Unprepared", value: "unprepared"}, + {name: "Always Prepared", value: "always"} + ]; + } +}); \ No newline at end of file diff --git a/rpg-docs/client/views/character/spells/spellListDialog/spellListDialog.js b/rpg-docs/client/views/character/spells/spellListDialog/spellListDialog.js index 7e3b4888..2189664e 100644 --- a/rpg-docs/client/views/character/spells/spellListDialog/spellListDialog.js +++ b/rpg-docs/client/views/character/spells/spellListDialog/spellListDialog.js @@ -43,6 +43,7 @@ Template.spellListDialog.events({ var value = event.currentTarget.value SpellLists.update(this._id, {$set: {maxPrepared: value}}); }, + //TODO change #spellListDescription "core-select .colorDropdown": function(event){ var detail = event.originalEvent.detail; if(!detail.isSelected) return; diff --git a/rpg-docs/client/views/character/spells/spells.css b/rpg-docs/client/views/character/spells/spells.css new file mode 100644 index 00000000..674937de --- /dev/null +++ b/rpg-docs/client/views/character/spells/spells.css @@ -0,0 +1,8 @@ +#spells .inventoryItem { + height: 56px; +} + +#spells .inventoryItem core-icon{ + width: 32px; + height: 32px; +} diff --git a/rpg-docs/client/views/character/spells/spells.html b/rpg-docs/client/views/character/spells/spells.html index 182c686b..bf36fb50 100644 --- a/rpg-docs/client/views/character/spells/spells.html +++ b/rpg-docs/client/views/character/spells/spells.html @@ -26,10 +26,19 @@ {{/if}} {{#each spells ../_id ../../_id}}
- - -
{{name}}
- + + +
+
{{name}}
+
+ {{school}} {{castingTime}}{{#if ritual}} (ritual){{/if}} - {{spellComponents}} +
+
+ {{#if ../../settings.showUnprepared}} + + {{else}} + + {{/if}}
{{/each}} diff --git a/rpg-docs/client/views/character/spells/spells.js b/rpg-docs/client/views/character/spells/spells.js index 37f328ed..779ee63d 100644 --- a/rpg-docs/client/views/character/spells/spells.js +++ b/rpg-docs/client/views/character/spells/spells.js @@ -29,6 +29,29 @@ Template.spells.helpers({ }, order: function(){ return _.indexOf(_.keys(colorOptions), this.color); + }, + spellComponents: function(){ + var components = ""; + if(this.components.verbal){ + components += "V" + } + if(this.components.somatic){ + components += components? ", S" : "S"; + } + if(this.components.material){ + components += components? ", M" : "M"; + components += "("+this.components.material+")"; + } + if(this.components.concentration){ + components += " - Requires concentration" + } + return components; + }, + isPrepared: function(){ + return this.prepared === "prepared" || this.prepared === "always"; + }, + cantUnprepare: function(){ + return this.prepared === "always"; } }); @@ -40,6 +63,13 @@ Template.spells.events({ heroId: this._id }); }, + "tap .spell": function(event){ + GlobalUI.setDetail({ + template: "spellDialog", + data: {spellId: this._id, charId: this.charId}, + heroId: this._id + }); + }, "tap #addSpellList": function(event){ var charId = this.charId; SpellLists.insert({ @@ -57,10 +87,31 @@ Template.spells.events({ } }); }, - "downAction .castButton": function(event){ - event.stopPropagation() + "tap #addSpell": function(event){ + var charId = this.charId; + var listId = this.listId; + Spells.insert({ + name: "New Spell", + charId: this._id, + listId: SpellLists.findOne({charId: this._id})._id + }, function(error, id){ + if(!error){ + GlobalUI.setDetail({ + template: "spellDialog", + data: {spellId: id, charId: charId, listId: listId}, + heroId: id + }); + } + }); }, - "upAction .castButton": function(event){ - event.stopPropagation() + "tap .preparedCheckbox": function(event){ + event.stopPropagation(); + }, + "change .preparedCheckbox": function(event){ + var value = event.currentTarget.checked; + if(this.prepared === "unprepared" && value) + Spells.update(this._id, {$set: {prepared: "prepared"}}); + else if(this.prepared === "prepared" && !value) + Spells.update(this._id, {$set: {prepared: "unprepared"}}); } }); diff --git a/rpg-docs/client/views/layout/imports.html b/rpg-docs/client/views/layout/imports.html index 168141aa..b17c5f30 100644 --- a/rpg-docs/client/views/layout/imports.html +++ b/rpg-docs/client/views/layout/imports.html @@ -14,6 +14,7 @@ + diff --git a/rpg-docs/lib/constants/colorOptions.js b/rpg-docs/lib/constants/colorOptions.js index 451e3c8d..0710278b 100644 --- a/rpg-docs/lib/constants/colorOptions.js +++ b/rpg-docs/lib/constants/colorOptions.js @@ -1,24 +1,24 @@ colorOptions = { - "red": {whiteText: true}, - "pink": {whiteText: true}, - "purple": {whiteText: true}, - "deep-purple": {whiteText: true}, - "indigo": {whiteText: true}, - "blue": {whiteText: true}, - "light-blue": {whiteText: true}, - "cyan": {whiteText: true}, - "teal": {whiteText: true}, - "green": {whiteText: true}, - "light-green": {whiteText: true}, - "lime": {whiteText: false}, - "yellow": {whiteText: false}, - "amber": {whiteText: false}, - "orange": {whiteText: false}, - "deep-orange": {whiteText: true}, - "brown": {whiteText: true}, - "grey": {whiteText: true}, //spec says no white text - "blue-grey": {whiteText: true}, - "black": {whiteText: true}, + "red": {whiteText: true, color: "#F44336"}, + "pink": {whiteText: true, color: "#E91E63"}, + "purple": {whiteText: true, color: "#9C27B0"}, + "deep-purple": {whiteText: true, color: "#673AB7"}, + "indigo": {whiteText: true, color: "#3F51B5"}, + "blue": {whiteText: true, color: "#2196F3"}, + "light-blue": {whiteText: true, color: "#03A9F4"}, + "cyan": {whiteText: true, color: "#00BCD4"}, + "teal": {whiteText: true, color: "#009688"}, + "green": {whiteText: true, color: "#4CAF50"}, + "light-green": {whiteText: true, color: "#8BC34A"}, + "lime": {whiteText: false, color: "#CDDC39"}, + "yellow": {whiteText: false, color: "#FFEB3B"}, + "amber": {whiteText: false, color: "#FFC107"}, + "orange": {whiteText: false, color: "#FF9800"}, + "deep-orange": {whiteText: true, color: "#FF5722"}, + "grey": {whiteText: true, color: "#9E9E9E"}, //spec says no white text + //"blue-grey": {whiteText: true, color: "#607D8B"}, + "brown": {whiteText: true, color: "#795548"}, + "black": {whiteText: true, color: "#000000"}, }; getColorClass = function(key){ diff --git a/rpg-docs/lib/constants/magicSchools.js b/rpg-docs/lib/constants/magicSchools.js new file mode 100644 index 00000000..fcc94145 --- /dev/null +++ b/rpg-docs/lib/constants/magicSchools.js @@ -0,0 +1,9 @@ +magicSchools = [ + "Abjuration", + "Conjuration", + "Divination", + "Enchantment", + "Evocation", + "Illusion", + "Necromancy" +];