diff --git a/common/dist/scripts/habitrpg-shared.js b/common/dist/scripts/habitrpg-shared.js index c464adc06c..d2209863f4 100644 --- a/common/dist/scripts/habitrpg-shared.js +++ b/common/dist/scripts/habitrpg-shared.js @@ -5821,11 +5821,17 @@ api.wrap = function(user, main) { return typeof cb === "function" ? cb(null, user.inbox.blocks) : void 0; }, feed: function(req, cb) { - var egg, evolve, food, message, pet, potion, userPets, _ref, _ref1, _ref2; + var egg, eggText, evolve, food, message, pet, petDisplayName, potion, potionText, userPets, _ref, _ref1, _ref2; _ref = req.params, pet = _ref.pet, food = _ref.food; food = content.food[food]; _ref1 = pet.split('-'), egg = _ref1[0], potion = _ref1[1]; userPets = user.items.pets; + potionText = content.hatchingPotions[potion] ? content.hatchingPotions[potion].text() : potion; + eggText = content.eggs[egg] ? content.eggs[egg].text() : egg; + petDisplayName = i18n.t('petName', { + potion: potionText, + egg: eggText + }); if (!userPets[pet]) { return typeof cb === "function" ? cb({ code: 404, @@ -5858,7 +5864,7 @@ api.wrap = function(user, main) { user.items.currentPet = ""; } return message = i18n.t('messageEvolve', { - egg: egg + pet: petDisplayName }, req.language); }; if (food.key === 'Saddle') { @@ -5867,13 +5873,13 @@ api.wrap = function(user, main) { if (food.target === potion) { userPets[pet] += 5; message = i18n.t('messageLikesFood', { - egg: egg, + pet: petDisplayName, foodText: food.text(req.language) }, req.language); } else { userPets[pet] += 2; message = i18n.t('messageDontEnjoyFood', { - egg: egg, + pet: petDisplayName, foodText: food.text(req.language) }, req.language); } diff --git a/common/locales/en/messages.json b/common/locales/en/messages.json index f6d2d03d07..3b8e877264 100644 --- a/common/locales/en/messages.json +++ b/common/locales/en/messages.json @@ -6,9 +6,9 @@ "messageFoodNotFound": ":food not found in user.items.food", "messageCannotFeedPet": "Can't feed this pet.", "messageAlreadyMount": "You already have that mount. Try feeding another pet.", - "messageEvolve": "You have tamed <%= potion%> <%= egg %>, let's go for a ride!", - "messageLikesFood": "<%= potion %> <%= egg %> really likes the <%= foodText %>!", - "messageDontEnjoyFood": "<%= potion %> <%= egg %> eats the <%= foodText %> but doesn't seem to enjoy it.", + "messageEvolve": "You have tamed <%= pet %>, let's go for a ride!", + "messageLikesFood": "<%= pet %> really likes the <%= foodText %>!", + "messageDontEnjoyFood": "<%= pet %> eats the <%= foodText %> but doesn't seem to enjoy it.", "messageBought": "Bought <%= itemText %>", "messageEquipped": " <%= itemText %> equipped.", "messageUnEquipped": "<%= itemText %> un-equipped.", diff --git a/common/script/index.coffee b/common/script/index.coffee index 205c97e635..4ed72d3ef4 100644 --- a/common/script/index.coffee +++ b/common/script/index.coffee @@ -672,6 +672,14 @@ api.wrap = (user, main=true) -> [egg, potion] = pet.split('-') userPets = user.items.pets + # Generate pet display name variable + potionText = if content.hatchingPotions[potion] then content.hatchingPotions[potion].text() else potion + eggText = if content.eggs[egg] then content.eggs[egg].text() else egg + petDisplayName = i18n.t('petName', { + potion: potionText + egg: eggText + }) + return cb?({code:404, message:i18n.t('messagePetNotFound', req.language)}) unless userPets[pet] return cb?({code:404, message:i18n.t('messageFoodNotFound', req.language)}) unless user.items.food?[food.key] return cb?({code:401, message:i18n.t('messageCannotFeedPet', req.language)}) if content.specialPets[pet] or (egg is "Egg") @@ -683,17 +691,17 @@ api.wrap = (user, main=true) -> # changed to -1 to mark "owned" pets user.items.mounts[pet] = true user.items.currentPet = "" if pet is user.items.currentPet - message = i18n.t('messageEvolve', {egg: egg, potion: potion}, req.language) + message = i18n.t('messageEvolve', {pet: petDisplayName}, req.language) if food.key is 'Saddle' evolve() else if food.target is potion userPets[pet] += 5 - message = i18n.t('messageLikesFood', {egg: egg, potion: potion, foodText: food.text(req.language)}, req.language) + message = i18n.t('messageLikesFood', {pet: petDisplayName, foodText: food.text(req.language)}, req.language) else userPets[pet] += 2 - message = i18n.t('messageDontEnjoyFood', {egg: egg, potion: potion, foodText: food.text(req.language)}, req.language) + message = i18n.t('messageDontEnjoyFood', {pet: petDisplayName, foodText: food.text(req.language)}, req.language) if userPets[pet] >= 50 and !user.items.mounts[pet] evolve() user.items.food[food.key]--