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 releaseMounts (user, req = {}, analytics) {
|
||||
|
||||
user.balance -= 1;
|
||||
|
||||
let giveMountMasterAchievement = true;
|
||||
|
||||
let mountInfo = content.mountInfo[user.items.currentMount];
|
||||
|
||||
if (mountInfo && mountInfo.type === 'drop') {
|
||||
@@ -18,13 +20,18 @@ module.exports = function releaseMounts (user, req = {}, analytics) {
|
||||
}
|
||||
|
||||
for (let mount in content.pets) {
|
||||
if (user.items.mounts[mount] === null || user.items.mounts[mount] === undefined) {
|
||||
giveMountMasterAchievement = false;
|
||||
}
|
||||
user.items.mounts[mount] = null;
|
||||
}
|
||||
|
||||
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 (analytics) {
|
||||
analytics.track('release mounts', {
|
||||
|
||||
Reference in New Issue
Block a user