mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-18 07:07:35 +01:00
classes: move item-store sorting from web to shard (so we can share with
mobile) habitrpg-shared#6651665
This commit is contained in:
@@ -9,7 +9,7 @@ db.users.find().forEach(function(user){
|
|||||||
|
|
||||||
user.stats.class = 'warrior';
|
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
|
// migrate current owned items
|
||||||
|
|
||||||
|
|||||||
@@ -104,34 +104,14 @@ habitrpg.controller("TasksCtrl", ['$scope', '$rootScope', '$location', 'User', '
|
|||||||
------------------------
|
------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
var updateStore = function(){
|
$scope.itemStore = window.habitrpgShared.items.updateStore(User.user);
|
||||||
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.buy = function(item) {
|
$scope.buy = function(item) {
|
||||||
var hasEnough = window.habitrpgShared.items.buyItem(User.user, item);
|
var hasEnough = window.habitrpgShared.items.buyItem(User.user, item);
|
||||||
if (hasEnough) {
|
if (hasEnough) {
|
||||||
User.log({op: "buy", key: item.key});
|
User.log({op: "buy", key: item.key});
|
||||||
Notification.text("Item purchased.");
|
Notification.text("Item purchased.");
|
||||||
updateStore();
|
$scope.itemStore = window.habitrpgShared.items.updateStore(User.user);
|
||||||
} else {
|
} else {
|
||||||
Notification.text("Not enough Gold!");
|
Notification.text("Not enough Gold!");
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user