prevent off-class items and free items being lost on death
This commit is contained in:
Vendored
+169
-997
File diff suppressed because it is too large
Load Diff
+15
-4
@@ -401,7 +401,7 @@ api.wrap = (user, main=true) ->
|
||||
revive: (req, cb) ->
|
||||
return cb?({code:400, message: "Cannot revive if not dead"}) unless user.stats.hp <= 0
|
||||
|
||||
# Reset stats
|
||||
# Reset stats after death
|
||||
_.merge user.stats, {hp:50, exp:0, gp:0}
|
||||
user.stats.lvl-- if user.stats.lvl > 1
|
||||
|
||||
@@ -410,9 +410,20 @@ api.wrap = (user, main=true) ->
|
||||
user.stats[lostStat]-- if lostStat
|
||||
|
||||
# Lose a gear piece
|
||||
# Note, they can actually lose item weapon_*_0 - it's 0 to buy back, no big deal
|
||||
# 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 loosing a free one.
|
||||
# Note ""+k string-casting. Without this, when run on the server Mongoose returns funny objects
|
||||
lostItem = user.fns.randomVal _.reduce(user.items.gear.owned, ((m,v,k)->m[''+k]=''+k if v;m), {})
|
||||
cl = user.stats.class
|
||||
lostItem = user.fns.randomVal _.reduce(user.items.gear.owned, ((m,v,k)->
|
||||
if v && k != 'toObject'
|
||||
# 'toObject' appears as first key when run on server. No idea why.
|
||||
itm = content.gear.flat[''+k]
|
||||
if itm
|
||||
if itm.value > 0 && ( itm.klass == cl || ( itm.klass == 'special' && (! itm.specialClass || itm.specialClass == cl) ) )
|
||||
m[''+k]=''+k
|
||||
# else
|
||||
# console.log "Can't get item for " + k
|
||||
# # in case other wierd things like 'toObject' turn up
|
||||
m), {})
|
||||
|
||||
if item = content.gear.flat[lostItem]
|
||||
user.items.gear.owned[lostItem] = false
|
||||
@@ -1306,7 +1317,7 @@ api.wrap = (user, main=true) ->
|
||||
)()]++
|
||||
|
||||
updateStats: (stats, req) ->
|
||||
# Game Over
|
||||
# Game Over (death)
|
||||
return user.stats.hp=0 if stats.hp <= 0
|
||||
|
||||
user.stats.hp = stats.hp
|
||||
|
||||
Reference in New Issue
Block a user