mirror of
https://github.com/sudoxnym/habitica.git
synced 2026-07-31 23:11:15 +00:00
emit the streak bonus so we can display the growl notification. I'm
not sure I like this approach, because (1) we can't set growl order, streak bonus comes first, and (2) I want to keep model-aware code to a minimum so we can weed out the mem leak
This commit is contained in:
parent
5b6cf5c039
commit
381fb48c03
3 changed files with 12 additions and 3 deletions
|
|
@ -48,9 +48,12 @@ module.exports.hpModifier = (value, armorDef, helmDef, shieldDef, level, priorit
|
|||
Future use
|
||||
{priority} user-defined priority multiplier
|
||||
###
|
||||
module.exports.gpModifier = (value, modifier, priority='!', streak=0) ->
|
||||
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
|
||||
return value * modifier * priorityValue(priority) * streakBonus
|
||||
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
|
||||
|
||||
###
|
||||
Calculates the next task.value based on direction
|
||||
|
|
|
|||
|
|
@ -157,6 +157,12 @@ setupGrowlNotifications = (model) ->
|
|||
else if num > 0
|
||||
statsNotification "<i class='icon-star'></i> + #{rounded} XP", 'xp'
|
||||
|
||||
model.on 'set', '_streakBonus', (captures, args) ->
|
||||
absolute = Math.abs(captures)
|
||||
gold = Math.floor(absolute)
|
||||
silver = Math.floor((absolute-gold)*100)
|
||||
statsNotification "+ #{gold} <i class='icon-gold'></i> #{silver} <i class='icon-silver'></i> - Streak Bonus!", 'gp'
|
||||
|
||||
user.on 'set', 'stats.gp', (captures, args) ->
|
||||
num = captures - args
|
||||
absolute = Math.abs(num)
|
||||
|
|
|
|||
|
|
@ -119,7 +119,7 @@ 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, taskObj.streak)
|
||||
gp += algos.gpModifier(delta, 1, priority, taskObj.streak, model)
|
||||
|
||||
subtractPoints = ->
|
||||
level = user.get('stats.lvl')
|
||||
|
|
|
|||
Loading…
Reference in a new issue