non working market

This commit is contained in:
Matteo Pagliazzi 2013-09-05 15:35:34 +02:00
parent f7d1159e06
commit bb4c0d2d69
5 changed files with 73 additions and 5 deletions

View file

@ -1,6 +1,7 @@
.NPC-Alex, .NPC-Bailey, .NPC-Bailey-Head, .NPC-Daniel, .NPC-Justin, .NPC-Justin-Head, .NPC-Matt {background: url("/bower_components/habitrpg-shared/img/npcs/NPC-SpriteSheet.png") no-repeat}
.NPC-Alex {background-position: 0 0; width: 162px; height: 138px}
.NPC-Alex {background-position: 0 0; width: 162px; height: 138px;}
.NPC-Alex-container{margin-bottom: 20px;}
.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}

View file

@ -23,4 +23,5 @@
//= require controllers/groupsCtrl
//= require controllers/petsCtrl
//= require controllers/inventoryCtrl
//= require controllers/marketCtrl
//= require controllers/footerCtrl

View file

@ -0,0 +1,40 @@
habitrpg.controller("MarketCtrl", ['$rootScope', '$scope', 'User',
function($rootScope, $scope, User) {
User.set('balance', 4);
$scope.eggs = window.habitrpgShared.items.items.pets;
$scope.hatchingPotions = window.habitrpgShared.items.items.hatchingPotions;
$scope.userEggs = User.user.items.eggs;
$scope.userHatchingPotions = User.user.items.hatchingPotions;
$scope.buy = function(type, item){
var gems = User.user.balance * 4,
store = type === 'egg' ? $scope.userEggs : $scope.userHatchingPotions;
storePath = type === 'egg' ? 'items.eggs' : 'items.hatchingPotions'
if(gems < item.value){
return $rootScope.modals.moreGems = true;
}
var message = "Buy this " + (type == 'egg' ? 'egg' : 'hatching potion') + " with " + item.value + " of your " + gems + " Gems?"
if(confirm(message)){
var toPush = type === 'egg' ? item : item.name;
store.push(toPush);
var dataStore = {
op: 'set',
data: {}
};
dataStore.data[storePath] = store;
User.log([
dataStore,
{ op: 'set', data: {'balance': (gems - item.value) / 4} }
]);
}
}
}]);

View file

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

29
views/options/market.jade Normal file
View file

@ -0,0 +1,29 @@
.row-fluid(ng-controller='MarketCtrl')
table.NPC-Alex-container
tr
td
.NPC-Alex.pull-left
td
.popover.static-popover.fade.right.in
.arrow
h3.popover-title Alexander Augustin
.popover-content
| Welcome to the Market! I'm the merchant,
a(target='_blank', href='http://www.kickstarter.com/profile/523661924') Alexander
| . Dying to get that particular pet you're after, but don't want to wait for it to drop? Buy it here!
menu.inventory-list(type='list')
li.customize-menu
menu.pets-menu(label='Eggs')
div(ng-repeat='egg in eggs track by $index')
button.customize-option(tooltip='{{egg.text}}', ng-click='buy("egg", egg)', class='Pet_Egg_{{egg.name}}')
p {{egg.text}}
li.customize-menu
menu.pets-menu(label='Hatching Potions')
div(ng-repeat='hatchingPotion in hatchingPotions track by $index')
button.customize-option(tooltip='{{hatchingPotion.text}}', ng-click='buy("hatchingPotion", hatchingPotion)', class='Pet_HatchingPotion_{{hatchingPotion.name}}')
p {{hatchingPotion.text}}