Apply experience deduction logic to money

This commit is contained in:
Tyler Renelle
2012-02-23 18:23:54 -05:00
parent 443e422f94
commit 4d97029ab9
3 changed files with 13 additions and 3 deletions
@@ -14,9 +14,15 @@ class HabitTracker.Models.User extends Backbone.Model
@set({ exp: @get('exp') - @tnl() })
@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.isDaily() or habit.isTodo())
@set({money: @get('money')+delta})
# @deprecated also add money. Only take away money if it was a mistake (aka, a checkbox)
# if delta>0 or (habit.isDaily() or habit.isTodo())
# @set({money: @get('money')+delta})
# apply same logic to money
@set({money: @get('money')+delta})
if @get('money') < 0 then @set({money: 0})
# if buying an item, deduct cost
if habit.isReward()
@set({money: @get('money')-habit.get('score')})