refactor(client): extract find pet logic into function

This commit is contained in:
Blade Barringer
2016-09-15 22:02:11 -05:00
parent 4ad50b9d30
commit 9c0998c29a

View File

@@ -378,18 +378,22 @@ habitrpg.controller("InventoryCtrl",
};
$scope.shouldShowPremiumMountSection = function () {
var pets = Object.keys(user.items.pets);
return pets.find(function (petKey) {
var pet = Content.petInfo[petKey];
return findPet(function (pet) {
return pet.type === 'premium';
});
};
$scope.hasAPetOfPotion = function (potion) {
return findPet(function (pet) {
return pet.potion === potion;
});
};
function findPet (fn) {
var pets = Object.keys(user.items.pets);
return pets.find(function (petKey) {
var pet = Content.petInfo[petKey];
return pet.potion === potion;
return fn(pet);
});
}