From bb4c0d2d6992476dad30241a5a6d2346d8bef99f Mon Sep 17 00:00:00 2001 From: Matteo Pagliazzi Date: Thu, 5 Sep 2013 15:35:34 +0200 Subject: [PATCH] non working market --- assets/css/npcs.styl | 3 ++- assets/js/appMain.js | 1 + assets/js/controllers/marketCtrl.js | 40 +++++++++++++++++++++++++++++ views/options/index.jade | 5 +--- views/options/market.jade | 29 +++++++++++++++++++++ 5 files changed, 73 insertions(+), 5 deletions(-) create mode 100644 assets/js/controllers/marketCtrl.js create mode 100644 views/options/market.jade diff --git a/assets/css/npcs.styl b/assets/css/npcs.styl index 74f08efc8a..b4d82d77be 100644 --- a/assets/css/npcs.styl +++ b/assets/css/npcs.styl @@ -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} diff --git a/assets/js/appMain.js b/assets/js/appMain.js index 8d568c62bd..27676bbef9 100644 --- a/assets/js/appMain.js +++ b/assets/js/appMain.js @@ -23,4 +23,5 @@ //= require controllers/groupsCtrl //= require controllers/petsCtrl //= require controllers/inventoryCtrl +//= require controllers/marketCtrl //= require controllers/footerCtrl \ No newline at end of file diff --git a/assets/js/controllers/marketCtrl.js b/assets/js/controllers/marketCtrl.js new file mode 100644 index 0000000000..f350eb0631 --- /dev/null +++ b/assets/js/controllers/marketCtrl.js @@ -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} } + ]); + } + } + + }]); \ No newline at end of file diff --git a/views/options/index.jade b/views/options/index.jade index eff9d15bf3..13f01ee46b 100644 --- a/views/options/index.jade +++ b/views/options/index.jade @@ -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 diff --git a/views/options/market.jade b/views/options/market.jade new file mode 100644 index 0000000000..7edf743025 --- /dev/null +++ b/views/options/market.jade @@ -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}} + + +