remove "+ undefined" for (-)habit. Workaround, need to find why

stats.gp is being set from (-)habit at all
This commit is contained in:
Tyler Renelle 2013-05-04 12:10:34 +01:00
parent 54ef864458
commit b468f052fd
3 changed files with 15 additions and 7 deletions

View file

@ -48,12 +48,15 @@ module.exports.hpModifier = (value, armorDef, helmDef, shieldDef, level, priorit
Future use
{priority} user-defined priority multiplier
###
module.exports.gpModifier = (value, modifier, priority='!', streak=0, model) ->
streakBonus = streak / 100 + 1 # eg, 1-day streak is 1.1, 2-day is 1.2, etc
module.exports.gpModifier = (value, modifier, priority='!', streak, model) ->
val = value * modifier * priorityValue(priority)
afterStreak = val * streakBonus
model.set('_streakBonus', afterStreak - val) if (model and streak and (val > 0)) # can we do this without model? just global emit?
return afterStreak
if streak and model
streakBonus = streak / 100 + 1 # eg, 1-day streak is 1.1, 2-day is 1.2, etc
afterStreak = val * streakBonus
model.set('_streakBonus', afterStreak - val) if (val > 0) # can we do this without model? just global emit?
return afterStreak
else
return val
###
Calculates the next task.value based on direction

View file

@ -173,12 +173,14 @@ setupGrowlNotifications = (model) ->
user.on 'set', 'stats.gp', (captures, args) ->
money = captures - args
return unless !!money # why is this happening? gotta find where stats.gp is being set from (-)habit
sign = if money < 0 then '-' else '+'
statsNotification "#{sign} #{showCoins(money)}", 'gp'
# Append Bonus
bonus = model.get('_streakBonus')
if money > 0 and bonus
debugger
if (money > 0) and !!bonus
bonus = 0.01 if bonus < 0.01
statsNotification "+ #{showCoins(bonus)} Streak Bonus!"
model.del('_streakBonus')

View file

@ -119,7 +119,10 @@ score = (model, taskId, direction, times, batch, cron) ->
level = user.get('stats.lvl')
weaponStrength = items.items.weapon[user.get('items.weapon')].strength
exp += algos.expModifier(delta,weaponStrength,level, priority) / 2 # / 2 hack for now bcause people leveling too fast
gp += algos.gpModifier(delta, 1, priority, streak, model)
if streak
gp += algos.gpModifier(delta, 1, priority, streak, model)
else
gp += algos.gpModifier(delta, 1, priority)
subtractPoints = ->
level = user.get('stats.lvl')