mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-19 07:37:25 +01:00
classes: fixes to buying special-gear & regular gear habitrpg-shared#ee4777d
This commit is contained in:
@@ -106,17 +106,30 @@ habitrpg.controller("TasksCtrl", ['$scope', '$rootScope', '$location', 'User', '
|
||||
|
||||
var updateStore = function(){
|
||||
var updated = window.habitrpgShared.items.updateStore(User.user);
|
||||
// Figure out whether we wanna put this in habitrpg-shared
|
||||
var sorted = [updated.weapon, updated.armor, updated.head, updated.shield, updated.potion, updated.reroll];
|
||||
// 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(type) {
|
||||
var hasEnough = window.habitrpgShared.items.buyItem(User.user, type);
|
||||
$scope.buy = function(item) {
|
||||
var hasEnough = window.habitrpgShared.items.buyItem(User.user, item);
|
||||
if (hasEnough) {
|
||||
User.log({op: "buy", type: type});
|
||||
User.log({op: "buy", key: item.key});
|
||||
Notification.text("Item purchased.");
|
||||
updateStore();
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user