Reverted changes related to multiple messages and changed handleTwoHanded to send single, clearer, messages.

This commit is contained in:
Oliver Eyton-Williams
2015-12-02 13:13:45 +01:00
parent da35eb6067
commit dcd7cae312
4 changed files with 23 additions and 38 deletions

View File

@@ -19,7 +19,8 @@
"messageAlreadyPet": "You already have that pet. Try hatching a different combination!", "messageAlreadyPet": "You already have that pet. Try hatching a different combination!",
"messageHatched": "Your egg hatched! Visit your stable to equip your pet.", "messageHatched": "Your egg hatched! Visit your stable to equip your pet.",
"messageNotEnoughGold": "Not Enough Gold", "messageNotEnoughGold": "Not Enough Gold",
"messageTwoHandled": "<%= gearText %> is two handed", "messageTwoHandedEquip": "Wielding <%= twoHandedText%> takes two hands, so <%= offHandedText%> has been unequipped.",
"messageTwoHandedUnequip": "Wielding <%= twoHandedText%> takes two hands, so it was unequipped when you armed yourself with <%= offHandedText%>.",
"messageDropFood": "You've found <%= dropArticle %><%= dropText %>! <%= dropNotes %>", "messageDropFood": "You've found <%= dropArticle %><%= dropText %>! <%= dropNotes %>",
"messageDropEgg": "You've found a <%= dropText %> Egg! <%= dropNotes %>", "messageDropEgg": "You've found a <%= dropText %> Egg! <%= dropNotes %>",
"messageDropPotion": "You've found a <%= dropText %> Hatching Potion! <%= dropNotes %>", "messageDropPotion": "You've found a <%= dropText %> Hatching Potion! <%= dropNotes %>",

View File

@@ -2065,31 +2065,23 @@ api.wrap = function(user, main) {
return item; return item;
}, },
handleTwoHanded: function(item, type, req) { handleTwoHanded: function(item, type, req) {
var message, ref, weapon, shield; var message, currentWeapon, currentShield;
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)) { currentShield = content.gear.flat[user.items.gear[type].shield];
user.items.gear[type].weapon = 'weapon_base_0'; currentWeapon = content.gear.flat[user.items.gear[type].weapon];
message = [i18n.t('messageTwoHandled', {
gearText: weapon.text(req.language)
}, req.language)];
message.push(i18n.t('messageUnEquipped', {
itemText: weapon.text(req.language)
}, req.language));
}
if (item.twoHanded) {
shield = content.gear.flat[user.items.gear.equipped.shield];
if(shield && user.items.gear.equipped.shield != "shield_base_0"){
user.items.gear[type].shield = "shield_base_0";
message = [i18n.t('messageTwoHandled', { if (item.type === "shield" && (currentWeapon ? currentWeapon.twoHanded : false)) {
gearText: item.text(req.language) user.items.gear[type].weapon = 'weapon_base_0';
}, req.language)]; message = i18n.t('messageTwoHandedUnequip', {
message.push(i18n.t('messageUnEquipped', { twoHandedText: currentWeapon.text(req.language), offHandedText: item.text(req.language),
itemText: shield.text(req.language) }, req.language);
}, req.language)); } else if (item.twoHanded && (currentShield && user.items.gear[type].shield != "shield_base_0")) {
} user.items.gear[type].shield = "shield_base_0";
message = i18n.t('messageTwoHandedEquip', {
twoHandedText: item.text(req.language), offHandedText: currentShield.text(req.language),
}, req.language);
} }
return message; return message;
}, },

View File

@@ -106,15 +106,10 @@ angular.module('habitrpg')
} }
if (err) { if (err) {
var message = err.code ? err.message : err; var message = err.code ? err.message : err;
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});
}); });

View File

@@ -78,10 +78,8 @@ describe('user.ops.equip', () => {
// equipping two-hander // equipping two-hander
user.ops.equip({params: {key: 'weapon_wizard_1'}}, spy); user.ops.equip({params: {key: 'weapon_wizard_1'}}, spy);
let weapon = content.gear.flat.weapon_wizard_1; let weapon = content.gear.flat.weapon_wizard_1;
let message = [i18n.t('messageTwoHandled', {gearText: weapon.text(null)})];
let item = content.gear.flat.shield_warrior_1; let item = content.gear.flat.shield_warrior_1;
let message = i18n.t('messageTwoHandedEquip', {twoHandedText: weapon.text(null), offHandedText: item.text(null)});
message.push(i18n.t('messageUnEquipped', {itemText: item.text(null)}));
assert.calledOnce(spy); assert.calledOnce(spy);
assert.calledWith(spy, {code: 200, message}); assert.calledWith(spy, {code: 200, message});
@@ -90,13 +88,12 @@ describe('user.ops.equip', () => {
it('should send messages if equipping an off-hand item causes a two-handed weapon to be unequipped', () => { it('should send messages if equipping an off-hand item causes a two-handed weapon to be unequipped', () => {
// equipping two-hander // equipping two-hander
user.ops.equip({params: {key: 'weapon_wizard_1'}}); user.ops.equip({params: {key: 'weapon_wizard_1'}});
let item = content.gear.flat.weapon_wizard_1; let weapon = content.gear.flat.weapon_wizard_1;
let shield = content.gear.flat.shield_warrior_1;
user.ops.equip({params: {key: 'shield_warrior_1'}}, spy); user.ops.equip({params: {key: 'shield_warrior_1'}}, spy);
let message = [i18n.t('messageTwoHandled', {gearText: item.text(null)})]; let message = i18n.t('messageTwoHandedUnequip', {twoHandedText: weapon.text(null), offHandedText: shield.text(null)});
message.push(i18n.t('messageUnEquipped', {itemText: item.text(null)}));
assert.calledOnce(spy); assert.calledOnce(spy);
assert.calledWith(spy, {code: 200, message}); assert.calledWith(spy, {code: 200, message});