feat(quests): allow quests to drop multiple items
This commit is contained in:
+20
-19
@@ -129,9 +129,7 @@ GroupSchema.statics.cleanQuestProgress = cleanQuestProgress;
|
||||
// Participants: Grant rewards & achievements, finish quest
|
||||
GroupSchema.methods.finishQuest = function(quest, cb) {
|
||||
var group = this;
|
||||
|
||||
var questK = quest.key;
|
||||
var dropK = quest.drop.key;
|
||||
var updates = {$inc:{},$set:{}};
|
||||
|
||||
updates['$inc']['achievements.quests.' + questK] = 1;
|
||||
@@ -140,23 +138,26 @@ GroupSchema.methods.finishQuest = function(quest, cb) {
|
||||
updates['$inc']['_v'] = 1;
|
||||
updates['$set']['party.quest'] = cleanQuestProgress({completed:questK});
|
||||
|
||||
switch (quest.drop.type) {
|
||||
case 'gear':
|
||||
// TODO This means they can lose their new gear on death, is that what we want?
|
||||
updates['$set']['items.gear.owned.'+dropK] = true;
|
||||
break;
|
||||
case 'eggs':
|
||||
case 'food':
|
||||
case 'hatchingPotions':
|
||||
updates['$inc']['items.'+quest.drop.type+'.'+dropK] = 1;
|
||||
break;
|
||||
case 'pets':
|
||||
updates['$set']['items.pets.'+dropK] = 5;
|
||||
break;
|
||||
case 'mounts':
|
||||
updates['$set']['items.mounts.'+dropK] = true;
|
||||
break;
|
||||
}
|
||||
_.each(quest.drop.items, function(item){
|
||||
var dropK = item.key;
|
||||
switch (item.type) {
|
||||
case 'gear':
|
||||
// TODO This means they can lose their new gear on death, is that what we want?
|
||||
updates['$set']['items.gear.owned.'+dropK] = true;
|
||||
break;
|
||||
case 'eggs':
|
||||
case 'food':
|
||||
case 'hatchingPotions':
|
||||
updates['$inc']['items.'+quest.drop.type+'.'+dropK] = 1;
|
||||
break;
|
||||
case 'pets':
|
||||
updates['$set']['items.pets.'+dropK] = 5;
|
||||
break;
|
||||
case 'mounts':
|
||||
updates['$set']['items.mounts.'+dropK] = true;
|
||||
break;
|
||||
}
|
||||
})
|
||||
var members = _.keys(group.quest.members);
|
||||
group.quest = {};group.markModified('quest');
|
||||
// FIXME this is TERRIBLE practice. Looks like there are circular dependencies in the models, such that `var User` at
|
||||
|
||||
@@ -436,6 +436,8 @@ describe('API', function () {
|
||||
function(_group,cb){
|
||||
expect(_group.quest.key).to.not.be.ok();
|
||||
expect(user.items.mounts['BearCub-Polar']).to.be(true);
|
||||
expect(user.stats.exp).to.be.above(shared.content.quests.evilsanta.drop.exp);
|
||||
expect(user.stats.gp).to.be.above(shared.content.quests.evilsanta.drop.gp);
|
||||
cb();
|
||||
}
|
||||
],done);
|
||||
|
||||
Reference in New Issue
Block a user