Last active
August 29, 2015 14:20
-
-
Save lefnire/dff001389b88275e82cc to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
content.gear.tree[klass][type]
needed to becontent.gear.tree[type][klass]
, but otherwise this seems to work great!