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:
jerellmendoodoo
2017-07-18 16:34:54 -04:00
committed by Sabe Jones
parent ab777f7006
commit a9195f0d96
9 changed files with 199 additions and 27 deletions

View File

@@ -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', {