mirror of
https://github.com/sudoxnym/habitica-self-host.git
synced 2026-07-14 02:02:19 +00:00
Swap out pet and mount count with stat calc functions
This commit is contained in:
parent
89bfc83b95
commit
aee37b2a0e
3 changed files with 101 additions and 3 deletions
|
|
@ -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);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
}
|
||||
}());
|
||||
|
|
|
|||
|
|
@ -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')
|
||||
|
|
|
|||
Loading…
Reference in a new issue