mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-17 14:47:53 +01:00
Reverted changes related to multiple messages and changed handleTwoHanded to send single, clearer, messages.
This commit is contained in:
@@ -19,7 +19,8 @@
|
||||
"messageAlreadyPet": "You already have that pet. Try hatching a different combination!",
|
||||
"messageHatched": "Your egg hatched! Visit your stable to equip your pet.",
|
||||
"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 %>",
|
||||
"messageDropEgg": "You've found a <%= dropText %> Egg! <%= dropNotes %>",
|
||||
"messageDropPotion": "You've found a <%= dropText %> Hatching Potion! <%= dropNotes %>",
|
||||
|
||||
@@ -2065,31 +2065,23 @@ api.wrap = function(user, main) {
|
||||
return item;
|
||||
},
|
||||
handleTwoHanded: function(item, type, req) {
|
||||
var message, ref, weapon, shield;
|
||||
var message, currentWeapon, currentShield;
|
||||
if (type == null) {
|
||||
type = 'equipped';
|
||||
}
|
||||
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';
|
||||
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";
|
||||
currentShield = content.gear.flat[user.items.gear[type].shield];
|
||||
currentWeapon = content.gear.flat[user.items.gear[type].weapon];
|
||||
|
||||
message = [i18n.t('messageTwoHandled', {
|
||||
gearText: item.text(req.language)
|
||||
}, req.language)];
|
||||
message.push(i18n.t('messageUnEquipped', {
|
||||
itemText: shield.text(req.language)
|
||||
}, req.language));
|
||||
}
|
||||
if (item.type === "shield" && (currentWeapon ? currentWeapon.twoHanded : false)) {
|
||||
user.items.gear[type].weapon = 'weapon_base_0';
|
||||
message = i18n.t('messageTwoHandedUnequip', {
|
||||
twoHandedText: currentWeapon.text(req.language), offHandedText: item.text(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;
|
||||
},
|
||||
|
||||
@@ -106,15 +106,10 @@ angular.module('habitrpg')
|
||||
}
|
||||
if (err) {
|
||||
var message = err.code ? err.message : err;
|
||||
console.log(message);
|
||||
if (typeof message === 'string')
|
||||
message = [message];
|
||||
_.each(message, (msg) => {
|
||||
if (MOBILE_APP) Notification.push({type:'text',text:msg});
|
||||
else Notification.text(msg);
|
||||
if (MOBILE_APP) Notification.push({type:'text',text:message});
|
||||
else Notification.text(message);
|
||||
// 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});
|
||||
});
|
||||
|
||||
@@ -78,10 +78,8 @@ describe('user.ops.equip', () => {
|
||||
// equipping two-hander
|
||||
user.ops.equip({params: {key: 'weapon_wizard_1'}}, spy);
|
||||
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;
|
||||
|
||||
message.push(i18n.t('messageUnEquipped', {itemText: item.text(null)}));
|
||||
let message = i18n.t('messageTwoHandedEquip', {twoHandedText: weapon.text(null), offHandedText: item.text(null)});
|
||||
|
||||
assert.calledOnce(spy);
|
||||
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', () => {
|
||||
// equipping two-hander
|
||||
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);
|
||||
|
||||
let message = [i18n.t('messageTwoHandled', {gearText: item.text(null)})];
|
||||
|
||||
message.push(i18n.t('messageUnEquipped', {itemText: item.text(null)}));
|
||||
let message = i18n.t('messageTwoHandedUnequip', {twoHandedText: weapon.text(null), offHandedText: shield.text(null)});
|
||||
|
||||
assert.calledOnce(spy);
|
||||
assert.calledWith(spy, {code: 200, message});
|
||||
|
||||
Reference in New Issue
Block a user