mirror of
https://github.com/sudoxnym/habitica.git
synced 2026-04-14 19:56:23 +00:00
fix(quests): don't reset quest progress when world boss defeated
This commit is contained in:
parent
899581ee56
commit
496618c665
2 changed files with 14 additions and 2 deletions
11
migrations/20140712_wiped_quest_membership.js
Normal file
11
migrations/20140712_wiped_quest_membership.js
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
//mongo habitrpg node_modules/lodash/lodash.js ./migrations/20140712_wiped_quest_membership.js
|
||||
db.groups.find({type:'party','quest.key':{$ne:null},'quest.active':true},{quest:1}).forEach(function(group){
|
||||
var activeMembers = _.reduce(group.quest.members, function(m,v,k){
|
||||
if (v===true) m.push(k); return m;
|
||||
},[]);
|
||||
db.users.update(
|
||||
{_id:{$in: activeMembers}},
|
||||
{$set:{'party.quest.key':group.quest.key,'party.quest.completed':null}},
|
||||
{multi:true}
|
||||
);
|
||||
});
|
||||
|
|
@ -155,7 +155,8 @@ GroupSchema.methods.finishQuest = function(quest, cb) {
|
|||
updates['$inc']['stats.gp'] = +quest.drop.gp;
|
||||
updates['$inc']['stats.exp'] = +quest.drop.exp;
|
||||
updates['$inc']['_v'] = 1;
|
||||
updates['$set']['party.quest'] = cleanQuestProgress({completed:questK});
|
||||
if (group._id !== 'habitrpg')
|
||||
updates['$set']['party.quest'] = cleanQuestProgress({completed:questK});
|
||||
|
||||
_.each(quest.drop.items, function(item){
|
||||
var dropK = item.key;
|
||||
|
|
@ -237,7 +238,7 @@ GroupSchema.statics.tavernBoss = function(user,progress) {
|
|||
mongoose.model('Group').findOne(tavernQ,cb);
|
||||
},
|
||||
function(tavern,cb){
|
||||
if (!tavern.quest || !tavern.quest.key) return cb(true);
|
||||
if (!(tavern && tavern.quest && tavern.quest.key)) return cb(true);
|
||||
module.exports.tavern = tavern;
|
||||
|
||||
var quest = shared.content.quests[tavern.quest.key];
|
||||
|
|
|
|||
Loading…
Reference in a new issue