Updated logic to not assign armoire incorrectly (#7476)
* Updated logic to not assign armoire incorrectly * Updated test and added new test to ensure armorie is not enabled prematurely. * Fixed linting issue * Removed toObject from being called when called on the server
This commit is contained in:
committed by
Matteo Pagliazzi
parent
f713bf53c1
commit
7297a6fa76
@@ -15,7 +15,16 @@ module.exports = function ultimateGear (user) {
|
||||
}
|
||||
});
|
||||
|
||||
if (_.contains(user.achievements.ultimateGearSets, true) && user.flags.armoireEnabled !== true) {
|
||||
let ultimateGearSetValues;
|
||||
if (user.achievements.ultimateGearSets.toObject) {
|
||||
ultimateGearSetValues = Object.values(user.achievements.ultimateGearSets.toObject());
|
||||
} else {
|
||||
ultimateGearSetValues = Object.values(user.achievements.ultimateGearSets);
|
||||
}
|
||||
|
||||
let hasFullSet = _.includes(ultimateGearSetValues, true);
|
||||
|
||||
if (hasFullSet && user.flags.armoireEnabled !== true) {
|
||||
user.flags.armoireEnabled = true;
|
||||
}
|
||||
|
||||
|
||||
@@ -8,6 +8,9 @@ describe('shared.fns.ultimateGear', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
user = generateUser();
|
||||
user.achievements.ultimateGearSets.toObject = function () {
|
||||
return this;
|
||||
};
|
||||
});
|
||||
|
||||
it('sets armoirEnabled when partial achievement already achieved', () => {
|
||||
@@ -30,4 +33,25 @@ describe('shared.fns.ultimateGear', () => {
|
||||
ultimateGear(user);
|
||||
expect(user.flags.armoireEnabled).to.equal(true);
|
||||
});
|
||||
|
||||
it('does not set armoirEnabled when gear is not owned', () => {
|
||||
let items = {
|
||||
gear: {
|
||||
owned: {
|
||||
toObject: () => {
|
||||
return {
|
||||
armor_warrior_5: true, // eslint-disable-line camelcase
|
||||
shield_warrior_5: true, // eslint-disable-line camelcase
|
||||
head_warrior_5: true, // eslint-disable-line camelcase
|
||||
weapon_warrior_6: false, // eslint-disable-line camelcase
|
||||
};
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
user.items = items;
|
||||
ultimateGear(user);
|
||||
expect(user.flags.armoireEnabled).to.equal(false);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user