From 7f1892b34a66d7413d1689db7ec6acdb009de003 Mon Sep 17 00:00:00 2001 From: Tyler Renelle Date: Thu, 5 Dec 2013 18:20:09 -0700 Subject: [PATCH] classes: move item-store sorting from web to shard (so we can share with mobile) habitrpg-shared#6651665 --- migrations/20131204_classes.js | 2 +- public/js/controllers/tasksCtrl.js | 24 ++---------------------- 2 files changed, 3 insertions(+), 23 deletions(-) diff --git a/migrations/20131204_classes.js b/migrations/20131204_classes.js index bf03f92740..c760da4c4b 100644 --- a/migrations/20131204_classes.js +++ b/migrations/20131204_classes.js @@ -9,7 +9,7 @@ db.users.find().forEach(function(user){ user.stats.class = 'warrior'; - // grant backer/contrib gear, rather than using js logic + // grant backer/contrib gear, 300, rather than using js logic // migrate current owned items diff --git a/public/js/controllers/tasksCtrl.js b/public/js/controllers/tasksCtrl.js index 6544e1bb0d..72fb1dcb59 100644 --- a/public/js/controllers/tasksCtrl.js +++ b/public/js/controllers/tasksCtrl.js @@ -104,34 +104,14 @@ habitrpg.controller("TasksCtrl", ['$scope', '$rootScope', '$location', 'User', ' ------------------------ */ - var updateStore = function(){ - var updated = window.habitrpgShared.items.updateStore(User.user); - // Do we wanna put this in habitrpg-shared? - var sorted = _.chain(updated) - .toArray() - .sortBy(function(item){ - switch (item.type) { - case 'weapon': return 1; - case 'armor': return 2; - case 'head': return 3; - case 'shield': return 4; - case 'potion': return 5; - case 'reroll': return 6; - default: return 7; - } - }) - .value(); - $scope.itemStore = sorted; - } - - updateStore(); + $scope.itemStore = window.habitrpgShared.items.updateStore(User.user); $scope.buy = function(item) { var hasEnough = window.habitrpgShared.items.buyItem(User.user, item); if (hasEnough) { User.log({op: "buy", key: item.key}); Notification.text("Item purchased."); - updateStore(); + $scope.itemStore = window.habitrpgShared.items.updateStore(User.user); } else { Notification.text("Not enough Gold!"); }