api:send 200 if not enough gp, no need to error

This commit is contained in:
Tyler Renelle 2013-08-13 17:26:15 -04:00
parent 2644e575ee
commit e2943178f4

View file

@ -234,8 +234,9 @@ api.buy = (req, res, next) ->
return res.json 400, err: ":type must be in one of: 'weapon', 'armor', 'head', 'shield'"
hasEnough = true
done = ->
return res.json 400, err: "Not enough GP" unless hasEnough
req.habit.result = data: req.habit.user.get("items")
req.habit.result = if hasEnough
data: req.habit.user.get("items")
else {data: {err: "Not enough GP"}}
next()
misc.batchTxn req.getModel(), (uObj, paths) ->
hasEnough = items.buyItem(uObj, type, {paths})