From 2a49b640239a987faaa5e8958e9e11e612b9c4ab Mon Sep 17 00:00:00 2001 From: Philip How Date: Thu, 28 Feb 2013 23:09:12 +0000 Subject: [PATCH] Better notifications --- src/app/browser.coffee | 34 ++++++++++++++++++++++------------ styles/app/alerts.styl | 15 +++++++++++---- 2 files changed, 33 insertions(+), 16 deletions(-) diff --git a/src/app/browser.coffee b/src/app/browser.coffee index 2830fefd48..5becd6bcc0 100644 --- a/src/app/browser.coffee +++ b/src/app/browser.coffee @@ -6,7 +6,7 @@ module.exports.restoreRefs = restoreRefs = (model) -> model.fn '_tnl', '_user.stats.lvl', (lvl) -> # see https://github.com/lefnire/habitrpg/issues/4 # also update in scoring.coffee. TODO create a function accessible in both locations - (lvl*100)/5 + 10*Math.pow(lvl,2)+(lvl*10)+80 #refLists _.each ['habit', 'daily', 'todo', 'reward'], (type) -> @@ -193,20 +193,30 @@ setupGrowlNotifications = (model) -> num = captures - args rounded = Math.abs(num.toFixed(1)) if num < 0 - statsNotification " -#{rounded} HP", 'hp' # lost hp from purchase + statsNotification " - #{rounded} HP", 'hp' # lost hp from purchase + else if num > 0 + statsNotification " + #{rounded} HP", 'hp' # gained hp from potion/level? + + user.on 'set', 'stats.exp', (captures, args) -> + num = captures - args + rounded = Math.abs(num.toFixed(1)) + if num < 0 + statsNotification " - #{rounded} XP", 'xp' + else if num > 0 + statsNotification " + #{rounded} XP", 'xp' user.on 'set', 'stats.gp', (captures, args) -> num = captures - args - rounded = Math.abs(num.toFixed(1)) - # made purchase - if num < 0 - # FIXME use 'warning' when unchecking an accidently completed daily/todo, and notify of exp too - statsNotification " -#{rounded} GP", 'gp' - # gained gp (and thereby exp) - else if num > 0 - num = Math.abs(num) - statsNotification " +#{rounded} XP", 'xp' - statsNotification " +#{rounded} GP", 'gp' + absolute = Math.abs(num) + gold = Math.floor(absolute) + silver = Math.floor((absolute-gold)*100) + sign = if num < 0 then '-' else '+' + if gold and silver > 0 + statsNotification "#{sign} #{gold} #{silver} ", 'gp' + else if gold > 0 + statsNotification "#{sign} #{gold} ", 'gp' + else if silver > 0 + statsNotification "#{sign} #{silver} ", 'gp' user.on 'set', 'stats.lvl', (captures, args) -> if captures > args diff --git a/styles/app/alerts.styl b/styles/app/alerts.styl index 8ecbd0e45e..38e411f480 100644 --- a/styles/app/alerts.styl +++ b/styles/app/alerts.styl @@ -34,9 +34,16 @@ borderDarken = 20% // alert icons -.icon-gp - background: url("img/sprites/shop_sprites.png") no-repeat - background-size: 400px - background-position: -386px 0 +.icon-gold + background: url("img/coin_single_gold.png") no-repeat + background-position: center center + background-size: 18px + width: 14px + height: 14px + +.icon-silver + background: url("img/coin_single_silver.png") no-repeat + background-position: center center + background-size: 18px width: 14px height: 14px \ No newline at end of file