From 94944f2cacf3ed09bc6783dce72169d5ec9de981 Mon Sep 17 00:00:00 2001 From: Tyler Renelle Date: Sat, 15 Feb 2014 14:27:40 -0700 Subject: [PATCH] fix(quests): temp workaround for #2853 `Cannot read property 'collect' of undefined` --- src/models/group.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/models/group.js b/src/models/group.js index 0ecc16221e..5d80c0baf4 100644 --- a/src/models/group.js +++ b/src/models/group.js @@ -175,13 +175,13 @@ GroupSchema.methods.finishQuest = function(quest, cb) { } // FIXME this is a temporary measure, we need to remove quests from users when they traverse parties -function isOnQuest(user,group){ - return group && user.party.quest.key && user.party.quest.key == group.quest.key; +function isOnQuest(user,progress,group){ + return group && progress && user.party.quest.key && user.party.quest.key == group.quest.key; } GroupSchema.statics.collectQuest = function(user, progress, cb) { this.findOne({type: 'party', members: {'$in': [user._id]}},function(err, group){ - if (!isOnQuest(user,group)) return cb(null); + if (!isOnQuest(user,progress,group)) return cb(null); var quest = shared.content.quests[group.quest.key]; _.each(progress.collect,function(v,k){ @@ -215,7 +215,7 @@ GroupSchema.statics.collectQuest = function(user, progress, cb) { GroupSchema.statics.bossQuest = function(user, progress, cb) { this.findOne({type: 'party', members: {'$in': [user._id]}},function(err, group){ - if (!isOnQuest(user,group)) return cb(null); + if (!isOnQuest(user,progress,group)) return cb(null); var quest = shared.content.quests[group.quest.key]; if (!progress || !quest) return cb(null); // FIXME why is this ever happening, progress should be defined at this point var down = progress.down * quest.boss.str; // multiply by boss strength