mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-17 14:47:53 +01:00
Merge branch 'develop' into party-chat-translations
This commit is contained in:
@@ -1015,22 +1015,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({
|
||||
@@ -1056,7 +1040,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) {
|
||||
@@ -1235,6 +1236,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;
|
||||
@@ -1245,7 +1248,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,
|
||||
@@ -1275,6 +1278,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