Proper reward processing & updating user-stats on vote save

This commit is contained in:
Tyler Renelle
2012-02-11 02:26:09 -05:00
parent d39dae354b
commit e2429632a1
9 changed files with 83 additions and 57 deletions
@@ -15,8 +15,11 @@ class HabitTracker.Models.User extends Backbone.Model
@set({ lvl: @get('lvl') + 1 })
# also add money. Only take away money if it was a mistake (aka, a checkbox)
if delta>0 or !habit.isHabit()
if delta>0 or (habit.isDaily() or habit.isTodo())
@set({money: @get('money')+delta})
# if buying an item, deduct cost
if habit.isReward()
@set({money: @get('money')-habit.get('score')})
@trigger('updatedStats')