Last active
August 29, 2015 14:20
-
-
Save lefnire/dff001389b88275e82cc to your computer and use it in GitHub Desktop.
This file contains 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 |
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
turns out you don't need
return true
inArray.forEach
, just a thing with Lodash's_.each
method. Looks like it's emulating the behavior ofArray.every
instead ofArray.forEach
, former which indeed exists upon encounteringfalse