feat(content): Generalize canBuy

This commit is contained in:
Sabe Jones
2015-09-25 15:01:08 -04:00
parent 04416c4d73
commit 38bdbf020b
4 changed files with 90 additions and 90 deletions
+1 -1
View File
@@ -822,7 +822,7 @@ api.wrap = (user, main=true) ->
item = content[type][key]
price = item.value / 4
return cb?({code:404,message:":key not found for Content.#{type}"},req) unless item
return cb?({code:403, message: i18n.t('messageNotAvailable', req.language)}) if type is 'hatchingPotions' and not item.canBuy
return cb?({code:403, message: i18n.t('messageNotAvailable', req.language)}) if not item.canBuy(user)
return cb?({code:403, message: i18n.t('notEnoughGems', req.language)}) if (user.balance < price) or !user.balance
user.balance -= price
if type is 'gear' then user.items.gear.owned[key] = true