event-items: try a different approach than "unbreakable" (1335750). If they've owned it before (item==false), then they canOwn() again. In those cases, set item to 'event'
This commit is contained in:
@@ -131,7 +131,7 @@ gear =
|
||||
0: text: "Shade Helm", notes:'Blood and ash, lava and obsidian give this helm its imagery and power. Increases INT by 20.', int: 20, value:150, canOwn: ((u)-> +u.backer?.tier >= 45)
|
||||
1: text: "Crystal Helm", notes:'The favored crown of those who lead by example. Increases all attributes by 6.', con: 6, str: 6, per: 6, int: 6, value:170, canOwn: ((u)-> +u.contributor?.level >= 3)
|
||||
2: text: "Nameless Helm", notes:'A testament to those who gave of themselves while asking nothing in return. Increases INT and STR by 25 each.', int: 25, str: 25, value:200, canOwn: ((u)-> +u.backer?.tier >= 300)
|
||||
nye: text: "Absurd Party Hat", notes:"You've received an Absurd Party Hat! Wear it with pride while ringing in the New Year!", value: 0, canOwn: (->false), unbreakable: true
|
||||
nye: text: "Absurd Party Hat", notes:"You've received an Absurd Party Hat! Wear it with pride while ringing in the New Year!", value: 0, event: {start:'2013-12-31',end:'2014-02-01'}
|
||||
#candycane: text: "Candy Cane Hat", notes: 'A hat adorned in candy, a wintery treat!', value:10, canOwn: ((u)-> moment(u.auth.timestamps?.created).isBefore(new Date '01/10/2014'))
|
||||
|
||||
shield:
|
||||
@@ -179,6 +179,14 @@ _.each ['weapon', 'armor', 'head', 'shield'], (type) ->
|
||||
_.each gear[type][klass], (item, i) ->
|
||||
key = "#{type}_#{klass}_#{i}"
|
||||
_.defaults item, {type, key, klass, index: i, str:0, int:0, per:0, con:0}
|
||||
|
||||
if item.event
|
||||
#? indicates null/undefined. true means they own currently, false means they once owned - and false is what we're
|
||||
# after (they can buy back if they bought it during the event's timeframe)
|
||||
_canOwn = item.canOwn or (->true)
|
||||
item.canOwn = (u)->
|
||||
_canOwn(u) and (u.items.gear.owned[key]? or (moment().isAfter(item.event.start) and moment().isBefore(item.event.end)))
|
||||
|
||||
api.gear.flat[key] = item
|
||||
|
||||
###
|
||||
|
||||
+2
-4
@@ -369,10 +369,8 @@ api.wrap = (user) ->
|
||||
|
||||
# Lose a gear piece
|
||||
# Note, they can actually lose item weapon_*_0 - it's 0 to buy back, no big deal
|
||||
lostItem = user.fns.randomVal _.reduce user.items.gear.owned, (m,v,k)->
|
||||
# Note ""+k string-casting. Without this, when run on the server Mongoose returns funny objects
|
||||
(m[''+k]=''+k if v and !content.gear.flat[''+k].unbreakable);m
|
||||
, {}
|
||||
# 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), {})
|
||||
|
||||
if item = content.gear.flat[lostItem]
|
||||
user.items.gear.owned[lostItem] = false
|
||||
|
||||
Reference in New Issue
Block a user