Skip to content

Instantly share code, notes, and snippets.

@lefnire
Last active August 29, 2015 14:20
Show Gist options
  • Save lefnire/dff001389b88275e82cc to your computer and use it in GitHub Desktop.
Save lefnire/dff001389b88275e82cc to your computer and use it in GitHub Desktop.
ultimateGear: ->
# on the server this is a LoDash transform, on the client its an object
owned = if window? then user.items.gear.owned else user.items.gear.owned.toObject()
content.classes.forEach (klass) ->
user.achievements.ultimateGear[klass] = _.reduce ['armor', 'shield', 'head', 'weapon'], (soFarGood, type) ->
found = _.find content.gear.tree[klass][type], {last:true}
soFarGood and (!found or owned[found.key]==true) #!found only true when weapon is two-handed (mages)
, true # start with true, else `and` will fail right away
@SabreCat
Copy link

content.gear.tree[klass][type] needed to be content.gear.tree[type][klass], but otherwise this seems to work great!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment