From 8b780eaf0d75d8ac632f8b07e138e1824d336e85 Mon Sep 17 00:00:00 2001 From: Xaz16 Date: Sun, 15 Dec 2019 22:00:34 +0300 Subject: [PATCH] Fix: pet tests --- website/common/script/ops/feed.js | 12 ++++++------ website/common/script/ops/hatch.js | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/website/common/script/ops/feed.js b/website/common/script/ops/feed.js index 05170ddba4..58a204fe22 100644 --- a/website/common/script/ops/feed.js +++ b/website/common/script/ops/feed.js @@ -17,6 +17,7 @@ function evolve (user, pet, req) { ...user.items.pets, [pet.key]: -1, }; + user.items.mounts = { ...user.items.mounts, [pet.key]: true, @@ -52,9 +53,8 @@ export default function feed (user, req = {}) { throw new NotFound(errorMessage('invalidFoodName', req.language)); } - const userPets = user.items.pets; - if (!userPets[pet.key]) { + if (!user.items.pets[pet.key]) { throw new NotFound(i18n.t('messagePetNotFound', req.language)); } @@ -81,16 +81,16 @@ export default function feed (user, req = {}) { }; if (food.target === pet.potion || pet.type === 'premium') { - userPets[pet.key] += 5; + user.items.pets[pet.key] += 5; message = i18n.t('messageLikesFood', messageParams, req.language); } else { - userPets[pet.key] += 2; + user.items.pets[pet.key] += 2; message = i18n.t('messageDontEnjoyFood', messageParams, req.language); } if (user.markModified) user.markModified('items.pets'); - if (userPets[pet.key] >= 50 && !user.items.mounts[pet.key]) { + if (user.items.pets[pet.key] >= 50 && !user.items.mounts[pet.key]) { message = evolve(user, pet, req); } } @@ -116,7 +116,7 @@ export default function feed (user, req = {}) { }); return [ - userPets[pet.key], + user.items.pets[pet.key], message, ]; } diff --git a/website/common/script/ops/hatch.js b/website/common/script/ops/hatch.js index 551ef89463..86eca5dcd0 100644 --- a/website/common/script/ops/hatch.js +++ b/website/common/script/ops/hatch.js @@ -46,7 +46,7 @@ export default function hatch (user, req = {}) { }; user.items.eggs = { ...user.items.eggs, - [egg]: user.items.eggs - 1, + [egg]: Number.isInteger(user.items.eggs) ? user.items.eggs - 1 : 0, }; user.items.hatchingPotions[hatchingPotion] -= 1; if (user.markModified) {