diff --git a/lib/app/scoring.js b/lib/app/scoring.js
index e61e65ebaf..040d22de4d 100644
--- a/lib/app/scoring.js
+++ b/lib/app/scoring.js
@@ -1,8 +1,20 @@
// Generated by CoffeeScript 1.3.3
-var content, expModifier, hpModifier, score, updateStats;
+var content, expModifier, hpModifier, score, statsNotification, updateStats;
content = require('./content');
+statsNotification = function(html, type, number) {
+ return $.bootstrapGrowl(html, {
+ type: type,
+ top_offset: 20,
+ align: 'center',
+ width: 250,
+ delay: 4000,
+ allow_dismiss: true,
+ stackup_spacing: 10
+ });
+};
+
expModifier = function(user, value) {
var dmg, modified;
dmg = user.get('items.weapon') * .03;
@@ -33,8 +45,9 @@ updateStats = function(user, stats) {
if (stats.exp >= tnl) {
stats.exp -= tnl;
user.set('stats.lvl', user.get('stats.lvl') + 1);
+ statsNotification(' Level Up!', 'info');
}
- if (!user.get('items.itemsEnabled') && stats.exp >= 50) {
+ if (!user.get('items.itemsEnabled') && stats.exp >= 15) {
user.set('items.itemsEnabled', true);
$('ul.items').popover({
title: content.items.unlockedMessage.title,
@@ -56,7 +69,7 @@ updateStats = function(user, stats) {
};
module.exports.score = score = function(spec) {
- var adjustvalue, cron, delta, direction, exp, hp, lvl, modified, money, sign, task, type, user, value, _ref, _ref1, _ref2;
+ var adjustvalue, cron, delta, diff, direction, exp, hp, lvl, modified, money, num, sign, task, type, user, value, _ref, _ref1, _ref2;
if (spec == null) {
spec = {
user: null,
@@ -69,14 +82,14 @@ module.exports.score = score = function(spec) {
if (!task) {
_ref1 = [user.get('stats.money'), user.get('stats.hp'), user.get('stats.exp')], money = _ref1[0], hp = _ref1[1], exp = _ref1[2];
if (direction === "up") {
- money += 1;
- exp += expModifier(user, 1);
+ modified = expModifier(user, 1);
+ money += modified;
+ exp += modified;
+ statsNotification("Exp,GP +" + (modified.toFixed(2)), 'success');
} else {
modified = hpModifier(user, 1);
hp -= modified;
- console.log({
- modified: modified
- });
+ statsNotification("HP " + (modified.toFixed(2)), 'error');
}
updateStats(user, {
hp: hp,
@@ -108,16 +121,24 @@ module.exports.score = score = function(spec) {
_ref2 = [user.get('stats.money'), user.get('stats.hp'), user.get('stats.exp'), user.get('stats.lvl')], money = _ref2[0], hp = _ref2[1], exp = _ref2[2], lvl = _ref2[3];
if (type === 'reward') {
money -= task.get('value');
+ num = task.get('value').toFixed(2);
+ statsNotification("GP -" + num, 'success');
if (money < 0) {
- hp += money;
+ diff = hp + money;
+ hp = diff;
+ statsNotification("HP -" + (diff.toFixed(2)), 'error');
money = 0;
}
}
if ((delta > 0 || (type === 'daily' || type === 'todo')) && !cron) {
- exp += expModifier(user, delta);
- money += delta;
+ modified = expModifier(user, delta);
+ exp += modified;
+ money += modified;
+ statsNotification("Exp,GP +" + (modified.toFixed(2)), 'success');
} else if (type !== 'reward' && type !== 'todo') {
- hp += hpModifier(user, delta);
+ modified = hpModifier(user, delta);
+ hp += modified;
+ statsNotification("HP " + (modified.toFixed(2)), 'error');
}
updateStats(user, {
hp: hp,
diff --git a/public/js/jquery.bootstrap-growl.min.js b/public/js/jquery.bootstrap-growl.min.js
new file mode 100644
index 0000000000..1636de1e80
--- /dev/null
+++ b/public/js/jquery.bootstrap-growl.min.js
@@ -0,0 +1,2 @@
+/* https://github.com/ifightcrime/bootstrap-growl */
+(function(e){e.bootstrapGrowl=function(t,n){var n=e.extend({},e.bootstrapGrowl.default_options,n),r=e("
");r.attr("class","bootstrap-growl alert"),n.type&&r.addClass("alert-"+n.type),n.allow_dismiss&&r.append('
×'),r.append(t);var i=n.top_offset,s=e(".bootstrap-growl","body");e.each(s,function(){i=i+e(this).outerHeight()+n.stackup_spacing}),r.css({position:"absolute",top:i+"px",border:"1px solid "+r.css("color"),margin:0,"z-index":"999",display:"none"}),n.width!=="auto"&&r.css("width",n.width+"px"),e("body").append(r);switch(n.align){case"center":r.css({left:"50%","margin-left":"-"+r.outerWidth()/2+"px"});break;case"left":r.css("left","20px");break;default:r.css("right","20px")}r.fadeIn().delay(n.delay).fadeOut("slow",function(){e(this).remove()})},e.bootstrapGrowl.default_options={type:null,top_offset:20,align:"right",width:250,delay:4e3,allow_dismiss:!0,stackup_spacing:10}})(jQuery);
diff --git a/src/app/scoring.coffee b/src/app/scoring.coffee
index 75ed58e697..ed4308e9dd 100644
--- a/src/app/scoring.coffee
+++ b/src/app/scoring.coffee
@@ -1,5 +1,16 @@
content = require('./content')
+statsNotification = (html, type, number) ->
+ $.bootstrapGrowl html, {
+ type: type # (null, 'info', 'error', 'success')
+ top_offset: 20
+ align: 'center' # ('left', 'right', or 'center')
+ width: 250 # (integer, or 'auto')
+ delay: 4000
+ allow_dismiss: true
+ stackup_spacing: 10 # spacing between consecutive stacecked growls.
+ }
+
# Calculates Exp modification based on weapon & lvl
expModifier = (user, value) ->
dmg = user.get('items.weapon') * .03 # each new weapon adds an additional 3% experience
@@ -29,7 +40,8 @@ updateStats = (user, stats) ->
if stats.exp >= tnl
stats.exp -= tnl
user.set 'stats.lvl', user.get('stats.lvl') + 1
- if !user.get('items.itemsEnabled') and stats.exp >=50
+ statsNotification('
Level Up!', 'info')
+ if !user.get('items.itemsEnabled') and stats.exp >=15
user.set 'items.itemsEnabled', true
$('ul.items').popover
title: content.items.unlockedMessage.title
@@ -56,12 +68,14 @@ module.exports.score = score = (spec = {user:null, task:null, direction:null, cr
if !task
[money, hp, exp] = [user.get('stats.money'), user.get('stats.hp'), user.get('stats.exp')]
if (direction == "up")
- money += 1
- exp += expModifier(user, 1)
+ modified = expModifier(user, 1)
+ money += modified
+ exp += modified
+ statsNotification "Exp,GP +#{modified.toFixed(2)}", 'success'
else
modified = hpModifier(user, 1)
hp -= modified
- console.log {modified:modified}
+ statsNotification "HP #{modified.toFixed(2)}", 'error'
updateStats(user, {hp: hp, exp: exp, money: money})
return
@@ -92,19 +106,27 @@ module.exports.score = score = (spec = {user:null, task:null, direction:null, cr
if type == 'reward'
# purchase item
money -= task.get('value')
+ num = task.get('value').toFixed(2)
+ statsNotification "GP -#{num}", 'success'
# if too expensive, reduce health & zero money
if money < 0
- hp += money # hp - money difference
+ diff = hp + money # hp - money difference
+ hp = diff
+ statsNotification "HP -#{diff.toFixed(2)}", 'error'
money = 0
# Add points to exp & money if positive delta
# Only take away mony if it was a mistake (aka, a checkbox)
if (delta > 0 or ( type in ['daily', 'todo'])) and !cron
- exp += expModifier(user, delta)
- money += delta
+ modified = expModifier(user, delta)
+ exp += modified
+ money += modified
+ statsNotification "Exp,GP +#{modified.toFixed(2)}", 'success'
# Deduct from health (rewards case handled above)
else unless type in ['reward', 'todo']
- hp += hpModifier(user, delta)
+ modified = hpModifier(user, delta)
+ hp += modified
+ statsNotification "HP #{modified.toFixed(2)}", 'error'
updateStats(user, {hp: hp, exp: exp, money: money})
diff --git a/views/app/index.html b/views/app/index.html
index 3113d0ff04..fd43894b43 100644
--- a/views/app/index.html
+++ b/views/app/index.html
@@ -54,10 +54,7 @@
-
+
@@ -296,6 +293,7 @@
+