From 3643d11d97d8f610776fbb0c1196d6a537c48ca9 Mon Sep 17 00:00:00 2001 From: Blade Barringer Date: Sun, 19 Jul 2015 20:56:14 -0500 Subject: [PATCH] Refactor pet and mount count into one method --- test/spec/services/statServicesSpec.js | 14 ++++++-------- website/public/js/services/statServices.js | 18 ++++++++---------- .../shared/profiles/stats/pets-and-mounts.jade | 4 ++-- 3 files changed, 16 insertions(+), 20 deletions(-) diff --git a/test/spec/services/statServicesSpec.js b/test/spec/services/statServicesSpec.js index 3e442c4f94..2dd65a3ccd 100644 --- a/test/spec/services/statServicesSpec.js +++ b/test/spec/services/statServicesSpec.js @@ -180,7 +180,7 @@ describe('Stats Service', function() { }); }); - describe('totalPetCount', function() { + describe('totalCount', function() { it('counts all pets that user has', function() { user.items.pets = { "BearCub-Base" : 5, @@ -192,7 +192,7 @@ describe('Stats Service', function() { "MantisShrimp-Base" : 5 } - var petsFound = statCalc.totalPetCount(user.items.pets); + var petsFound = statCalc.totalCount(user.items.pets); expect(petsFound).to.eql(7); }); @@ -208,7 +208,7 @@ describe('Stats Service', function() { "MantisShrimp-Base" : 5 } - var petsFound = statCalc.totalPetCount(user.items.pets); + var petsFound = statCalc.totalCount(user.items.pets); expect(petsFound).to.eql(7); }); @@ -224,13 +224,11 @@ describe('Stats Service', function() { "MantisShrimp-Base" : 5 } - var petsFound = statCalc.totalPetCount(user.items.pets); + var petsFound = statCalc.totalCount(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, @@ -242,7 +240,7 @@ describe('Stats Service', function() { "Bunny-Skeleton" : true } - var mountsFound = statCalc.totalMountCount(user.items.mounts); + var mountsFound = statCalc.totalCount(user.items.mounts); expect(mountsFound).to.eql(7); }); @@ -258,7 +256,7 @@ describe('Stats Service', function() { "Bunny-Skeleton" : false } - var mountsFound = statCalc.totalMountCount(user.items.mounts); + var mountsFound = statCalc.totalCount(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 7ee6df2428..55affe670a 100644 --- a/website/public/js/services/statServices.js +++ b/website/public/js/services/statServices.js @@ -12,6 +12,10 @@ function statsFactory(Content, Shared) { + function beastMasterProgress(pets) { + + } + function classBonus(user, stat) { var computedStats = user._statsComputed; @@ -85,14 +89,8 @@ return display; } - function totalPetCount(pets) { - var total = _.size(pets); - - return total; - } - - function totalMountCount(mounts) { - var total = _.size(mounts); + function totalCount(objectToCount) { + var total = _.size(objectToCount); return total; } @@ -103,6 +101,7 @@ } return { + beastMasterProgress: beastMasterProgress, classBonus: classBonus, equipmentStatBonus: equipmentStatBonus, expDisplay: expDisplay, @@ -110,8 +109,7 @@ hpDisplay: hpDisplay, levelBonus: levelBonus, mpDisplay: mpDisplay, - totalPetCount: totalPetCount, - totalMountCount: totalMountCount + totalCount: totalCount } } }()); diff --git a/website/views/shared/profiles/stats/pets-and-mounts.jade b/website/views/shared/profiles/stats/pets-and-mounts.jade index 0b693e847b..3bb2c10b1d 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','{{::statCalc.totalPetCount(profile.items.pets)}}') + +basicRow('petsFound','{{::statCalc.totalCount(profile.items.pets)}}') +basicRow('beastMasterProgress','{{profile.petCount}}/90') h4(class=mobile?'item item-divider':'')=env.t('mounts') table.table.table-striped - +basicRow('mountsTamed','{{::statCalc.totalPetCount(profile.items.mounts)}}') + +basicRow('mountsTamed','{{::statCalc.totalCount(profile.items.mounts)}}') +basicRow('mountMasterProgress','{{profile.mountCount}}/90')