From 3a20455cda8c5e86ea745a7412c92b8c787356a5 Mon Sep 17 00:00:00 2001 From: Sabe Jones Date: Mon, 30 Nov 2015 16:11:13 -0500 Subject: [PATCH 1/3] fix(modals): Rehatch pets Corrects an issue with #6281 that would cause the pet hatching modal to fail to display if the pet had a value of -1 (i.e. raised to a mount and not yet re-hatched). --- website/public/js/controllers/inventoryCtrl.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/public/js/controllers/inventoryCtrl.js b/website/public/js/controllers/inventoryCtrl.js index c053f88d8c..bae616efa3 100644 --- a/website/public/js/controllers/inventoryCtrl.js +++ b/website/public/js/controllers/inventoryCtrl.js @@ -115,7 +115,7 @@ habitrpg.controller("InventoryCtrl", var potName = Content.hatchingPotions[potion.key].text(); if (!$window.confirm(window.env.t('hatchAPot', {potion: potName, egg: eggName}))) return; - var userHasPet = user.items.pets[egg.key + '-' + potion.key]; + var userHasPet = (user.items.pets[egg.key + '-' + potion.key] > 0) ? true:false; user.ops.hatch({params:{egg:egg.key, hatchingPotion:potion.key}}); From 1643e3dbc69216c73daf055f94a883dccd5d88ea Mon Sep 17 00:00:00 2001 From: Sabe Jones Date: Mon, 30 Nov 2015 16:19:12 -0500 Subject: [PATCH 2/3] test(modals): Rehatch scenario --- test/spec/controllers/inventoryCtrlSpec.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/test/spec/controllers/inventoryCtrlSpec.js b/test/spec/controllers/inventoryCtrlSpec.js index c110a70dae..ff959eb8e2 100644 --- a/test/spec/controllers/inventoryCtrlSpec.js +++ b/test/spec/controllers/inventoryCtrlSpec.js @@ -79,6 +79,15 @@ describe('Inventory Controller', function() { expect(rootScope.openModal).to.have.been.calledWith('hatchPet'); }); + it('shows modal even if user has raised that pet to a mount', function(){ + user.items.pets['Cactus-Base'] = -1; + scope.chooseEgg('Cactus'); + scope.choosePotion('Base'); + + expect(rootScope.openModal).to.have.been.calledOnce; + expect(rootScope.openModal).to.have.been.calledWith('hatchPet'); + }); + it('does not show modal if user tries to hatch a pet they own', function(){ scope.chooseEgg('Cactus'); scope.choosePotion('Base'); From dd3218ebbd34505eea895e872c94c2996ec96ae1 Mon Sep 17 00:00:00 2001 From: Sabe Jones Date: Mon, 30 Nov 2015 16:43:46 -0500 Subject: [PATCH 3/3] refactor(modal): Remove unnecessary ternary --- website/public/js/controllers/inventoryCtrl.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/public/js/controllers/inventoryCtrl.js b/website/public/js/controllers/inventoryCtrl.js index bae616efa3..b8a9704c24 100644 --- a/website/public/js/controllers/inventoryCtrl.js +++ b/website/public/js/controllers/inventoryCtrl.js @@ -115,7 +115,7 @@ habitrpg.controller("InventoryCtrl", var potName = Content.hatchingPotions[potion.key].text(); if (!$window.confirm(window.env.t('hatchAPot', {potion: potName, egg: eggName}))) return; - var userHasPet = (user.items.pets[egg.key + '-' + potion.key] > 0) ? true:false; + var userHasPet = user.items.pets[egg.key + '-' + potion.key] > 0; user.ops.hatch({params:{egg:egg.key, hatchingPotion:potion.key}});