mirror of
https://github.com/sudoxnym/habitica.git
synced 2026-07-08 21:38:43 +00:00
fix(quests): temp workaround for #2853 `Cannot read property 'collect'
of undefined`
This commit is contained in:
parent
8b2ea61461
commit
94944f2cac
1 changed files with 4 additions and 4 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in a new issue