feat(Armoire): Improved counter

The popover counter of remaining Equipment in the Armoire now counts down immediately instead of requiring a browser refresh. A modal announces when the last item has been found. Also includes several fixes to the Ultimate Gear migration.
This commit is contained in:
Sabe Jones
2015-06-04 15:45:55 -05:00
parent 09d32390f9
commit 20859b83ef
10 changed files with 51 additions and 42 deletions

View File

@@ -3,8 +3,9 @@
"potionNotes": "Recover 15 Health (Instant Use)",
"armoireText": "Enchanted Armoire",
"armoireNotesFull": "Open the Armoire to randomly receive special equipment, Experience, or food!",
"armoireNotesEmpty": "The Enchanted Armoire will have new Equipment every month. Until then, keep clicking for Experience and Food!",
"armoireNotesFull": "Open the Armoire to randomly receive special Equipment, Experience, or food! Equipment pieces remaining: ",
"armoireLastItem": "You've found the last piece of rare Equipment in the Enchanted Armoire.",
"armoireNotesEmpty": "The Armoire will have new Equipment every month. Until then, keep clicking for Experience and Food!",
"dropEggWolfText": "Wolf",
"dropEggWolfAdjective": "loyal",

View File

@@ -21,7 +21,7 @@
"messageDropEgg": "You've found a <%= dropText %> Egg! <%= dropNotes %>",
"messageDropPotion": "You've found a <%= dropText %> Hatching Potion! <%= dropNotes %>",
"messageFoundQuest": "You've found the quest \"<%= questText %>\"!",
"armoireEquipment": "<%= image %> You found a piece of rare Equipment in the Armoire: <%= dropText %>! Awesome! There are <%= count %> pieces left.",
"armoireEquipment": "<%= image %> You found a piece of rare Equipment in the Armoire: <%= dropText %>! Awesome!",
"armoireFood": "<%= image %> You rummage in the Armoire and find <%= dropArticle %><%= dropText %>. What's that doing in here?",
"armoireExp": "You wrestle with the Armoire and gain Experience. Take that!"
}

View File

@@ -363,8 +363,8 @@ api.countTriad = (pets) ->
count3
api.countArmoire = (gear) ->
count4 = _.size(_.filter(content.gear.flat, ((i)->i.klass is 'armoire' and !gear[i.key])))
count4
count = _.size(_.filter(content.gear.flat, ((i)->i.klass is 'armoire' and !gear[i.key])))
count
###
------------------------------------------------------
@@ -856,7 +856,8 @@ api.wrap = (user, main=true) ->
drop = user.fns.randomVal(eligibleEquipment)
user.items.gear.owned[drop.key] = true
user.flags.armoireOpened = true
message = i18n.t('armoireEquipment', {image: '<span class="shop_'+drop.key+' pull-left"></span>', dropText: drop.text(req.language), count: api.countArmoire(user.items.gear.owned)}, req.language)
message = i18n.t('armoireEquipment', {image: '<span class="shop_'+drop.key+' pull-left"></span>', dropText: drop.text(req.language)}, req.language)
if api.countArmoire(user.items.gear.owned) is 0 then user.flags.armoireEmpty = true
else if (!_.isEmpty(eligibleEquipment) and armoireResult < .85) or armoireResult < .6
drop = user.fns.randomVal _.where(content.food, {canDrop:true})
user.items.food[drop.key] ?= 0

View File

