mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-16 06:07:21 +01:00
Merged in develop
This commit is contained in:
@@ -931,22 +931,6 @@ schema.methods.finishQuest = async function finishQuest (quest) {
|
||||
'lostMasterclasser4',
|
||||
];
|
||||
|
||||
if (masterClasserQuests.includes(questK)) {
|
||||
let lostMasterclasserQuery = {
|
||||
'achievements.lostMasterclasser': {$ne: true},
|
||||
};
|
||||
masterClasserQuests.forEach(questName => {
|
||||
lostMasterclasserQuery[`achievements.quests.${questName}`] = {$gt: 0};
|
||||
});
|
||||
let lostMasterclasserUpdate = {
|
||||
$set: {'achievements.lostMasterclasser': true},
|
||||
};
|
||||
|
||||
promises = promises.concat(participants.map(userId => {
|
||||
return _updateUserWithRetries(userId, lostMasterclasserUpdate, null, lostMasterclasserQuery);
|
||||
}));
|
||||
}
|
||||
|
||||
// Send webhooks in background
|
||||
// @TODO move the find users part to a worker as well, not just the http request
|
||||
User.find({
|
||||
@@ -972,7 +956,24 @@ schema.methods.finishQuest = async function finishQuest (quest) {
|
||||
});
|
||||
});
|
||||
|
||||
return await Promise.all(promises);
|
||||
await Promise.all(promises);
|
||||
|
||||
if (masterClasserQuests.includes(questK)) {
|
||||
let lostMasterclasserQuery = {
|
||||
'achievements.lostMasterclasser': {$ne: true},
|
||||
};
|
||||
masterClasserQuests.forEach(questName => {
|
||||
lostMasterclasserQuery[`achievements.quests.${questName}`] = {$gt: 0};
|
||||
});
|
||||
let lostMasterclasserUpdate = {
|
||||
$set: {'achievements.lostMasterclasser': true},
|
||||
};
|
||||
|
||||
let lostMasterClasserPromises = participants.map(userId => {
|
||||
return _updateUserWithRetries(userId, lostMasterclasserUpdate, null, lostMasterclasserQuery);
|
||||
});
|
||||
await Promise.all(lostMasterClasserPromises);
|
||||
}
|
||||
};
|
||||
|
||||
function _isOnQuest (user, progress, group) {
|
||||
@@ -1108,6 +1109,8 @@ schema.methods._processCollectionQuest = async function processCollectionQuest (
|
||||
};
|
||||
|
||||
schema.statics.processQuestProgress = async function processQuestProgress (user, progress) {
|
||||
if (user.preferences.sleep) return;
|
||||
|
||||
let group = await this.getGroup({user, groupId: 'party'});
|
||||
|
||||
if (!_isOnQuest(user, progress, group)) return;
|
||||
@@ -1118,7 +1121,7 @@ schema.statics.processQuestProgress = async function processQuestProgress (user,
|
||||
|
||||
let questType = quest.boss ? 'Boss' : 'Collection';
|
||||
|
||||
await group[`_process${questType}Quest`]({
|
||||
await group[`_process${questType}Quest`]({ // _processBossQuest, _processCollectionQuest
|
||||
user,
|
||||
progress,
|
||||
group,
|
||||
@@ -1148,6 +1151,7 @@ process.nextTick(() => {
|
||||
// returns a promise
|
||||
schema.statics.tavernBoss = async function tavernBoss (user, progress) {
|
||||
if (!progress) return;
|
||||
if (user.preferences.sleep) return;
|
||||
|
||||
// hack: prevent crazy damage to world boss
|
||||
let dmg = Math.min(900, Math.abs(progress.up || 0));
|
||||
|
||||
Reference in New Issue
Block a user