From b468f052fd798faca22ddcd1b2c55c1f563836e5 Mon Sep 17 00:00:00 2001 From: Tyler Renelle Date: Sat, 4 May 2013 12:10:34 +0100 Subject: [PATCH] remove "+ undefined" for (-)habit. Workaround, need to find why stats.gp is being set from (-)habit at all --- src/app/algos.coffee | 13 ++++++++----- src/app/browser.coffee | 4 +++- src/app/scoring.coffee | 5 ++++- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/src/app/algos.coffee b/src/app/algos.coffee index 6ec2c97907..1e9ab67cdf 100644 --- a/src/app/algos.coffee +++ b/src/app/algos.coffee @@ -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 diff --git a/src/app/browser.coffee b/src/app/browser.coffee index 6c0bbb49dc..89368fd4ee 100644 --- a/src/app/browser.coffee +++ b/src/app/browser.coffee @@ -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') diff --git a/src/app/scoring.coffee b/src/app/scoring.coffee index 83ff56bd8f..8046d64c6d 100644 --- a/src/app/scoring.coffee +++ b/src/app/scoring.coffee @@ -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')