diff --git a/test/spec/services/statServicesSpec.js b/test/spec/services/statServicesSpec.js index 3555fa4406..3e442c4f94 100644 --- a/test/spec/services/statServicesSpec.js +++ b/test/spec/services/statServicesSpec.js @@ -179,4 +179,88 @@ describe('Stats Service', function() { expect(mpDisplay).to.eql('30/100'); }); }); + + describe('totalPetCount', function() { + it('counts all pets that user has', function() { + user.items.pets = { + "BearCub-Base" : 5, + "BearCub-CottonCandyBlue" : 5, + "Cactus-Zombie" : 5, + "Deer-Golden" : 5, + "Deer-Red" : 5, + "Egg-Desert" : 5, + "MantisShrimp-Base" : 5 + } + + var petsFound = statCalc.totalPetCount(user.items.pets); + + expect(petsFound).to.eql(7); + }); + + it('includes pets that have a value of 0', function() { + user.items.pets = { + "BearCub-Base" : 0, + "BearCub-CottonCandyBlue" : 5, + "Cactus-Zombie" : 0, + "Deer-Golden" : 0, + "Deer-Red" : 0, + "Egg-Desert" : 0, + "MantisShrimp-Base" : 5 + } + + var petsFound = statCalc.totalPetCount(user.items.pets); + + expect(petsFound).to.eql(7); + }); + + it('includes pets that have a value of -1', function() { + user.items.pets = { + "BearCub-Base" : -1, + "BearCub-CottonCandyBlue" : 5, + "Cactus-Zombie" : -1, + "Deer-Golden" : -1, + "Deer-Red" : -1, + "Egg-Desert" : -1, + "MantisShrimp-Base" : 5 + } + + var petsFound = statCalc.totalPetCount(user.items.pets); + + expect(petsFound).to.eql(7); + }); + }); + + describe('totalMountCount', function() { + it('counts all mounts that user has', function() { + user.items.mounts = { + "Hedgehog-Desert" : true, + "Octopus-CottonCandyPink" : true, + "TigerCub-White" : true, + "Wolf-Golden" : true, + "Owl-CottonCandyBlue" : true, + "Mammoth-Base" : true, + "Bunny-Skeleton" : true + } + + var mountsFound = statCalc.totalMountCount(user.items.mounts); + + expect(mountsFound).to.eql(7); + }); + + it('inlcudes mounts with a value of false', function() { + user.items.mounts = { + "Hedgehog-Desert" : false, + "Octopus-CottonCandyPink" : true, + "TigerCub-White" : false, + "Wolf-Golden" : false, + "Owl-CottonCandyBlue" : false, + "Mammoth-Base" : true, + "Bunny-Skeleton" : false + } + + var mountsFound = statCalc.totalMountCount(user.items.mounts); + + expect(mountsFound).to.eql(7); + }); + }); }); diff --git a/website/public/js/services/statServices.js b/website/public/js/services/statServices.js index 53ba032de5..7ee6df2428 100644 --- a/website/public/js/services/statServices.js +++ b/website/public/js/services/statServices.js @@ -85,6 +85,18 @@ return display; } + function totalPetCount(pets) { + var total = _.size(pets); + + return total; + } + + function totalMountCount(mounts) { + var total = _.size(mounts); + + return total; + } + function _formatOutOfTotalDisplay(stat, totalStat) { var display = stat + "/" + totalStat; return display; @@ -97,7 +109,9 @@ goldDisplay: goldDisplay, hpDisplay: hpDisplay, levelBonus: levelBonus, - mpDisplay: mpDisplay + mpDisplay: mpDisplay, + totalPetCount: totalPetCount, + totalMountCount: totalMountCount } } }()); diff --git a/website/views/shared/profiles/stats/pets-and-mounts.jade b/website/views/shared/profiles/stats/pets-and-mounts.jade index f3bb0bef25..0b693e847b 100644 --- a/website/views/shared/profiles/stats/pets-and-mounts.jade +++ b/website/views/shared/profiles/stats/pets-and-mounts.jade @@ -2,11 +2,11 @@ div(ng-if='user.flags.dropsEnabled') h4(class=mobile?'item item-divider':'')=env.t('pets') table.table.table-striped - +basicRow('petsFound','{{_.size(profile.items.pets)}}') + +basicRow('petsFound','{{::statCalc.totalPetCount(profile.items.pets)}}') +basicRow('beastMasterProgress','{{profile.petCount}}/90') h4(class=mobile?'item item-divider':'')=env.t('mounts') table.table.table-striped - +basicRow('mountsTamed','{{_.size(profile.items.mounts)}}') + +basicRow('mountsTamed','{{::statCalc.totalPetCount(profile.items.mounts)}}') +basicRow('mountMasterProgress','{{profile.mountCount}}/90')