mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-15 05:37:22 +01:00
Fixed release pets mounts (#8545)
* Fixed release pets/mounts achievements when fully earned and added unit tests for these changes * Fixed release pets/mounts achievements to award only when fully earned and added unit tests for these changes, also fixed linting issues * Updated variable assignments to make more readable * Revised releaseBoth/Pets/Mounts to include null or undefined checks, also updated unit tests * fixed integration tests
This commit is contained in:
committed by
Sabe Jones
parent
ab777f7006
commit
a9195f0d96
@@ -11,6 +11,8 @@ module.exports = function releasePets (user, req = {}, analytics) {
|
||||
|
||||
user.balance -= 1;
|
||||
|
||||
let giveBeastMasterAchievement = true;
|
||||
|
||||
let petInfo = content.petInfo[user.items.currentPet];
|
||||
|
||||
if (petInfo && petInfo.type === 'drop') {
|
||||
@@ -18,13 +20,18 @@ module.exports = function releasePets (user, req = {}, analytics) {
|
||||
}
|
||||
|
||||
for (let pet in content.pets) {
|
||||
if (!user.items.pets[pet]) {
|
||||
giveBeastMasterAchievement = false;
|
||||
}
|
||||
user.items.pets[pet] = 0;
|
||||
}
|
||||
|
||||
if (!user.achievements.beastMasterCount) {
|
||||
user.achievements.beastMasterCount = 0;
|
||||
if (giveBeastMasterAchievement) {
|
||||
if (!user.achievements.beastMasterCount) {
|
||||
user.achievements.beastMasterCount = 0;
|
||||
}
|
||||
user.achievements.beastMasterCount++;
|
||||
}
|
||||
user.achievements.beastMasterCount++;
|
||||
|
||||
if (analytics) {
|
||||
analytics.track('release pets', {
|
||||
|
||||
Reference in New Issue
Block a user