diff --git a/rpg-docs/Model/Character/Characters.js b/rpg-docs/Model/Character/Characters.js index 48091545..d4a081ea 100644 --- a/rpg-docs/Model/Character/Characters.js +++ b/rpg-docs/Model/Character/Characters.js @@ -223,7 +223,7 @@ Characters.attachSchema(Schemas.Character); var attributeBase = function(charId, statName){ check(statName, String); - var effects = Effects.find({charId: charId, stat: statName}).fetch(); + var effects = Effects.find({charId: charId, stat: statName, enabled: true}).fetch(); effects = _.groupBy(effects, "operation"); var value = 0; @@ -360,7 +360,7 @@ Characters.helpers({ //add multiplied proficiency bonus to modifier mod += prof * this.attributeValue("proficiencyBonus"); - Effects.find({charId: charId, stat: skillName}).forEach(function(effect){ + Effects.find({charId: charId, stat: skillName, enabled: true}).forEach(function(effect){ switch(effect.operation) { case "add": mod += evaluateEffect(charId, effect); @@ -390,7 +390,7 @@ Characters.helpers({ var charId = this._id; //return largest value in proficiency array var prof = 0; - Effects.find({charId: charId, stat: skillName}).forEach(function(effect){ + Effects.find({charId: charId, stat: skillName, enabled: true}).forEach(function(effect){ if(effect.operation === "proficiency"){ var newProf = evaluateEffect(charId, effect); if (newProf > prof){ @@ -408,7 +408,7 @@ Characters.helpers({ var charId = this._id var mod = +this.skillMod(skillName); var value = 10 + mod; - Effects.find({charId: charId, stat: skillName}).forEach(function(effect){ + Effects.find({charId: charId, stat: skillName, enabled: true}).forEach(function(effect){ if(effect.operation === "passiveAdd"){ value += evaluateEffect(charId, effect); } diff --git a/rpg-docs/Model/Character/Effects.js b/rpg-docs/Model/Character/Effects.js index 3d0c5ade..224c3355 100644 --- a/rpg-docs/Model/Character/Effects.js +++ b/rpg-docs/Model/Character/Effects.js @@ -43,7 +43,27 @@ Schemas.Effect = new SimpleSchema({ stat: { type: String, optional: true + }, + enabled: { + type: Boolean, + defaultValue: true } }); Effects.attachSchema(Schemas.Effect); + +//Keep effects in-sync with items +Effects.find({type: "equipment"}, {fields: {type: 1, enabled: 1, sourceId: 1}}).observe({ + added: function(newEffect){ + var item = Items.findOne(newEffect.sourceId); + if(item && item.equipped !== newEffect.enabled){ + Effects.update(newEffect._id, {$set: {enabled: item.equipped}}) + } + }, + changed: function(newEffect, oldEffect){ + var item = Items.findOne(newEffect.sourceId); + if(item && item.equipped !== newEffect.enabled){ + Effects.update(newEffect._id, {$set: {enabled: item.equipped}}) + } + } +}) \ No newline at end of file diff --git a/rpg-docs/Model/Character/SubSchemas/Effect/Effect.js b/rpg-docs/Model/Character/SubSchemas/Effect/Effect.js deleted file mode 100644 index 0034ce8a..00000000 --- a/rpg-docs/Model/Character/SubSchemas/Effect/Effect.js +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Effects are reason-value attached to skills and abilities - * that modify their final value or presentation in some way - */ -Schemas.Effect = new SimpleSchema({ - _id: { - type: String, - regEx: SimpleSchema.RegEx.Id, - autoValue: function(){ - if(!this.isSet) return Random.id(); - } - }, - name: { - type: String - }, - operation: { - type: String, - defaultValue: "add", - allowedValues: ["base", "proficiency","add","mul","min","max","advantage","disadvantage","passiveAdd","fail","conditional"] - }, - value: { - type: Number, - decimal: true, - optional: true - }, - calculation: { - type: String, - optional: true - }, - //indicates what the effect originated from - type: { - type: String, - defaultValue: "editable", - allowedValues: ["editable", "feature", "buff", "equipment", "inate"] - }, - //which stat the effect is applied to - stat: { - type: String, - optional: true - } -}); \ No newline at end of file diff --git a/rpg-docs/Model/Inventory/Items.js b/rpg-docs/Model/Inventory/Items.js index d7cd1649..7333f4cc 100644 --- a/rpg-docs/Model/Inventory/Items.js +++ b/rpg-docs/Model/Inventory/Items.js @@ -4,13 +4,11 @@ Schemas.Item = new SimpleSchema({ name: {type: String, defaultValue: "New Item"}, plural: {type: String, optional: true}, description:{type: String, defaultValue: ""}, - container: {type: String, regEx: SimpleSchema.RegEx.Id, optional: true}, //id of container it normally is stowed in - charId: {type: String, regEx: SimpleSchema.RegEx.Id, optional: true}, //id of owner + container: {type: String, regEx: SimpleSchema.RegEx.Id}, //id of container it is normally stowed in + charId: {type: String, regEx: SimpleSchema.RegEx.Id}, //id of owner quantity: {type: Number, min: 0, defaultValue: 1}, weight: {type: Number, min: 0, defaultValue: 0, decimal: true}, value: {type: Number, min: 0, defaultValue: 0, decimal: true}, - tradeGood: {type: Boolean, defaultValue: false}, - stackable: {type: Boolean, defaultValue: false}, equipmentSlot: { type: String, defaultValue: "none", @@ -29,10 +27,33 @@ Items.helpers({ return this.weight * this.quantity; }, pluralName: function(){ - if(this.stackable && this.plural && this.quantity > 1){ + if(this.plural && this.quantity > 1){ return this.plural; } else{ return this.name; } } -}); \ No newline at end of file +}); + +//keep effects sycned with items +Items.find({}, {fields: {equipped: 1}}).observeChanges({ + added: function(id, fields){ + Effects.find({type: "equipment", sourceId: id}, {fields: {enabled: 1} }).forEach(function(effect){ + if(fields.equipped !== effect.enabled){ + Effects.update(effect._id, {$set: {enabled: fields.equipped}}) + } + }); + }, + changed: function(id, fields){ + Effects.find({type: "equipment", sourceId: id}, {fields: {enabled: 1} }).forEach(function(effect){ + if(fields.equipped !== effect.enabled){ + Effects.update(effect._id, {$set: {enabled: fields.equipped}}) + } + }); + }, + removed: function(id){ + Effects.find({type: "equipment", sourceId: id}, {fields: {_id: 1} }).forEach(function(effect){ + Effects.remove(effect._id); + }); + } +}); diff --git a/rpg-docs/bower.json b/rpg-docs/bower.json index 5b99a63a..a6176151 100644 --- a/rpg-docs/bower.json +++ b/rpg-docs/bower.json @@ -15,7 +15,8 @@ "dependencies": { "polymer": "Polymer/polymer#~0.5.2", "core-elements": "Polymer/core-elements#~0.5.2", - "paper-elements": "Polymer/paper-elements#~0.5.2" + "paper-elements": "Polymer/paper-elements#~0.5.2", + "paper-fab-menu": "cwdoh/paper-fab-menu" }, "resolutions": { "core-component-page": "^0.5.0", diff --git a/rpg-docs/client/views/GeneralCSS/general.css b/rpg-docs/client/views/GeneralCSS/general.css index 9e0c2e89..a94bed0c 100644 --- a/rpg-docs/client/views/GeneralCSS/general.css +++ b/rpg-docs/client/views/GeneralCSS/general.css @@ -112,3 +112,13 @@ paper-button { border-radius: 0; } } + +.floatyButton { + position: absolute; + bottom: 24px; + right: 24px; +} + +paper-fab-menu /deep/ .container { + padding: 24px !important; +} diff --git a/rpg-docs/client/views/character/Stats/stats.html b/rpg-docs/client/views/character/Stats/stats.html index f5b4b095..8602e34c 100644 --- a/rpg-docs/client/views/character/Stats/stats.html +++ b/rpg-docs/client/views/character/Stats/stats.html @@ -1,5 +1,5 @@ diff --git a/rpg-docs/client/views/character/features/featuresDialog.css b/rpg-docs/client/views/character/effectEdit/effectEdit.css similarity index 88% rename from rpg-docs/client/views/character/features/featuresDialog.css rename to rpg-docs/client/views/character/effectEdit/effectEdit.css index 0765c384..58cef736 100644 --- a/rpg-docs/client/views/character/features/featuresDialog.css +++ b/rpg-docs/client/views/character/effectEdit/effectEdit.css @@ -1,7 +1,3 @@ -body /deep/ .featureDialogWidth { - width: 560px; -} - body /deep/ #statGroupDropDown { width: 120px; } @@ -29,4 +25,4 @@ html /deep/ paper-input { html /deep/ .featureEffect { display: flex; align-items: flex-end; -} \ No newline at end of file +} diff --git a/rpg-docs/client/views/character/features/featureEffect.html b/rpg-docs/client/views/character/effectEdit/effectEdit.html similarity index 95% rename from rpg-docs/client/views/character/features/featureEffect.html rename to rpg-docs/client/views/character/effectEdit/effectEdit.html index af9ad468..a1cc9e03 100644 --- a/rpg-docs/client/views/character/features/featureEffect.html +++ b/rpg-docs/client/views/character/effectEdit/effectEdit.html @@ -1,10 +1,10 @@ -