mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-14 21:27:23 +01:00
WIP: Improve User model performances (#10832)
* wip: define items as mixed objects * add default owned gear * mark modified * more mark modified * more mark modified * more mark modified * more mark modified * fix common tests * fix common tests * update mongoose * add itemsUtils * use new util function in hall controller * add tests for items utils * update website/server to mark all items as modified * start updating common code * update login incentives * update unlock * remove changes to package-lock.json * remove changes to package.json
This commit is contained in:
@@ -12,6 +12,11 @@ function evolve (user, pet, req) {
|
||||
user.items.pets[pet.key] = -1;
|
||||
user.items.mounts[pet.key] = true;
|
||||
|
||||
if (user.markModified) {
|
||||
user.markModified('items.pets');
|
||||
user.markModified('items.mounts');
|
||||
}
|
||||
|
||||
if (pet.key === user.items.currentPet) {
|
||||
user.items.currentPet = '';
|
||||
}
|
||||
@@ -74,12 +79,15 @@ module.exports = function feed (user, req = {}) {
|
||||
message = i18n.t('messageDontEnjoyFood', messageParams, req.language);
|
||||
}
|
||||
|
||||
if (user.markModified) user.markModified('items.pets');
|
||||
|
||||
if (userPets[pet.key] >= 50 && !user.items.mounts[pet.key]) {
|
||||
message = evolve(user, pet, req);
|
||||
}
|
||||
}
|
||||
|
||||
user.items.food[food.key]--;
|
||||
if (user.markModified) user.markModified('items.food');
|
||||
|
||||
return [
|
||||
userPets[pet.key],
|
||||
|
||||
Reference in New Issue
Block a user