mirror of
https://github.com/sudoxnym/habitica-self-host.git
synced 2026-07-13 17:52:22 +00:00
Refactor pet and mount count into one method
This commit is contained in:
parent
aee37b2a0e
commit
3643d11d97
3 changed files with 16 additions and 20 deletions
|
|
@ -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);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
}
|
||||
}());
|
||||
|
|
|
|||
|
|
@ -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')
|
||||
|
|
|
|||
Loading…
Reference in a new issue