2013-08-25 01:06:37 +00:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
|
|
habitrpg.controller('NotificationCtrl',
|
2013-09-17 15:43:05 +00:00
|
|
|
['$scope', '$rootScope', 'User', 'Guide', 'Notification', function ($scope, $rootScope, User, Guide, Notification) {
|
2013-09-10 22:06:16 +00:00
|
|
|
|
2013-09-17 15:43:05 +00:00
|
|
|
$rootScope.$watch('user.stats.hp', function(after, before) {
|
|
|
|
|
if (after == before) return;
|
|
|
|
|
Notification.hp(after - before, 'hp');
|
|
|
|
|
});
|
2013-08-28 20:48:27 +00:00
|
|
|
|
2013-09-17 15:43:05 +00:00
|
|
|
$rootScope.$watch('user.stats.exp', function(after, before) {
|
|
|
|
|
if (after == before) return;
|
|
|
|
|
Notification.exp(after - before);
|
|
|
|
|
});
|
2013-08-28 20:48:27 +00:00
|
|
|
|
2013-09-17 15:43:05 +00:00
|
|
|
$rootScope.$watch('user.stats.gp', function(after, before) {
|
|
|
|
|
if (after == before) return;
|
|
|
|
|
var money = after - before;
|
|
|
|
|
Notification.gp(money);
|
2013-08-28 20:48:27 +00:00
|
|
|
|
2013-09-17 15:43:05 +00:00
|
|
|
//Append Bonus
|
2013-09-17 16:52:51 +00:00
|
|
|
var bonus = User.user._tmp.streakBonus;
|
2013-08-28 20:48:27 +00:00
|
|
|
|
2013-09-17 15:43:05 +00:00
|
|
|
if ((money > 0) && !!bonus) {
|
2013-09-17 16:52:51 +00:00
|
|
|
if (bonus < 0.01) bonus = 0.01;
|
2013-09-17 15:43:05 +00:00
|
|
|
Notification.text("+ " + Notification.coins(bonus) + " Streak Bonus!");
|
2013-10-27 12:44:04 +00:00
|
|
|
delete User.user._tmp.streakBonus;
|
2013-09-17 15:43:05 +00:00
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
2013-09-17 16:16:16 +00:00
|
|
|
$rootScope.$watch('user._tmp.drop', function(after, before){
|
|
|
|
|
if (after == before || !after) return;
|
|
|
|
|
$rootScope.modals.drop = true;
|
|
|
|
|
});
|
|
|
|
|
|
2013-10-23 15:57:02 +00:00
|
|
|
$rootScope.$watch('user.achievements.streak', function(after, before){
|
|
|
|
|
if(after == before || after < before) return;
|
|
|
|
|
$rootScope.modals.achievements.streak = true;
|
|
|
|
|
});
|
|
|
|
|
|
2013-10-27 11:11:59 +00:00
|
|
|
$rootScope.$watch('user.achievements.ultimateGear', function(after, before) {
|
|
|
|
|
if (after === before || after !== true) return;
|
|
|
|
|
$rootScope.modals.achievements.ultimateGear = true;
|
|
|
|
|
});
|
|
|
|
|
|
2013-09-17 15:43:05 +00:00
|
|
|
/*_.each(['weapon', 'head', 'chest', 'shield'], function(watched){
|
|
|
|
|
$rootScope.$watch('user.items.' + watched, function(before, after){
|
2013-08-28 20:48:27 +00:00
|
|
|
if (after == before) return;
|
2013-09-17 15:43:05 +00:00
|
|
|
if (+after < +before) {
|
|
|
|
|
Notification.death();
|
|
|
|
|
//don't want to day "lost a head"
|
|
|
|
|
if (watched === 'head') watched = 'helm';
|
|
|
|
|
Notification.text('Lost GP, 1 LVL, ' + watched);
|
2013-08-28 20:48:27 +00:00
|
|
|
}
|
2013-09-17 15:43:05 +00:00
|
|
|
})
|
|
|
|
|
});*/
|
|
|
|
|
|
|
|
|
|
$rootScope.$watch('user.stats.lvl', function(after, before) {
|
|
|
|
|
if (after == before) return;
|
|
|
|
|
if (after > before) {
|
|
|
|
|
Notification.lvl();
|
|
|
|
|
}
|
|
|
|
|
});
|
2013-10-30 18:29:46 +00:00
|
|
|
|
|
|
|
|
$rootScope.$on('responseError', function(ev, error){
|
|
|
|
|
Notification.error(error);
|
|
|
|
|
});
|
2013-08-25 01:06:37 +00:00
|
|
|
}
|
|
|
|
|
]);
|