Use better beastMaster / mountMaster counts

This commit is contained in:
Blade Barringer 2015-07-19 21:48:38 -05:00
parent 3643d11d97
commit 2695419182
4 changed files with 117 additions and 2 deletions

View file

@ -386,6 +386,24 @@ api.countPets = (originalCount, pets) ->
count-- if pets[pet]
count
DROP_ANIMALS = _.keys(content.pets)
api.countBeastMasterProgress = (pets) ->
count = 0
for animal in DROP_ANIMALS
if pets[animal] > 0 || pets[animal] == -1
count++
count
api.countMountMasterProgress = (mounts) ->
count = 0
for animal in DROP_ANIMALS
if mounts[animal]
count++
count
api.countMounts = (originalCount, mounts) ->
count2 = if originalCount? then originalCount else _.size(mounts)
for mount of content.questPets

View file

@ -15,6 +15,56 @@ describe('Stats Service', function() {
});
});
describe('beastMasterProgress', function() {
it('counts drop 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 beastMasterDisplay = statCalc.beastMasterProgress(user.items.pets);
expect(beastMasterDisplay).to.eql('3/90');
});
it('counts drop pets with a value of -1', function() {
user.items.pets = {
"BearCub-Base" : -1,
"BearCub-CottonCandyBlue" : -1,
"Cactus-Zombie" : 5,
"Deer-Golden" : 5,
"Deer-Red" : 5,
"Egg-Desert" : 5,
"MantisShrimp-Base" : 5
}
var beastMasterDisplay = statCalc.beastMasterProgress(user.items.pets);
expect(beastMasterDisplay).to.eql('3/90');
});
it('does not count drop pets with a value of 0', function() {
user.items.pets = {
"BearCub-Base" : 0,
"BearCub-CottonCandyBlue" : 0,
"Cactus-Zombie" : 5,
"Deer-Golden" : 5,
"Deer-Red" : 5,
"Egg-Desert" : 5,
"MantisShrimp-Base" : 5
}
var beastMasterDisplay = statCalc.beastMasterProgress(user.items.pets);
expect(beastMasterDisplay).to.eql('1/90');
});
});
describe('classBonus', function() {
it('calculates class bonus', function() {
var equippedGear = {
@ -162,6 +212,40 @@ describe('Stats Service', function() {
});
});
describe('mountMasterProgress', function() {
it('counts drop 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 mountMasterDisplay = statCalc.mountMasterProgress(user.items.mounts);
expect(mountMasterDisplay).to.eql('2/90');
});
it('does not count drop mounts with a value of false', function() {
user.items.mounts = {
"Hedgehog-Desert" : true,
"Octopus-CottonCandyPink" : true,
"TigerCub-White" : false,
"Wolf-Golden" : false,
"Owl-CottonCandyBlue" : true,
"Mammoth-Base" : true,
"Bunny-Skeleton" : true
}
var mountMasterDisplay = statCalc.mountMasterProgress(user.items.mounts);
expect(mountMasterDisplay).to.eql('0/90');
});
});
describe('mpDisplay', function() {
it('displays mp as "mp / totalMP"', function() {
user._statsComputed = { maxMP: 100 };

View file

@ -11,9 +11,14 @@
];
function statsFactory(Content, Shared) {
var DROP_ANIMALS = _.keys(Content.pets);
var TOTAL_NUMBER_OF_DROP_ANIMALS = DROP_ANIMALS.length;
function beastMasterProgress(pets) {
var dropPetsFound = Shared.countBeastMasterProgress(pets);
var display = _formatOutOfTotalDisplay(dropPetsFound, TOTAL_NUMBER_OF_DROP_ANIMALS);
return display;
}
function classBonus(user, stat) {
@ -81,6 +86,13 @@
return bonus;
}
function mountMasterProgress(mounts) {
var dropMountsFound = Shared.countMountMasterProgress(mounts);
var display = _formatOutOfTotalDisplay(dropMountsFound, TOTAL_NUMBER_OF_DROP_ANIMALS);
return display;
}
function mpDisplay(user) {
var remainingMP = Math.floor(user.stats.mp);
var totalMP = user._statsComputed.maxMP;
@ -108,6 +120,7 @@
goldDisplay: goldDisplay,
hpDisplay: hpDisplay,
levelBonus: levelBonus,
mountMasterProgress: mountMasterProgress,
mpDisplay: mpDisplay,
totalCount: totalCount
}

View file

@ -3,10 +3,10 @@ div(ng-if='user.flags.dropsEnabled')
table.table.table-striped
+basicRow('petsFound','{{::statCalc.totalCount(profile.items.pets)}}')
+basicRow('beastMasterProgress','{{profile.petCount}}/90')
+basicRow('beastMasterProgress','{{::statCalc.beastMasterProgress(profile.items.pets)}}')
h4(class=mobile?'item item-divider':'')=env.t('mounts')
table.table.table-striped
+basicRow('mountsTamed','{{::statCalc.totalCount(profile.items.mounts)}}')
+basicRow('mountMasterProgress','{{profile.mountCount}}/90')
+basicRow('mountMasterProgress','{{::statCalc.mountMasterProgress(profile.items.mounts)}}')