Last active
December 30, 2015 02:28
-
-
Save lefnire/7762451 to your computer and use it in GitHub Desktop.
coffee
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
# Aggregate all intrinsic stats, buffs, weapon, & armor into computed stats | |
Object.defineProperty user, '_statsComputed', | |
get: -> | |
_.reduce(['per','con','str','int'], (m,stat) => | |
m[stat] = _.reduce('stats stats.buffs items.gear.current.weapon items.gear.current.armor items.gear.current.head items.gear.current.shield'.split(' '), (m2,path) => | |
val = helpers.dotGet(path, @) | |
m2 + | |
if ~path.indexOf('items.gear') | |
# get the gear stat, and multiply it by 1.2 if it's class-gear | |
(+items.items.gear.flat[val]?[stat] or 0) * (if ~val?.indexOf(@stats.class) then 1.2 else 1) | |
else | |
+val[stat] or 0 | |
, 0); m | |
, {}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment