improve code for user.items.gear.owned.toObject as lefnire suggested in https://github.com/HabitRPG/habitrpg-shared/pull/305#issuecomment-55528155

This commit is contained in:
Alice Harris
2014-11-01 14:05:35 +10:00
parent 71269a762f
commit 7d74f36466
2 changed files with 5964 additions and 5954 deletions
+5963 -5953
View File
File diff suppressed because it is too large Load Diff
+1 -1
View File
@@ -413,7 +413,7 @@ api.wrap = (user, main=true) ->
# Free items (value:0) cannot be lost to avoid "pay to win". Subscribers have more free (Mystery) items and so would have a higher chance of losing a free one. The only exception is that the weapon_warrior_0 free item can be lost so that a new player who dies before buying any gear does experience equipment loss.
# Note ""+k string-casting. Without this, when run on the server Mongoose returns funny objects
cl = user.stats.class
gearOwned = if (typeof user.items.gear.owned.toObject is "undefined") then user.items.gear.owned else user.items.gear.owned.toObject()
gearOwned = user.items.gear.owned.toObject?() or user.items.gear.owned
losableItems = {}
_.each gearOwned, (v,k) ->
if v