non working stable choosePet

This commit is contained in:
Matteo Pagliazzi 2013-09-03 10:32:06 +02:00
parent 3417e3a76b
commit 3fd290a3e1
5 changed files with 73 additions and 5 deletions

View file

@ -4,7 +4,7 @@
.NPC-Daniel {background-position: -222px 0; width: 135px; height: 123px}
.NPC-Justin {background-position: -357px 0; width: 84px; height: 119px}
.NPC-Justin-Head {background-position: -396px 0; width: 36px; height: 96px}
.NPC-Matt {background-position: -441px 0; width: 198px; height: 144px}
.NPC-Matt {background-position: -441px 0; width: 100%; padding-left: 208px; padding-bottom: 20px;}
// Bailey
.NPC-Bailey

View file

@ -0,0 +1,39 @@
habitrpg.controller("PetsCtrl", ['$scope', '$rootScope', 'User',
function($scope, $rootScope, User) {
var user = $rootScope.user;
$scope.userPets = user.items.pets;
$scope.userCurrentPet = user.items.currentPet;
$scope.pets = window.habitrpgShared.items.items.pets;
$scope.hatchingPotions = window.habitrpgShared.items.items.hatchingPotions;
$scope.hasPet = function(name, potion){
if (!$scope.userPets) return false;
return _.contains($scope.userPets, name + '-' + potion) ? true : false;
}
$scope.isCurrentPet = function(name, potion){
if (!$scope.userCurrentPet || !$scope.userPets) return false;
return $scope.userCurrentPet.str === (name + '-' + potion);
}
$scope.choosePet = function(name, potion){
console.log(user.items.currentPet);
if($scope.userCurrentPet && $scope.userCurrentPet.str === (name + '-' + potion)){
$scope.userCurrentPet = null;
User.log({op:'set', data:{'items.currentPet': $scope.userCurrentPet}});
}else{
var pet = _.find($scope.pets, {name: name});
console.log(pet, {name: $scope.pets});
pet.modifier = potion;
pet.str = name + '-' + potion;
$scope.userCurrentPet = pet;
User.log({op:'set', data:{'items.currentPet': $scope.userCurrentPet}});
}
// Changes doesn't propagate!!! here the console log for 'user.items.currentPet' the old value and
// for '$scope.userCurrentPet' the new one
console.log(user.items.currentPet, $scope.userCurrentPet);
}
}]);

View file

@ -68,6 +68,7 @@ html
!= js('controllers/filtersCtrl')
!= js('controllers/userAvatarCtrl')
!= js('controllers/groupsCtrl')
!= js('controllers/petsCtrl')
!= js('controllers/footerCtrl')
//webfonts

View file

@ -54,10 +54,7 @@
//app:game-pane:market
.tab-pane#stable-tab
h4.well
| Coming soon.
a(href='https://github.com/lefnire/habitrpg/wiki/Contributing#website', target='blank') Help us port this feature!
//app:pets:stable
include ./groups/tavern
.tab-pane#tavern-tab
include ./groups/tavern

31
views/options/pets.jade Normal file
View file

@ -0,0 +1,31 @@
.stable(ng-controller='PetsCtrl')
.NPC-Matt
.popover.static-popover.fade.right.in(style='max-width: 550px; margin-left: 10px;')
.arrow
h3.popover-title Matt Boch
.popover-content
p
| Welcome to the Stable! I'm
a(target='_blank', href='http://www.kickstarter.com/profile/mattboch') 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
a(href='https://trello.com/card/mounts/50e5d3684fe3a7266b0036d6/221') grow into powerful steeds
| ! Until that day,
a(target='_blank', href='https://f.cloud.github.com/assets/2374703/164631/3ed5fa6c-78cd-11e2-8743-f65ac477b55e.png') have a look-see
| at all the pets you can collect.
h4 {{userPets.length}} / 90 Pets Found
table.pets(ng-repeat='pet in pets')
tbody
tr
td(ng-repeat='potion in hatchingPotions')
button(class="pet-button Pet-{{pet.name}}-{{potion.name}}", ng-show='hasPet(pet.name, potion.name)', ng-class="{active: isCurrentPet(pet.name, potion.name)}", ng-click='choosePet(pet.name, potion.name)', tooltip='{{potion.name}} {{pet.name}}')
button(class="pet-button pet-not-owned", ng-hide='hasPet(pet.name, potion.name)')
img(src='/bower_components/habitrpg-shared/img/PixelPaw.png', tooltip='{{potion.name}} {{pet.name}}')
h4 Rare Pets
table
tr
td
button(class="pet-button Pet-Wolf-Veteran", ng-show='hasPet("Wolf", "Veteran")', ng-class='{active: isCurrentPet("Wolf", "Veteran")}', ng-click='choosePet("Wolf", "Veteran")', tooltip='Veteran Wolf')
button(class="pet-button pet-not-owned", ng-hide='hasPet("Wolf", "Veteran")')
img(src='/bower_components/habitrpg-shared/img/PixelPaw.png', tooltip='Veteran Wolf')