@@ -17,47 +17,35 @@ var _ = require('lodash');
var dbUsers = mongo.db(dbserver + '/habitrpg?auto_reconnect').collection('users');
var fields = {
'achievements.ultimateGearSets':1
};
var query = {
'items.gear.owned.weapon_wizard_6':true,
'items.gear.owned.armor_wizard_5':true,
'items.gear.owned.head_wizard_5':true
};
var fields = {
'achievements.ultimateGearSets.wizard':true
'items.gear.owned.weapon_wizard_6': {$exists: true},
'items.gear.owned.armor_wizard_5': {$exists: true},
'items.gear.owned.head_wizard_5': {$exists: true}
};
/* var query = {
'items.gear.owned.weapon_warrior_6':true,
'items.gear.owned.armor_warrior_5':true,
'items.gear.owned.head_warrior_5':true,
'items.gear.owned.shield_warrior_5':true
};
var fields = {
'achievements.ultimateGearSets.warrior':true
'items.gear.owned.weapon_warrior_6': {$exists: true},
'items.gear.owned.armor_warrior_5': {$exists: true},
'items.gear.owned.head_warrior_5': {$exists: true},
'items.gear.owned.shield_warrior_5': {$exists: true}
}; */
/* var query = {
'items.gear.owned.weapon_healer_6':true,
'items.gear.owned.armor_healer_5':true,
'items.gear.owned.head_healer_5':true,
'items.gear.owned.shield_healer_5':true
};
var fields = {
'achievements.ultimateGearSets.healer':true
'items.gear.owned.weapon_healer_6': {$exists: true},
'items.gear.owned.armor_healer_5': {$exists: true},
'items.gear.owned.head_healer_5': {$exists: true},
'items.gear.owned.shield_healer_5': {$exists: true}
}; */
/* var query = {
'items.gear.owned.weapon_rogue_6':true,
'items.gear.owned.armor_rogue_5':true,
'items.gear.owned.head_rogue_5':true,
'items.gear.owned.shield_rogue_6':true
};
var fields = {
'achievements.ultimateGearSets.rogue':true
'items.gear.owned.weapon_rogue_6': {$exists: true},
'items.gear.owned.armor_rogue_5': {$exists: true},
'items.gear.owned.head_rogue_5': {$exists: true},
'items.gear.owned.shield_rogue_6': {$exists: true}
}; */
console.warn('Updating users...');
@@ -71,7 +59,7 @@ dbUsers.findEach(query, fields, {batchSize:250}, function(err, user) {
}
count++;
var set = {'migration':migrationName, 'achievements.ultimateGearSets':{'wizard':true} }; // Change per class
var set = {'migration':migrationName, 'achievements.ultimateGearSets.wizard':true}; // Change per class
dbUsers.update({_id:user._id}, {$set:set});
if (count%progressCount == 0) console.warn(count + ' ' + user._id);

View File

@@ -106,6 +106,11 @@ habitrpg.controller('NotificationCtrl',
$rootScope.openModal('achievements/ultimateGear');
}, true);
$rootScope.$watch('user.flags.armoireEmpty', function(after,before){
if (before == undefined || after == before || after == false) return;
$rootScope.openModal('armoireEmpty');
});
$rootScope.$watch('user.achievements.rebirths', function(after, before){
if(after === before) return;
$rootScope.openModal('achievements/rebirth');

View File

@@ -34,7 +34,6 @@ habitrpg.controller("RootCtrl", ['$scope', '$rootScope', '$location', 'User', '$
$rootScope.Groups = Groups;
$rootScope.toJson = angular.toJson;
$rootScope.Payments = Payments;
$rootScope.armoireCount = Shared.countArmoire(User.user.items.gear.owned);
// Angular UI Router
$rootScope.$state = $state;

View File

@@ -4,6 +4,9 @@ habitrpg.controller("TasksCtrl", ['$scope', '$rootScope', '$location', 'User','N
function($scope, $rootScope, $location, User, Notification, $http, ApiUrl, $timeout, Shared, Guide) {
$scope.obj = User.user; // used for task-lists
$scope.user = User.user;
$scope.armoireCount = function(gear) {
return Shared.countArmoire(gear);
};
$scope.score = function(task, direction) {
switch (task.type) {

View File

@@ -159,7 +159,8 @@ var UserSchema = new Schema({
cronCount: {type:Number, 'default':0},
welcomed: {type: Boolean, 'default': false},
armoireEnabled: {type: Boolean, 'default': false},
armoireOpened: {type: Boolean, 'default': false}
armoireOpened: {type: Boolean, 'default': false},
armoireEmpty: {type: Boolean, 'default': false}
},
history: {
exp: Array, // [{date: Date, value: Number}], // big peformance issues if these are defined

View File

@@ -51,3 +51,14 @@ script(type='text/ng-template', id='modals/pet-key.html')
span(ng-if='!user.achievements.triadBingo')
| : 6&nbsp;
span.Pet_Currency_Gem1x.inline-gems
script(type='text/ng-template', id='modals/armoireEmpty.html')
.modal-header
.shop_armoire.pull-right
h4=env.t('armoireText')
.modal-body
p=env.t('armoireLastItem')
br
p=env.t('armoireNotesEmpty')
.modal-footer
button.btn.btn-default(ng-click='$close()')=env.t('close')

View File

@@ -126,7 +126,7 @@ script(id='templates/habitrpg-tasks.html', type="text/ng-template")
// Static Rewards
ul.items.rewards(ng-if='main && list.type=="reward"')
li.task.reward-item(ng-repeat='item in itemStore',popover-trigger='mouseenter', popover-placement='top', popover='{{item.key == "armoire" && armoireCount > 0 ? env.t("armoireNotesFull") : item.notes()}}')
li.task.reward-item(ng-repeat='item in itemStore',popover-trigger='mouseenter', popover-placement='top', popover='{{item.key == "armoire" && !user.flags.armoireEmpty ? env.t("armoireNotesFull") + armoireCount(user.items.gear.owned) : item.notes()}}')
// right-hand side control buttons
.task-meta-controls
span.task-notes