mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-17 14:47:53 +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 () {
|
$scope.shouldShowPremiumMountSection = function () {
|
||||||
var pets = Object.keys(user.items.pets);
|
return findPet(function (pet) {
|
||||||
return pets.find(function (petKey) {
|
|
||||||
var pet = Content.petInfo[petKey];
|
|
||||||
return pet.type === 'premium';
|
return pet.type === 'premium';
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.hasAPetOfPotion = function (potion) {
|
$scope.hasAPetOfPotion = function (potion) {
|
||||||
|
return findPet(function (pet) {
|
||||||
|
return pet.potion === potion;
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
function findPet (fn) {
|
||||||
var pets = Object.keys(user.items.pets);
|
var pets = Object.keys(user.items.pets);
|
||||||
return pets.find(function (petKey) {
|
return pets.find(function (petKey) {
|
||||||
var pet = Content.petInfo[petKey];
|
var pet = Content.petInfo[petKey];
|
||||||
return pet.potion === potion;
|
return fn(pet);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user