mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-14 21:27:23 +01:00
Fix: pet tests
This commit is contained in:
@@ -17,6 +17,7 @@ function evolve (user, pet, req) {
|
|||||||
...user.items.pets,
|
...user.items.pets,
|
||||||
[pet.key]: -1,
|
[pet.key]: -1,
|
||||||
};
|
};
|
||||||
|
|
||||||
user.items.mounts = {
|
user.items.mounts = {
|
||||||
...user.items.mounts,
|
...user.items.mounts,
|
||||||
[pet.key]: true,
|
[pet.key]: true,
|
||||||
@@ -52,9 +53,8 @@ export default function feed (user, req = {}) {
|
|||||||
throw new NotFound(errorMessage('invalidFoodName', req.language));
|
throw new NotFound(errorMessage('invalidFoodName', req.language));
|
||||||
}
|
}
|
||||||
|
|
||||||
const userPets = user.items.pets;
|
|
||||||
|
|
||||||
if (!userPets[pet.key]) {
|
if (!user.items.pets[pet.key]) {
|
||||||
throw new NotFound(i18n.t('messagePetNotFound', req.language));
|
throw new NotFound(i18n.t('messagePetNotFound', req.language));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -81,16 +81,16 @@ export default function feed (user, req = {}) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
if (food.target === pet.potion || pet.type === 'premium') {
|
if (food.target === pet.potion || pet.type === 'premium') {
|
||||||
userPets[pet.key] += 5;
|
user.items.pets[pet.key] += 5;
|
||||||
message = i18n.t('messageLikesFood', messageParams, req.language);
|
message = i18n.t('messageLikesFood', messageParams, req.language);
|
||||||
} else {
|
} else {
|
||||||
userPets[pet.key] += 2;
|
user.items.pets[pet.key] += 2;
|
||||||
message = i18n.t('messageDontEnjoyFood', messageParams, req.language);
|
message = i18n.t('messageDontEnjoyFood', messageParams, req.language);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (user.markModified) user.markModified('items.pets');
|
if (user.markModified) user.markModified('items.pets');
|
||||||
|
|
||||||
if (userPets[pet.key] >= 50 && !user.items.mounts[pet.key]) {
|
if (user.items.pets[pet.key] >= 50 && !user.items.mounts[pet.key]) {
|
||||||
message = evolve(user, pet, req);
|
message = evolve(user, pet, req);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -116,7 +116,7 @@ export default function feed (user, req = {}) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
return [
|
return [
|
||||||
userPets[pet.key],
|
user.items.pets[pet.key],
|
||||||
message,
|
message,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ export default function hatch (user, req = {}) {
|
|||||||
};
|
};
|
||||||
user.items.eggs = {
|
user.items.eggs = {
|
||||||
...user.items.eggs,
|
...user.items.eggs,
|
||||||
[egg]: user.items.eggs - 1,
|
[egg]: Number.isInteger(user.items.eggs) ? user.items.eggs - 1 : 0,
|
||||||
};
|
};
|
||||||
user.items.hatchingPotions[hatchingPotion] -= 1;
|
user.items.hatchingPotions[hatchingPotion] -= 1;
|
||||||
if (user.markModified) {
|
if (user.markModified) {
|
||||||
|
|||||||
Reference in New Issue
Block a user