From 4ad50b9d301db0690b73e4de7a4657ee85bd3fad Mon Sep 17 00:00:00 2001 From: Oziris Moreira Date: Fri, 16 Sep 2016 00:01:31 -0300 Subject: [PATCH] Fix Magic Mount Spacing (#8015) * fix magic mount spacing * simplify functions * function hasAPetOfPotion * var premiumPotion --- .../js/controllers/inventoryCtrl.js | 31 +++++++++++++------ website/views/options/inventory/mounts.jade | 4 +-- 2 files changed, 23 insertions(+), 12 deletions(-) diff --git a/website/client-old/js/controllers/inventoryCtrl.js b/website/client-old/js/controllers/inventoryCtrl.js index c78d00918c..9bfe5ddfa7 100644 --- a/website/client-old/js/controllers/inventoryCtrl.js +++ b/website/client-old/js/controllers/inventoryCtrl.js @@ -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); diff --git a/website/views/options/inventory/mounts.jade b/website/views/options/inventory/mounts.jade index 3c77e8a46c..d206d0ec5a 100644 --- a/website/views/options/inventory/mounts.jade +++ b/website/views/options/inventory/mounts.jade @@ -26,11 +26,11 @@ mixin mountList(eggSource, potionSource) .row: .col-md-12 +mountList(env.Content.dropEggs,env.Content.dropHatchingPotions) - .row: .col-md-12 + .row(ng-if="::shouldShowPremiumMountSection()"): .col-md-12 h4=env.t('magicMounts') menu.pets(type='list') each potion in env.Content.premiumHatchingPotions - li.customize-menu + li.customize-menu(ng-if="::hasAPetOfPotion('#{potion.key}')") menu each egg in env.Content.dropEggs - var mountKey = egg.key + "-" + potion.key