mirror of
https://github.com/sudoxnym/habitica-self-host.git
synced 2026-07-18 20:04:38 +00:00
Merge pull request #6024 from crookedneighbor/fix_world_dmg
Fix world dmg
This commit is contained in:
commit
c45736fc6f
2 changed files with 15 additions and 12 deletions
|
|
@ -6,14 +6,14 @@ var i18n = require('../i18n.js');
|
|||
var buildManifest = require('../libs/buildManifest');
|
||||
var shared = require('../../../common');
|
||||
var forceRefresh = require('./forceRefresh');
|
||||
var tavern = require('../models/group').tavern;
|
||||
var tavernQuest = require('../models/group').tavernQuest;
|
||||
var mods = require('../models/user').mods;
|
||||
|
||||
// To avoid stringifying more data then we need,
|
||||
// items from `env` used on the client will have to be specified in this array
|
||||
var clientVars = ['language', 'isStaticPage', 'avalaibleLanguages', 'translations',
|
||||
'FACEBOOK_KEY', 'NODE_ENV', 'BASE_URL', 'GA_ID',
|
||||
'AMAZON_PAYMENTS', 'STRIPE_PUB_KEY', 'AMPLITUDE_KEY',
|
||||
'AMAZON_PAYMENTS', 'STRIPE_PUB_KEY', 'AMPLITUDE_KEY',
|
||||
'worldDmg', 'mods', 'IS_MOBILE'];
|
||||
|
||||
var env = {
|
||||
|
|
@ -21,7 +21,6 @@ var env = {
|
|||
getBuildUrl: buildManifest.getBuildUrl,
|
||||
_: _,
|
||||
clientVars: clientVars,
|
||||
tavern: tavern, // for world boss
|
||||
mods: mods,
|
||||
Content: shared.content,
|
||||
siteVersion: forceRefresh.siteVersion,
|
||||
|
|
@ -53,9 +52,9 @@ module.exports = function(req, res, next) {
|
|||
args.push(language.code);
|
||||
return shared.i18n.t.apply(null, args);
|
||||
},
|
||||
// Defined here and not outside of the middleware because tavern might be an
|
||||
// Defined here and not outside of the middleware because tavernQuest might be an
|
||||
// empty object until the query to fetch it finishes
|
||||
worldDmg: (tavern && tavern.quest && tavern.quest.extra && tavern.quest.extra.worldDmg) || {},
|
||||
worldDmg: (tavernQuest && tavernQuest.extra && tavernQuest.extra.worldDmg) || {},
|
||||
});
|
||||
|
||||
// Put query-string party (& guild but use partyInvite for backward compatibility)
|
||||
|
|
@ -68,4 +67,4 @@ module.exports = function(req, res, next) {
|
|||
}
|
||||
|
||||
next();
|
||||
};
|
||||
};
|
||||
|
|
|
|||
|
|
@ -269,12 +269,15 @@ GroupSchema.statics.collectQuest = function(user, progress, cb) {
|
|||
}
|
||||
|
||||
// to set a boss: `db.groups.update({_id:'habitrpg'},{$set:{quest:{key:'dilatory',active:true,progress:{hp:1000,rage:1500}}}})`
|
||||
module.exports.tavern = {};
|
||||
module.exports.tavernQuest = {};
|
||||
var tavernQ = {_id:'habitrpg','quest.key':{$ne:null}};
|
||||
process.nextTick(function(){
|
||||
mongoose.model('Group').findOne(tavernQ,function(err,tavern){
|
||||
// Using _assign so we don't lose the reference to the exported tavern
|
||||
_.assign(module.exports.tavern, tavern);
|
||||
mongoose.model('Group').findOne(tavernQ, function(err,tavern){
|
||||
if (!tavern) return; // No tavern quest
|
||||
|
||||
var quest = tavern.quest.toObject();
|
||||
// Using _assign so we don't lose the reference to the exported tavernQuest
|
||||
_.assign(module.exports.tavernQuest, quest);
|
||||
});
|
||||
});
|
||||
|
||||
|
|
@ -291,14 +294,13 @@ GroupSchema.statics.tavernBoss = function(user,progress) {
|
|||
},
|
||||
function(tavern,cb){
|
||||
if (!(tavern && tavern.quest && tavern.quest.key)) return cb(true);
|
||||
module.exports.tavern = tavern;
|
||||
|
||||
var quest = shared.content.quests[tavern.quest.key];
|
||||
if (tavern.quest.progress.hp <= 0) {
|
||||
tavern.sendChat(quest.completionChat('en'));
|
||||
tavern.finishQuest(quest, function(){});
|
||||
tavern.save(cb);
|
||||
module.exports.tavern = undefined;
|
||||
_.assign(module.exports.tavernQuest, {extra: null});
|
||||
} else {
|
||||
// Deal damage. Note a couple things here, str & def are calculated. If str/def are defined in the database,
|
||||
// use those first - which allows us to update the boss on the go if things are too easy/hard.
|
||||
|
|
@ -330,6 +332,8 @@ GroupSchema.statics.tavernBoss = function(user,progress) {
|
|||
tavern.quest.extra.str = quest.boss.desperation.str;
|
||||
tavern.markModified('quest.extra');
|
||||
}
|
||||
|
||||
_.assign(module.exports.tavernQuest, tavern.quest.toObject());
|
||||
tavern.save(cb);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue