mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-16 06:07:21 +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
@@ -14,6 +14,8 @@ module.exports = function releaseBoth (user, req = {}, analytics) {
|
||||
}
|
||||
|
||||
let giveTriadBingo = true;
|
||||
let giveBeastMasterAchievement = true;
|
||||
let giveMountMasterAchievement = true;
|
||||
|
||||
if (!user.achievements.triadBingo) {
|
||||
if (analytics) {
|
||||
@@ -44,21 +46,30 @@ module.exports = function releaseBoth (user, req = {}, analytics) {
|
||||
for (animal in content.pets) {
|
||||
if (user.items.pets[animal] === -1) {
|
||||
giveTriadBingo = false;
|
||||
} else if (!user.items.pets[animal]) {
|
||||
giveBeastMasterAchievement = false;
|
||||
}
|
||||
if (user.items.mounts[animal] === null || user.items.mounts[animal] === undefined) {
|
||||
giveMountMasterAchievement = false;
|
||||
}
|
||||
|
||||
user.items.pets[animal] = 0;
|
||||
user.items.mounts[animal] = null;
|
||||
}
|
||||
|
||||
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 (!user.achievements.mountMasterCount) {
|
||||
user.achievements.mountMasterCount = 0;
|
||||
if (giveMountMasterAchievement) {
|
||||
if (!user.achievements.mountMasterCount) {
|
||||
user.achievements.mountMasterCount = 0;
|
||||
}
|
||||
user.achievements.mountMasterCount++;
|
||||
}
|
||||
user.achievements.mountMasterCount++;
|
||||
|
||||
if (giveTriadBingo) {
|
||||
if (!user.achievements.triadBingoCount) {
|
||||
|
||||
Reference in New Issue
Block a user