diff --git a/migrations/20131214_classes.coffee b/migrations/20131214_classes.coffee index d54ba85595..b1b5f31692 100644 --- a/migrations/20131214_classes.coffee +++ b/migrations/20131214_classes.coffee @@ -13,7 +13,7 @@ users = mongo.db('localhost:27017/habitrpg?auto_reconnect').collection('users') users.count query, (err, count) -> console.log {count} return console.error(err) if err - users.findEach query, {batchSize:10}, (err, user) -> + users.findEach query, {batchSize:500}, (err, user) -> unless user then err = 'Blank user';count-- return console.log(err) if err @@ -64,19 +64,21 @@ users.count query, (err, count) -> costume: {} _.each {head: "showHelm", weapon: "showWeapon", shield: "showShield", armor: "showArmor"}, (show, type) -> - user.items[type] = if Math.abs(user.items[type]) > 10 then 0 else ~~user.items[type] - _.times user.items[type], (i) -> + user.items[type] = unless 0 < ~~user.items[type] < 8 then 0 else ~~user.items[type] + _.times user.items[type]+1, (i) -> #+1 since 0 is significant item = if type is 'weapon' if i > 8 then 'weapon_warrior_6' else if i is 8 then "weapon_special_1" else if i is 7 then "weapon_special_0" + else "weapon_warrior_#{i}" else if i > 7 then "#{type}_warrior_5" else if i is 7 then "#{type}_special_1" else if i is 6 then "#{type}_special_0" + else if i is 0 then "#{type}_base_0" else "#{type}_warrior_#{i}" - gear.owned[item] = true + gear.owned[item] = true unless item is "#{type}_base_0" gear.equipped[type] = item # # TODO how to handle combo of wearing / hiding? diff --git a/public/js/controllers/notificationCtrl.js b/public/js/controllers/notificationCtrl.js index 4a87b7129b..03d418ffd0 100644 --- a/public/js/controllers/notificationCtrl.js +++ b/public/js/controllers/notificationCtrl.js @@ -5,16 +5,19 @@ habitrpg.controller('NotificationCtrl', $rootScope.$watch('user.stats.hp', function(after, before) { if (after == before) return; + if (User.user.stats.lvl == 0) return; Notification.hp(after - before, 'hp'); }); $rootScope.$watch('user.stats.exp', function(after, before) { if (after == before) return; + if (User.user.stats.lvl == 0) return; Notification.exp(after - before); }); $rootScope.$watch('user.stats.gp', function(after, before) { if (after == before) return; + if (User.user.stats.lvl == 0) return; var money = after - before; Notification.gp(money); diff --git a/public/js/services/notificationServices.js b/public/js/services/notificationServices.js index 5ac1b06d64..ff60c2e61c 100644 --- a/public/js/services/notificationServices.js +++ b/public/js/services/notificationServices.js @@ -2,7 +2,7 @@ Set up "+1 Exp", "Level Up", etc notifications */ angular.module("notificationServices", []) - .factory("Notification", ['User', function(User) { + .factory("Notification", [function() { function growl(html, type) { $.bootstrapGrowl(html, { ele: '#notification-area', @@ -45,16 +45,13 @@ angular.module("notificationServices", []) coins: coins, hp: function(val) { // don't show notifications if user dead - if (User.user.stats.lvl == 0) return; growl(" " + sign(val) + " " + round(val) + " HP", 'hp'); }, exp: function(val) { - if (User.user.stats.lvl == 0) return; if (val < -50) return; // don't show when they level up (resetting their exp) growl(" " + sign(val) + " " + round(val) + " XP", 'xp'); }, gp: function(val) { - if (User.user.stats.lvl == 0) return; growl(sign(val) + " " + coins(val), 'gp'); }, text: function(val){ diff --git a/public/js/services/userServices.js b/public/js/services/userServices.js index f588822c9e..a8ba0885ae 100644 --- a/public/js/services/userServices.js +++ b/public/js/services/userServices.js @@ -5,8 +5,8 @@ */ angular.module('userServices', []). - factory('User', ['$rootScope', '$http', '$location', '$window', 'API_URL', 'STORAGE_USER_ID', 'STORAGE_SETTINGS_ID', - function($rootScope, $http, $location, $window, API_URL, STORAGE_USER_ID, STORAGE_SETTINGS_ID) { + factory('User', ['$rootScope', '$http', '$location', '$window', 'API_URL', 'STORAGE_USER_ID', 'STORAGE_SETTINGS_ID', 'Notification', + function($rootScope, $http, $location, $window, API_URL, STORAGE_USER_ID, STORAGE_SETTINGS_ID, Notification) { var authenticated = false, defaultSettings = { auth: { apiId: '', apiToken: ''}, @@ -75,8 +75,7 @@ angular.module('userServices', []). _.each(user.ops, function(op,k){ user.ops[k] = _.partialRight(op, function(err, req){ if (err) { - //Notification.text(err.code ? err.message : err); // FIXME Circular dependency found: Notification <- User - alert(err.code ? err.message : err); + Notification.text(err.code ? err.message : err); // In the case of 200s, they're friendly alert messages like "You're pet has hatched!" - still send the op if ((err.code && err.code >= 400) || !err.code) return; } diff --git a/public/manifest.json b/public/manifest.json index a81693508a..5ec5938837 100644 --- a/public/manifest.json +++ b/public/manifest.json @@ -73,6 +73,7 @@ "bower_components/angular-loading-bar/build/loading-bar.js", "js/static.js", "js/services/userServices.js", + "js/services/notificationServices.js", "js/controllers/authCtrl.js" ], "css": [ diff --git a/views/options/social/tavern.jade b/views/options/social/tavern.jade index 048b3c36ff..075f0a3f41 100644 --- a/views/options/social/tavern.jade +++ b/views/options/social/tavern.jade @@ -13,10 +13,10 @@ .popover-content | Welcome to the Tavern! Stay a while and meet the locals. If you need to rest (going on vacation? sudden illness?), I'll set you up at the inn - Dailies won't hurt you while you're resting. div - button.btn.btn-large.btn-success(ng-class='{active: user.flags.rest}', ng-click='User.user.ops.sleep({})') - span(ng-show='user.flags.rest') Check Out of Inn - span(ng-hide='user.flags.rest') Rest in the Inn - .alert.alert-info(ng-show='user.flags.rest') + button.btn.btn-large.btn-success(ng-class='{active: user.preferences.sleep}', ng-click='User.user.ops.sleep({})') + span(ng-show='user.preferences.sleep') Check Out of Inn + span(ng-hide='user.preferences.sleep') Rest in the Inn + .alert.alert-info(ng-show='user.preferences.sleep') | Whilst resting, your dailies are saved and aren't affected by day turn-over. Whether you check out tomorrow or in a week's time, you'll continue in the same state as when you checked in. // Resources diff --git a/views/shared/header/avatar.jade b/views/shared/header/avatar.jade index b804b1138e..bb0239788e 100644 --- a/views/shared/header/avatar.jade +++ b/views/shared/header/avatar.jade @@ -37,7 +37,7 @@ figure.herobox(ng-click='spell ? castEnd(profile, "user", $event) : clickMember( span(ng-if='profile.items.currentMount', class='Mount_Head_{{profile.items.currentMount}}') // Resting - span(ng-class='{zzz:profile.flags.rest}') + span(ng-class='{zzz:profile.preferences.sleep}') // FIXME handle @minimal, this might have to be a directive span.current-pet(class='Pet-{{profile.items.currentPet}}', ng-show='profile.items.currentPet && !minimal') .avatar-level(ng-class='userLevelStyle(profile,"label")') diff --git a/views/shared/modals/classes.jade b/views/shared/modals/classes.jade index 7e9c740800..2b7ccf9716 100644 --- a/views/shared/modals/classes.jade +++ b/views/shared/modals/classes.jade @@ -44,7 +44,7 @@ span(class='hair_beard_{{user.preferences.hair.beard}}_{{user.preferences.hair.color}}') span(class='hair_mustache_{{user.preferences.hair.mustache}}_{{user.preferences.hair.color}}') span(class='head_rogue_5') - span(class='shield_rogue_5') + span(class='shield_rogue_6') span(class='weapon_rogue_6') .span3(ng-click='selectedClass = "healer"') h5 Healer