diff --git a/assets/js/appMain.js b/assets/js/appMain.js index 9f57a33254..8d568c62bd 100644 --- a/assets/js/appMain.js +++ b/assets/js/appMain.js @@ -22,4 +22,5 @@ //= require controllers/userAvatarCtrl //= require controllers/groupsCtrl //= require controllers/petsCtrl +//= require controllers/inventoryCtrl //= require controllers/footerCtrl \ No newline at end of file diff --git a/assets/js/controllers/inventoryCtrl.js b/assets/js/controllers/inventoryCtrl.js new file mode 100644 index 0000000000..7e8db4340c --- /dev/null +++ b/assets/js/controllers/inventoryCtrl.js @@ -0,0 +1,46 @@ +habitrpg.controller("InventoryCtrl", ['$scope', 'User', + function($scope, User) { + + $scope.hatching = false; + $scope.userEggs = User.user.items.eggs; + $scope.userHatchingPotions = User.user.items.hatchingPotions; + + $scope.chooseEgg = function(egg){ + if($scope.userHatchingPotions && $scope.userHatchingPotions.length < 1) { + return alert("You have no hatching potion!"); + } + + $scope.selectedEgg = egg; + $scope.selectedPotion = $scope.userHatchingPotions[0]; + $scope.hatching = true; + } + + $scope.pour = function(){ + var i = _.indexOf($scope.userEggs, $scope.selectedEgg); + $scope.userEggs.splice(i, 1); + + i = _.indexOf($scope.userHatchingPotions, $scope.selectedPotion); + $scope.userHatchingPotions.splice(i, 1); + + var pet = $scope.selectedEgg.name + '-' + $scope.selectedPotion; + + if(User.user.items.pets && User.user.items.pets.indexOf(pet) != -1) { + return alert("You already have that pet, hatch a different combo.") + } + + if(!User.user.items.pets) User.user.items.pets = []; + User.user.items.pets.push(pet); + + User.log([ + { op: 'set', data: {'items.pets': User.user.items.pets} }, + { op: 'set', data: {'items.eggs': $scope.userEggs} }, + { op: 'set', data: {'items.hatchingPotions': $scope.userHatchingPotions} } + ]); + + alert("Your egg hatched! Visit your stable to equip your pet."); + + $scope.selectedEgg = null; + $scope.hatching = false; + } + + }]); \ No newline at end of file diff --git a/views/options/inventory.jade b/views/options/inventory.jade index f152927b93..29eff8dc6d 100644 --- a/views/options/inventory.jade +++ b/views/options/inventory.jade @@ -1,24 +1,23 @@ -.row-fluid - div(ng-class='{span6: _hatchEgg}') +.row-fluid(ng-controller='InventoryCtrl') + div(ng-class='{span6: hatching}') menu.inventory-list(type='list') li.customize-menu menu.pets-menu(label='Eggs') - p(ng-show='!user.items.eggs') You don't have any eggs yet. - div(ng-repeat='egg in user.items.eggs track by $index') - button.customize-option(tooltip='{{egg.text}}', x-bind='click: chooseEgg', class='Pet_Egg_{{egg.name}}') + p(ng-show='userEggs.length < 1') You don't have any eggs yet. + div(ng-repeat='egg in userEggs track by $index') + button.customize-option(tooltip='{{egg.text}}', ng-click='chooseEgg(egg)', class='Pet_Egg_{{egg.name}}') p {{egg.text}} li.customize-menu menu.hatchingPotion-menu(label='Hatching Potions') - p(ng-show='!user.items.hatchingPotions') You don't have any hatching potions yet. - div(ng-repeat='hatchingPotion in user.items.hatchingPotions track by $index') - button.customize-option(tooltip='{{hatchingPotion}}', x-bind='click: chooseHatching Potion', class='Pet_HatchingPotion_{{hatchingPotion}}') + p(ng-show='userHatchingPotions.length < 1') You don't have any hatching potions yet. + div(ng-repeat='hatchingPotion in userHatchingPotions track by $index') + button.customize-option(tooltip='{{hatchingPotion}}', class='Pet_HatchingPotion_{{hatchingPotion}}') p {{hatchingPotion}} - .span6(ng-show='_hatchEgg') + .span6(ng-show='hatching') h3 Hatch Your Egg - p(ng-show='!user.items.hatchingPotions') You don't have any hatching potions yet. - div(ng-show='user.items.hatchingPotions') + p(ng-show='userHatchingPotions.length < 1') You don't have any hatching potions yet. + div(ng-show='userHatchingPotions') p Which hatching potion will you pour on your {{_hatchEgg.text}} egg? - form(x-bind='submit:hatchEgg') - select - option(ng-repeat='hatchingPotion in user.items.hatchingPotions track by $index') {{hatchingPotion}} - button(type='submit') Pour + form + select(ng-options='hatchingPotion for hatchingPotion in userHatchingPotions', ng-model="selectedPotion") + button(ng-click="pour()") Pour diff --git a/views/options/pets.html b/views/options/pets.html deleted file mode 100644 index 3581a50245..0000000000 --- a/views/options/pets.html +++ /dev/null @@ -1,64 +0,0 @@ - - - - - - - - -
-

{.text}
{.value} Gems

- - - - -
-

{.text}
{.value} Gems

- - - - - - - -
-
-

Matt Boch

-
-

Welcome to the Stable! I'm Matt, the beast master. Choose a pet here to adventure at your side - they aren't much help yet, but I forsee a time when they're able to grow into powerful steeds! Until that day, have a look-see at all the pets you can collect.

-

{count(_user.items.pets)} / 90 Pets Found

-
-
- - - {{#each _items.pets as :pet}} - - {{#each _items.hatchingPotions as :potion}} - - {{/}} - - {{/}} -
- -
-

Rare Pets

- - - - {{#if gt(_user.backer.tier,79)}}{{/}} - -
- - -
- {#if ownsPet(@pet, _user.items.pets)} - - {else} - - {/} -
\ No newline at end of file