Added function to count pets that are actually owned

This commit is contained in:
Blade Barringer 2015-07-21 20:14:15 -05:00
parent 20660f50c0
commit 063e53b0ea
2 changed files with 55 additions and 0 deletions

View file

@ -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
};

View file

@ -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);
});
});
});