Fix Magic Mount Spacing (#8015)

* fix magic mount spacing

* simplify functions

* function hasAPetOfPotion

* var premiumPotion
This commit is contained in:
Oziris Moreira
2016-09-16 00:01:31 -03:00
committed by Blade Barringer
parent 998037e0a1
commit 4ad50b9d30
2 changed files with 23 additions and 12 deletions

View File

@@ -355,24 +355,19 @@ habitrpg.controller("InventoryCtrl",
$scope.seasonalShopCategories = Shared.shops.getSeasonalShopCategories(user);
$scope.shouldShowPremiumPetRow = function (potion) {
potion = Content.premiumHatchingPotions[potion];
var premiumPotion = Content.premiumHatchingPotions[potion];
if (!potion) {
if (!premiumPotion) {
return false;
}
if (user.items.hatchingPotions[potion.key] > 0) {
if (user.items.hatchingPotions[premiumPotion.key] > 0) {
return true;
}
if (potion.canBuy()) {
if (premiumPotion.canBuy()) {
return true;
}
var pets = Object.keys(user.items.pets);
var hasAPetOfPotion = pets.find(function (pet) {
return pet.indexOf(potion.key) !== -1;
});
return hasAPetOfPotion;
return $scope.hasAPetOfPotion(potion);
};
$scope.shouldShowPremiumPetSection = function () {
@@ -382,6 +377,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 pet.type === 'premium';
});
};
$scope.hasAPetOfPotion = function (potion) {
var pets = Object.keys(user.items.pets);
return pets.find(function (petKey) {
var pet = Content.petInfo[petKey];
return pet.potion === potion;
});
}
function _updateDropAnimalCount(items) {
$scope.petCount = Shared.count.beastMasterProgress(items.pets);
$scope.mountCount = Shared.count.mountMasterProgress(items.mounts);