classes armory: separate gear listings by class type, show selected gear

This commit is contained in:
Tyler Renelle
2013-12-06 09:26:02 -07:00
parent 7f1892b34a
commit 3e5c213694
2 changed files with 27 additions and 8 deletions

View File

@@ -2,6 +2,7 @@ habitrpg.controller("InventoryCtrl", ['$rootScope', '$scope', 'User', 'API_URL',
function($rootScope, $scope, User, API_URL, $http, Notification) {
var user = User.user;
var Items = window.habitrpgShared.items;
// convenience vars since these are accessed frequently
@@ -17,11 +18,28 @@ habitrpg.controller("InventoryCtrl", ['$rootScope', '$scope', 'User', 'API_URL',
$scope.$watch('user.items.hatchingPotions', function(pots){ $scope.potCount = countStacks(pots); }, true);
$scope.$watch('user.items.food', function(food){ $scope.foodCount = countStacks(food); }, true);
$scope.$watch('user.items.gear', function(gear){
$scope.gear = {
base: [
Items.items.gear.flat['head_warrior_0'],
Items.items.gear.flat['armor_warrior_0'],
//Items.items.gear.flat['weapon_warrior_0'],
Items.items.gear.flat['shield_warrior_0']
]
};
_.each(gear.owned, function(bool,key){
var item = Items.items.gear.flat[key];
debugger;
if (!$scope.gear[item.klass]) $scope.gear[item.klass] = [];
$scope.gear[item.klass].push(item);
})
}, true)
$scope.chooseEgg = function(egg){
if ($scope.selectedEgg && $scope.selectedEgg.name == egg) {
return $scope.selectedEgg = null; // clicked same egg, unselect
}
var eggData = _.findWhere(window.habitrpgShared.items.items.eggs, {name:egg});
var eggData = _.findWhere(Items.items.eggs, {name:egg});
if (!$scope.selectedPotion) {
$scope.selectedEgg = eggData;
} else {
@@ -34,7 +52,7 @@ habitrpg.controller("InventoryCtrl", ['$rootScope', '$scope', 'User', 'API_URL',
return $scope.selectedPotion = null; // clicked same egg, unselect
}
// we really didn't think through the way these things are stored and getting passed around...
var potionData = _.findWhere(window.habitrpgShared.items.items.hatchingPotions, {name:potion});
var potionData = _.findWhere(Items.items.hatchingPotions, {name:potion});
if (!$scope.selectedEgg) {
$scope.selectedPotion = potionData;
} else {

View File

@@ -5,18 +5,19 @@ script(type='text/ng-template', id='partials/options.inventory.inventory.html')
p.well Click an egg to see usable potions highlighted in green and then click one of the highlighted potions to hatch your pet. If no potions are highlighted, click that egg again to deselect it, and instead click a potion first to have the usable eggs highlighted. You can also sell unwanted drops to Alexander the Merchant.
menu.inventory-list(type='list')
h4 Gear
li.customize-menu
menu.pets-menu(label='Gear')
div(ng-repeat='(k,v) in user.items.gear.owned', ng-init='item = Items.gear.flat[k]')
button.customize-option(popover='{{item.notes}}', popover-title='{{item.text}}', popover-trigger='mouseenter', popover-placement='right', ng-click='equip(user,item)', class='shop_{{item.key}}')
menu.pets-menu(label='{{label}}', ng-repeat='(klass,label) in {base:"Base", warrior:"Warrior", wizard:"Wizard", rogue:"Rogue", special:"Special"}', ng-show='gear[klass]')
div(ng-repeat='item in gear[klass]')
button.customize-option(popover='{{item.notes}}', popover-title='{{item.text}}', popover-trigger='mouseenter', popover-placement='right', ng-click='equip(user,item)', class='shop_{{item.key}}', ng-class='{selectableInventory: user.items.gear.equipped[item.type] == item.key}')
label.checkbox.inline
input(type="checkbox", ng-model="user.preferences.costume")
| Use Costume 
i.icon-question-sign(popover="Show something different on your avatar than the gear you have equipped for battle", popover-trigger='mouseenter', popover-placement='right')
li.customize-menu(ng-if='user.preferences.costume')
menu.pets-menu(label='Gear')
div(ng-repeat='(k,v) in user.items.gear.owned', ng-init='item = Items.gear.flat[k]')
button.customize-option(popover='{{item.notes}}', popover-title='{{item.text}}', popover-trigger='mouseenter', popover-placement='right', ng-click='equip(user,item,true)', class='shop_{{item.key}}')
menu.pets-menu(label='{{label}}', ng-repeat='(klass,label) in {base:"Base", warrior:"Warrior", wizard:"Wizard", rogue:"Rogue", special:"Special"}', ng-show='gear[klass]')
div(ng-repeat='item in gear[klass]')
button.customize-option(popover='{{item.notes}}', popover-title='{{item.text}}', popover-trigger='mouseenter', popover-placement='right', ng-click='equip(user,item, true)', class='shop_{{item.key}}', ng-class='{selectableInventory: user.items.gear.costume[item.type] == item.key}')
li.customize-menu
menu.pets-menu(label='Eggs ({{eggCount}})')