diff --git a/common/script/count.js b/common/script/count.js index cbb7fe3b47..14c41bee36 100644 --- a/common/script/count.js +++ b/common/script/count.js @@ -26,7 +26,21 @@ function mountMasterProgress(mounts) { return count; } +function remainingGearInSet(userGear, set) { + var gear = _.filter(content.gear.flat, function(item) { + var setMatches = item.klass === set; + var hasItem = _.has(userGear, item.key); + + return setMatches && !hasItem; + }); + + var count = _.size(gear); + + return count; +} + module.exports = { beastMasterProgress: beastMasterProgress, - mountMasterProgress: mountMasterProgress + mountMasterProgress: mountMasterProgress, + remainingGearInSet: remainingGearInSet }; diff --git a/test/common/count.js b/test/common/count.js index 44fc14e6ae..f0a25a771d 100644 --- a/test/common/count.js +++ b/test/common/count.js @@ -84,4 +84,32 @@ describe('count', function() { expect(mountMasterTotal).to.eql(1); }); }); + + describe('remainingGearInSet', function() { + it('counts remaining gear based on set', function() { + var gear = { + 'weapon_wizard_0':true, + 'weapon_wizard_1':true, + 'weapon_warrior_0':true, + 'weapon_warrior_1':true, + 'weapon_armor_0':true, + 'weapon_armor_1':true + }; + + var armoireCount = count.remainingGearInSet(gear, 'warrior'); + expect(armoireCount).to.eql(20); + }); + + it('includes previously owned items in count', function() { + var gear = { + 'weapon_warrior_0':false, + 'weapon_warrior_1':false, + 'weapon_armor_0':true, + 'weapon_armor_1':true + }; + + var armoireCount = count.remainingGearInSet(gear, 'warrior'); + expect(armoireCount).to.eql(20); + }); + }); });