diff --git a/common/script/count.js b/common/script/count.js index 14c41bee36..b0ae608675 100644 --- a/common/script/count.js +++ b/common/script/count.js @@ -16,6 +16,18 @@ function beastMasterProgress(pets) { return count; } +function dropPetsCurrentlyOwned(pets) { + var count = 0; + + _(DROP_ANIMALS).each(function(animal) { + if(pets[animal] > 0) + count++ + }); + + return count; +} + + function mountMasterProgress(mounts) { var count = 0; _(DROP_ANIMALS).each(function(animal) { @@ -41,6 +53,7 @@ function remainingGearInSet(userGear, set) { module.exports = { beastMasterProgress: beastMasterProgress, + dropPetsCurrentlyOwned: dropPetsCurrentlyOwned, mountMasterProgress: mountMasterProgress, remainingGearInSet: remainingGearInSet }; diff --git a/test/common/count.js b/test/common/count.js index f0a25a771d..d02c3b665c 100644 --- a/test/common/count.js +++ b/test/common/count.js @@ -112,4 +112,46 @@ describe('count', function() { expect(armoireCount).to.eql(20); }); }); + + describe('dropPetsCurrentlyOwned', function() { + it('counts drop pets owned', function() { + var pets = { + "Wolf-Base": 2, + "Wolf-Red": 4 + }; + var dropPets = count.dropPetsCurrentlyOwned(pets); + expect(dropPets).to.eql(2); + }); + + it('does not count pets that have been raised to mounts', function() { + var pets = { + "Wolf-Base": -1, + "Wolf-Red": 4, + "Wolf-Veteran": 1, + "Gryphon-Base": 1 + }; + var dropPets = count.dropPetsCurrentlyOwned(pets); + expect(dropPets).to.eql(1); + }); + + it('does not count quest pets', function() { + var pets = { + "Wolf-Base": 2, + "Wolf-Red": 4, + "Gryphon-Base": 1 + }; + var dropPets = count.dropPetsCurrentlyOwned(pets); + expect(dropPets).to.eql(2); + }); + + it('does not count special pets', function() { + var pets = { + "Wolf-Base": 2, + "Wolf-Red": 4, + "Wolf-Veteran": 1 + }; + var dropPets = count.dropPetsCurrentlyOwned(pets); + expect(dropPets).to.eql(2); + }); + }); });