Created
December 26, 2013 14:54
-
-
Save SabreCat/8134728 to your computer and use it in GitHub Desktop.
HabitRPG's logic for automatic assignment of an attribute point at levelup
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
if user.preferences.automaticAllocation | |
tallies = _.reduce user.tasks, ((m,v)-> m[v.attribute or 'str'] += v.value;m), {str:0,int:0,con:0,per:0} | |
suggested = _.reduce tallies, ((m,v,k)-> if v>tallies[m] then k else m), 'str' | |
user.stats[suggested]++ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The way it looks to me is that it goes through all your tasks, checks the attribute of each (defaulting to STR if for some reason it's not defined), and adds the task value to a counter for the appropriate attribute. Then at the end it checks which of the four attributes has the biggest counter, and increments that attribute.
If my reading is correct, there are several problems with this:
So @lefnire, did I read it right?