mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-19 15:48:04 +01:00
Refactored pet display name changes
This commit is contained in:
14
common/dist/scripts/habitrpg-shared.js
vendored
14
common/dist/scripts/habitrpg-shared.js
vendored
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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.",
|
||||
|
||||
@@ -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]--
|
||||
|
||||
Reference in New Issue
Block a user