user.ops functions can now send multiple messages at once. Clearer messages are sent when equipping/unequipping two-handed weapons.

This commit is contained in:
Oliver Eyton-Williams
2015-12-01 18:24:23 +01:00
parent ee7bfece06
commit da35eb6067
2 changed files with 26 additions and 12 deletions

View File

@@ -2065,21 +2065,31 @@ api.wrap = function(user, main) {
return item; return item;
}, },
handleTwoHanded: function(item, type, req) { handleTwoHanded: function(item, type, req) {
var message, ref, weapon; var message, ref, weapon, shield;
if (type == null) { if (type == null) {
type = 'equipped'; type = 'equipped';
} }
if (item.type === "shield" && ((ref = (weapon = content.gear.flat[user.items.gear[type].weapon])) != null ? ref.twoHanded : void 0)) { if (item.type === "shield" && ((ref = (weapon = content.gear.flat[user.items.gear[type].weapon])) != null ? ref.twoHanded : void 0)) {
user.items.gear[type].weapon = 'weapon_base_0'; user.items.gear[type].weapon = 'weapon_base_0';
message = i18n.t('messageTwoHandled', { message = [i18n.t('messageTwoHandled', {
gearText: weapon.text(req.language) gearText: weapon.text(req.language)
}, req.language); }, req.language)];
message.push(i18n.t('messageUnEquipped', {
itemText: weapon.text(req.language)
}, req.language));
} }
if (item.twoHanded) { if (item.twoHanded) {
user.items.gear[type].shield = "shield_base_0"; shield = content.gear.flat[user.items.gear.equipped.shield];
message = i18n.t('messageTwoHandled', { if(shield && user.items.gear.equipped.shield != "shield_base_0"){
gearText: item.text(req.language) user.items.gear[type].shield = "shield_base_0";
}, req.language);
message = [i18n.t('messageTwoHandled', {
gearText: item.text(req.language)
}, req.language)];
message.push(i18n.t('messageUnEquipped', {
itemText: shield.text(req.language)
}, req.language));
}
} }
return message; return message;
}, },

View File

@@ -107,10 +107,14 @@ angular.module('habitrpg')
if (err) { if (err) {
var message = err.code ? err.message : err; var message = err.code ? err.message : err;
console.log(message); console.log(message);
if (MOBILE_APP) Notification.push({type:'text',text:message}); if (typeof message === 'string')
else Notification.text(message); message = [message];
// In the case of 200s, they're friendly alert messages like "Your pet has hatched!" - still send the op _.each(message, (msg) => {
if ((err.code && err.code >= 400) || !err.code) return; if (MOBILE_APP) Notification.push({type:'text',text:msg});
else Notification.text(msg);
// In the case of 200s, they're friendly alert messages like "Your pet has hatched!" - still send the op
if ((err.code && err.code >= 400) || !err.code) return;
});
} }
userServices.log({op:k, params: req.params, query:req.query, body:req.body}); userServices.log({op:k, params: req.params, query:req.query, body:req.body});
}); });