From 848902c358a17bdc1ec0baee9d5caf084ffff1a9 Mon Sep 17 00:00:00 2001 From: Thaum Date: Wed, 28 Jan 2015 12:12:43 +0000 Subject: [PATCH] Fixed bug with skillMod calculation --- rpg-docs/Model/Character/Characters.js | 2 +- rpg-docs/Model/Inventory/Items.js | 7 ++----- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/rpg-docs/Model/Character/Characters.js b/rpg-docs/Model/Character/Characters.js index 3fecb1c5..40de4920 100644 --- a/rpg-docs/Model/Character/Characters.js +++ b/rpg-docs/Model/Character/Characters.js @@ -349,7 +349,7 @@ Characters.helpers({ var mod = +getMod(ability) //multiply proficiency bonus by largest value in proficiency array - var prof = this.proficiency(skill); + var prof = this.proficiency(skillName); //add multiplied proficiency bonus to modifier mod += prof * this.attributeValue("proficiencyBonus"); diff --git a/rpg-docs/Model/Inventory/Items.js b/rpg-docs/Model/Inventory/Items.js index 7423f039..c316f573 100644 --- a/rpg-docs/Model/Inventory/Items.js +++ b/rpg-docs/Model/Inventory/Items.js @@ -36,6 +36,7 @@ Items.helpers({ }); //keep effects sycned with items +//if an item's equipped state changes, update related effects' enabled state Items.find({}, {fields: {equipped: 1}}).observeChanges({ added: function(id, fields){ Effects.find({ type: "equipment", sourceId: id, enabled: {$ne: fields.equipped} }, @@ -48,14 +49,10 @@ Items.find({}, {fields: {equipped: 1}}).observeChanges({ {fields: {enabled: 1} }).forEach(function(effect){ 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); - }); } }); +//if an effect's type, source or enabled state change, keep the enabled state up to date with the item's equipped state Effects.find({type: "equipment"}, {fields: {type: 1, enabled: 1, sourceId: 1}}).observe({ added: function(newEffect){ var item = Items.findOne(newEffect.sourceId, {fields: {equipped: 1}});