From 98be57a82c2fe2cbd981fc0410087949aa331cd4 Mon Sep 17 00:00:00 2001 From: Tyler Renelle Date: Thu, 12 Dec 2013 17:38:19 -0700 Subject: [PATCH] [#1977] misc fixes --- dist/habitrpg-shared.js | 29 +++++++++++++---------------- script/index.coffee | 15 ++++++++------- 2 files changed, 21 insertions(+), 23 deletions(-) diff --git a/dist/habitrpg-shared.js b/dist/habitrpg-shared.js index 5c24dca32d..5c5079cb7f 100644 --- a/dist/habitrpg-shared.js +++ b/dist/habitrpg-shared.js @@ -10964,7 +10964,7 @@ var process=require("__browserify_process");(function() { return task; }, feed: function(req, cb) { - var egg, evolve, food, pet, potion, userPets, _ref, _ref1, _ref2, _ref3; + var egg, evolve, food, message, pet, potion, userPets, _ref, _ref1, _ref2, _ref3; _ref2 = [(_ref = req.query) != null ? _ref.pet : void 0, content.food[(_ref1 = req.query) != null ? _ref1.food : void 0]], pet = _ref2[0], food = _ref2[1]; _ref3 = pet.split('-'), egg = _ref3[0], potion = _ref3[1]; if (!(pet && food)) { @@ -10977,40 +10977,34 @@ var process=require("__browserify_process");(function() { return cb("You already have that mount"); } userPets = user.items.pets; + message = ''; evolve = function() { userPets[pet] = 0; user.items.mounts[pet] = true; if (pet === user.items.currentPet) { user.items.currentPet = ""; } - return cb({ - code: 200, - message: "You have tamed " + egg + ", let's go for a ride!" - }, req); + return message = "You have tamed " + egg + ", let's go for a ride!"; }; if (food.name === 'Saddle') { evolve(); } else { if (food.target === potion) { userPets[pet] += 5; - cb({ - code: 200, - message: "" + egg + " really likes the " + food.name + "!" - }, req); + message = "" + egg + " really likes the " + food.name + "!"; } else { userPets[pet] += 2; - cb({ - code: 200, - message: "" + egg + " eats the " + food.name + " but doesn't seem to enjoy it." - }, req); + message = "" + egg + " eats the " + food.name + " but doesn't seem to enjoy it."; } if (userPets[pet] >= 50 && !user.items.mounts[pet]) { evolve(); } } - user.items.pets[pet] = userPets[pet]; user.items.food[food.name]--; - return typeof cb === "function" ? cb(null, req) : void 0; + return cb({ + code: 200, + message: message + }, req); }, buy: function(req, cb) { var item, key, _ref; @@ -11137,7 +11131,10 @@ var process=require("__browserify_process");(function() { user.items.pets[pet] = 5; user.items.eggs[egg]--; user.items.hatchingPotions[hatchingPotion]--; - return typeof cb === "function" ? cb(null, req) : void 0; + return typeof cb === "function" ? cb({ + code: 200, + message: "Your egg hatched! Visit your stable to equip your pet." + }, req) : void 0; }, unlock: function(req, cb) { var cost, fullSet, path; diff --git a/script/index.coffee b/script/index.coffee index 38894d7749..32e44ab605 100644 --- a/script/index.coffee +++ b/script/index.coffee @@ -674,25 +674,26 @@ api.wrap = (user) -> return cb("You already have that mount") if user.items.mounts[pet] and (userPets[pet] >= 50 or food.name is 'Saddle') userPets = user.items.pets + message = '' evolve = -> userPets[pet] = 0 user.items.mounts[pet] = true user.items.currentPet = "" if pet is user.items.currentPet - cb {code:200, message:"You have tamed #{egg}, let's go for a ride!"}, req + message = "You have tamed #{egg}, let's go for a ride!" if food.name is 'Saddle' evolve() else if food.target is potion userPets[pet] += 5 - cb {code:200, message: "#{egg} really likes the #{food.name}!"}, req + message = "#{egg} really likes the #{food.name}!" else userPets[pet] += 2 - cb {code:200, message: "#{egg} eats the #{food.name} but doesn't seem to enjoy it."}, req - evolve() if userPets[pet] >= 50 and not user.items.mounts[pet] - user.items.pets[pet] = userPets[pet] + message = "#{egg} eats the #{food.name} but doesn't seem to enjoy it." + if userPets[pet] >= 50 and !user.items.mounts[pet] + evolve() user.items.food[food.name]-- - cb? null, req + cb {code:200, message}, req buy: (req, cb) -> {key} = req.query @@ -765,7 +766,7 @@ api.wrap = (user) -> user.items.pets[pet] = 5 user.items.eggs[egg]-- user.items.hatchingPotions[hatchingPotion]-- - cb? null, req + cb? {code:200, message:"Your egg hatched! Visit your stable to equip your pet."}, req unlock: (req, cb) -> {path} = req.query