classes: fixes to buying items

This commit is contained in:
Tyler Renelle 2013-12-04 23:10:14 -07:00
parent 5fea978e6b
commit 62d50a1f4d
3 changed files with 4 additions and 4 deletions

View file

@ -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 {

View file

@ -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);

View file

@ -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);