Skip to content

Instantly share code, notes, and snippets.

@SabreCat
Created December 26, 2013 14:54
Show Gist options
  • Save SabreCat/8134728 to your computer and use it in GitHub Desktop.
Save SabreCat/8134728 to your computer and use it in GitHub Desktop.
HabitRPG's logic for automatic assignment of an attribute point at levelup
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]++
@SabreCat
Copy link
Author

Pinging @lefnire per request on G+. I haven't been able to find a good way to just start a code-line conversation at an arbitrary point in a file...

@SabreCat
Copy link
Author

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:

  1. It's only a snapshot of what's on your list at the end of the level. If for instance I completed a ton of INT To-Dos, but Cleared them before leveling up, they're not going to be considered.
  2. It's counter-intuitive. You would expect the attribute you worked on the most (things you actually clicked) to get "trained" for leveling up, not just whatever you've thrown in your list.
  3. Related to #2, it's backward with respect to Habits. If I've been punching my "Read a chapter of a book" Habit regularly, such that it's green or blue, it's going to count less for attribute training rather than more.
  4. It makes the same mistake that Re-Roll did, in that it counts Rewards as tasks like anything else, and looks at their price as a value. If you've got any custom Rewards at all, you're likely to blow the roof off your STR count by default.

So @lefnire, did I read it right?

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