eggs: add ability to sell potions / eggs

This commit is contained in:
Tyler Renelle
2013-10-19 20:04:26 -07:00
parent 017398eb83
commit c882525150
2 changed files with 20 additions and 2 deletions

View File

@@ -28,6 +28,24 @@ habitrpg.controller("InventoryCtrl", ['$scope', 'User',
} }
} }
$scope.sellInventory = function() {
if ($scope.selectedEgg) {
User.user.stats.gp += $scope.selectedEgg.value;
$scope.userEggs.splice($scope.selectedEgg.index, 1);
User.log([
{ op: 'set', data: {'items.eggs': $scope.userEggs} }
]);
$scope.selectedEgg = null;
} else if ($scope.selectedPotion) {
User.user.stats.gp += $scope.selectedPotion.value;
$scope.userHatchingPotions.splice($scope.selectedPotion.index, 1);
User.log([
{ op: 'set', data: {'items.hatchingPotions': $scope.selectedPotion} }
]);
$scope.selectedPotion = null;
}
}
$scope.ownsPet = function(egg, potion){ $scope.ownsPet = function(egg, potion){
if (!egg || !potion) return; if (!egg || !potion) return;
var pet = egg.name + '-' + potion; var pet = egg.name + '-' + potion;

View File

@@ -21,9 +21,9 @@
table.NPC-Alex-container table.NPC-Alex-container
tr tr
td td
button.customize-option.sell-inventory(ng-show='selectedEgg') button.customize-option.sell-inventory(ng-show='selectedEgg', ng-click='sellInventory()')
| Sell {{selectedEgg.name}} for {{selectedEgg.value}} GP | Sell {{selectedEgg.name}} for {{selectedEgg.value}} GP
button.customize-option.sell-inventory(ng-show='selectedPotion') button.customize-option.sell-inventory(ng-show='selectedPotion', ng-click='sellInventory()')
| Sell {{selectedPotion.name}} for {{selectedPotion.value}} GP | Sell {{selectedPotion.name}} for {{selectedPotion.value}} GP
.NPC-Alex.pull-left(ng-show='!selectedEgg && !selectedPotion') .NPC-Alex.pull-left(ng-show='!selectedEgg && !selectedPotion')
td td