Yes, and now it says if it hasn't been initialized or is negative, set it
to zero. user.items[type][key] needs more than a value -- it should always
have a positive or zero value.


On Sun, May 11, 2014 at 3:41 PM, Tyler Renelle <notifications@github.com>wrote:

> In script/index.coffee:
>
> > @@ -604,7 +604,7 @@ api.wrap = (user, main=true) ->
> >          item = content[type][key]
> >          return cb?({code:404,message:":key not found for Content.#{type}"},req) unless item
> >          return cb?({code:401, message: i18n.t('notEnoughGems', req.language)}) if user.balance < (item.value / 4)
> > -        user.items[type][key] = 0  unless user.items[type][key]
> > +        user.items[type][key] = 0  unless user.items[type][key] > 0
>
> having trouble wrapping my mind what this will do for those issues. What
> this line said before was: "If user.items[type][key] hasn't been
> initialized on the user object, initialize it with 0".
>
> —
> Reply to this email directly or view it on GitHub<https://github.com/HabitRPG/habitrpg-shared/pull/204/files#r12511192>
> .
>