From 9b5b83871faddbd5deaff51dc77e3f51634da8c1 Mon Sep 17 00:00:00 2001 From: Blade Barringer Date: Sun, 25 Jan 2015 21:00:34 -0600 Subject: [PATCH] Refined triad Bingo calculation --- public/js/controllers/inventoryCtrl.js | 19 +++++-------------- public/js/controllers/rootCtrl.js | 4 ---- 2 files changed, 5 insertions(+), 18 deletions(-) diff --git a/public/js/controllers/inventoryCtrl.js b/public/js/controllers/inventoryCtrl.js index ef2152818d..20b1ffbe3c 100644 --- a/public/js/controllers/inventoryCtrl.js +++ b/public/js/controllers/inventoryCtrl.js @@ -77,18 +77,6 @@ habitrpg.controller("InventoryCtrl", return _.pick(inventory, function(v,k){return v>0;}); } - $scope.calcTriadBingo = function() { - var hasPets = Shared.countPets(null, User.user.items.pets) >= 90 ; - var hasMounts = Shared.countMounts(null, User.user.items.mounts) >= 90; - - if(!(hasPets && hasMounts)) return false; - - for (var p in User.user.items.pets) { - if(User.user.items.pets[p] < 0) return false; - } - return true; - } - $scope.hatch = function(egg, potion){ var eggName = Content.eggs[egg.key].text(); var potName = Content.hatchingPotions[potion.key].text(); @@ -97,16 +85,19 @@ habitrpg.controller("InventoryCtrl", $scope.selectedEgg = null; $scope.selectedPotion = null; + $rootScope.petCount = Shared.countPets($rootScope.countExists(User.user.items.pets), User.user.items.pets); + // Checks if beastmaster has been reached for the first time if(!User.user.achievements.beastMaster - && Shared.countPets(null, User.user.items.pets) >= 90) { + && $rootScope.petCount >= 90) { User.user.achievements.beastMaster = true; $rootScope.openModal('achievements/beastMaster'); } // Checks if Triad Bingo has been reached for the first time if(!User.user.achievements.triadBingo - && $scope.calcTriadBingo()) { + && $rootScope.mountCount >= 90 + && Shared.countTriad(User.user.items.pets)) { User.user.achievements.triadBingo = true; $rootScope.openModal('achievements/triadBingo'); } diff --git a/public/js/controllers/rootCtrl.js b/public/js/controllers/rootCtrl.js index e46ffdbc1f..9360daf469 100644 --- a/public/js/controllers/rootCtrl.js +++ b/public/js/controllers/rootCtrl.js @@ -91,10 +91,6 @@ habitrpg.controller("RootCtrl", ['$scope', '$rootScope', '$location', 'User', '$ $rootScope.petCount = Shared.countPets($rootScope.countExists(User.user.items.pets), User.user.items.pets); $rootScope.mountCount = Shared.countMounts($rootScope.countExists(User.user.items.mounts), User.user.items.mounts); - $rootScope.$watch('user.items.pets', function(pets){ - $rootScope.petCount = Shared.countPets($rootScope.countExists(pets), User.user.items.pets); - }, true); - $scope.safeApply = function(fn) { var phase = this.$root.$$phase; if(phase == '$apply' || phase == '$digest') {