mirror of
https://github.com/sudoxnym/habitica-self-host.git
synced 2026-07-16 03:02:24 +00:00
classes: fixes to buying items
This commit is contained in:
parent
5fea978e6b
commit
62d50a1f4d
3 changed files with 4 additions and 4 deletions
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Reference in a new issue