classes: fixes to buying items
This commit is contained in:
@@ -116,7 +116,7 @@ habitrpg.controller("TasksCtrl", ['$scope', '$rootScope', '$location', 'User', '
|
||||
$scope.buy = function(type) {
|
||||
var hasEnough = window.habitrpgShared.items.buyItem(User.user, type);
|
||||
if (hasEnough) {
|
||||
User.log({op: "buy",type: type});
|
||||
User.log({op: "buy", type: type});
|
||||
Notification.text("Item purchased.");
|
||||
updateStore();
|
||||
} else {
|
||||
|
||||
@@ -204,8 +204,8 @@ api.clearCompleted = function(req, res, next) {
|
||||
*/
|
||||
api.buy = function(req, res, next) {
|
||||
var user = res.locals.user;
|
||||
var item = req.params.item;
|
||||
if (item !== 'potion' && !items.items.gear.flat[item]) {
|
||||
var type = req.params.type;
|
||||
if (!type.match(/potion|weapon|armor|head|shield/)) { // if (item !== 'potion' && !items.items.gear.flat[item])
|
||||
return res.json(400, {err: ":item must be a supported key, see https://github.com/HabitRPG/habitrpg-shared/blob/master/script/items.coffee"});
|
||||
}
|
||||
var hasEnough = items.buyItem(user, type);
|
||||
|
||||
+1
-1
@@ -48,7 +48,7 @@ if (nconf.get('NODE_ENV') == 'development') {
|
||||
}
|
||||
|
||||
/* Items*/
|
||||
router.post('/user/buy/:item', auth.auth, cron, user.buy);
|
||||
router.post('/user/buy/:type', auth.auth, cron, user.buy);
|
||||
|
||||
/* User*/
|
||||
router.get('/user', auth.auth, cron, user.getUser);
|
||||
|
||||
Reference in New Issue
Block a user