mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-16 22:27:26 +01:00
refactor(client): extract find pet logic into function
This commit is contained in:
@@ -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);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user