From 5a2daabada41df597de79df92fcdab0d641cae2f Mon Sep 17 00:00:00 2001 From: Matteo Pagliazzi Date: Tue, 8 Mar 2016 17:45:14 +0100 Subject: [PATCH] remove all changes from eslint --fix --- common/script/ops/allocate.js | 2 +- common/script/ops/buy.js | 2 +- common/script/ops/buyMysterySet.js | 2 +- common/script/ops/buySpecialSpell.js | 2 +- common/script/ops/changeClass.js | 2 +- common/script/ops/deletePM.js | 6 +-- common/script/ops/deleteTag.js | 12 +++--- common/script/ops/deleteTask.js | 12 +++--- common/script/ops/deleteWebhook.js | 6 +-- common/script/ops/disableClasses.js | 8 ++-- common/script/ops/equip.js | 22 +++++----- common/script/ops/feed.js | 18 ++++---- common/script/ops/getTag.js | 6 +-- common/script/ops/getTags.js | 4 +- common/script/ops/hatch.js | 16 +++---- common/script/ops/hourglassPurchase.js | 14 +++---- common/script/ops/openMysteryItem.js | 16 +++---- common/script/ops/purchase.js | 42 +++++++++---------- common/script/ops/readCard.js | 13 +++--- common/script/ops/rebirth.js | 26 ++++++------ common/script/ops/releaseBoth.js | 12 +++--- common/script/ops/releaseMounts.js | 10 ++--- common/script/ops/releasePets.js | 10 ++--- common/script/ops/reroll.js | 10 ++--- common/script/ops/reset.js | 10 ++--- common/script/ops/revive.js | 24 +++++------ common/script/ops/score.js | 42 +++++++++---------- common/script/ops/sell.js | 12 +++--- common/script/ops/sleep.js | 4 +- common/script/ops/sortTag.js | 8 ++-- common/script/ops/sortTask.js | 16 +++---- common/script/ops/unlock.js | 28 ++++++------- common/script/ops/update.js | 6 +-- common/script/ops/updateTag.js | 6 +-- common/script/ops/updateTask.js | 10 ++--- common/script/ops/updateWebhook.js | 6 +-- .../common/user.ops.hourglassPurchase.test.js | 2 +- 37 files changed, 224 insertions(+), 223 deletions(-) diff --git a/common/script/ops/allocate.js b/common/script/ops/allocate.js index d471d45d62..92b5ae53fa 100644 --- a/common/script/ops/allocate.js +++ b/common/script/ops/allocate.js @@ -11,5 +11,5 @@ module.exports = function(user, req, cb) { user.stats.mp++; } } - return typeof cb === "function" ? cb(null, _.pick(user, $w('stats'))) : void 0; + return typeof cb === "function" ? cb(null, _.pick(user, splitWhitespace('stats'))) : void 0; }; diff --git a/common/script/ops/buy.js b/common/script/ops/buy.js index 4735025cd4..d80c64169c 100644 --- a/common/script/ops/buy.js +++ b/common/script/ops/buy.js @@ -108,7 +108,7 @@ module.exports = function(user, req, cb, analytics) { if (analytics != null) { analytics.track('acquire item', analyticsData); } - buyResp = _.pick(user, $w('items achievements stats flags')); + buyResp = _.pick(user, splitWhitespace('items achievements stats flags')); if (armoireResp) { buyResp["armoire"] = armoireResp; } diff --git a/common/script/ops/buyMysterySet.js b/common/script/ops/buyMysterySet.js index 557cfd0595..44ccdb9aaf 100644 --- a/common/script/ops/buyMysterySet.js +++ b/common/script/ops/buyMysterySet.js @@ -39,5 +39,5 @@ module.exports = function(user, req, cb, analytics) { return typeof cb === "function" ? cb({ code: 200, message: i18n.t('hourglassPurchaseSet', req.language) - }, _.pick(user, $w('items purchased.plan.consecutive'))) : void 0; + }, _.pick(user, splitWhitespace('items purchased.plan.consecutive'))) : void 0; }; diff --git a/common/script/ops/buySpecialSpell.js b/common/script/ops/buySpecialSpell.js index 408c8e94c3..e2a9dc8deb 100644 --- a/common/script/ops/buySpecialSpell.js +++ b/common/script/ops/buySpecialSpell.js @@ -27,5 +27,5 @@ module.exports = function(user, req, cb) { return typeof cb === "function" ? cb({ code: 200, message: message - }, _.pick(user, $w('items stats'))) : void 0; + }, _.pick(user, splitWhitespace('items stats'))) : void 0; }; diff --git a/common/script/ops/changeClass.js b/common/script/ops/changeClass.js index 4a9a7e0536..3fb591a31b 100644 --- a/common/script/ops/changeClass.js +++ b/common/script/ops/changeClass.js @@ -55,5 +55,5 @@ module.exports = function(user, req, cb, analytics) { }); user.flags.classSelected = false; } - return typeof cb === "function" ? cb(null, _.pick(user, $w('stats flags items preferences'))) : void 0; + return typeof cb === "function" ? cb(null, _.pick(user, splitWhitespace('stats flags items preferences'))) : void 0; }; diff --git a/common/script/ops/deletePM.js b/common/script/ops/deletePM.js index d4d5684fbd..ad95bc9ae0 100644 --- a/common/script/ops/deletePM.js +++ b/common/script/ops/deletePM.js @@ -1,7 +1,7 @@ -module.exports = function (user, req, cb) { +module.exports = function(user, req, cb) { delete user.inbox.messages[req.params.id]; - if (typeof user.markModified === 'function') { + if (typeof user.markModified === "function") { user.markModified('inbox.messages.' + req.params.id); } - return typeof cb === 'function' ? cb(null, user.inbox.messages) : void 0; + return typeof cb === "function" ? cb(null, user.inbox.messages) : void 0; }; diff --git a/common/script/ops/deleteTag.js b/common/script/ops/deleteTag.js index 6339f62d3d..a82af59e86 100644 --- a/common/script/ops/deleteTag.js +++ b/common/script/ops/deleteTag.js @@ -1,14 +1,14 @@ import i18n from '../i18n'; import _ from 'lodash'; -module.exports = function (user, req, cb) { +module.exports = function(user, req, cb) { var i, tag, tid; tid = req.params.id; i = _.findIndex(user.tags, { id: tid }); if (!~i) { - return typeof cb === 'function' ? cb({ + return typeof cb === "function" ? cb({ code: 404, message: i18n.t('messageTagNotFound', req.language) }) : void 0; @@ -16,11 +16,11 @@ module.exports = function (user, req, cb) { tag = user.tags[i]; delete user.filters[tag.id]; user.tags.splice(i, 1); - _.each(user.tasks, function (task) { + _.each(user.tasks, function(task) { return delete task.tags[tag.id]; }); - _.each(['habits', 'dailys', 'todos', 'rewards'], function (type) { - return typeof user.markModified === 'function' ? user.markModified(type) : void 0; + _.each(['habits', 'dailys', 'todos', 'rewards'], function(type) { + return typeof user.markModified === "function" ? user.markModified(type) : void 0; }); - return typeof cb === 'function' ? cb(null, user.tags) : void 0; + return typeof cb === "function" ? cb(null, user.tags) : void 0; }; diff --git a/common/script/ops/deleteTask.js b/common/script/ops/deleteTask.js index c72f2ec07e..715b102241 100644 --- a/common/script/ops/deleteTask.js +++ b/common/script/ops/deleteTask.js @@ -1,17 +1,17 @@ import i18n from '../i18n'; -module.exports = function (user, req, cb) { +module.exports = function(user, req, cb) { var i, ref, task; - task = user.tasks[(ref = req.params) !== null ? ref.id : void 0]; + task = user.tasks[(ref = req.params) != null ? ref.id : void 0]; if (!task) { - return typeof cb === 'function' ? cb({ + return typeof cb === "function" ? cb({ code: 404, message: i18n.t('messageTaskNotFound', req.language) }) : void 0; } - i = user[task.type + 's'].indexOf(task); + i = user[task.type + "s"].indexOf(task); if (~i) { - user[task.type + 's'].splice(i, 1); + user[task.type + "s"].splice(i, 1); } - return typeof cb === 'function' ? cb(null, {}) : void 0; + return typeof cb === "function" ? cb(null, {}) : void 0; }; diff --git a/common/script/ops/deleteWebhook.js b/common/script/ops/deleteWebhook.js index da9b598ead..a187f08770 100644 --- a/common/script/ops/deleteWebhook.js +++ b/common/script/ops/deleteWebhook.js @@ -1,7 +1,7 @@ -module.exports = function (user, req, cb) { +module.exports = function(user, req, cb) { delete user.preferences.webhooks[req.params.id]; - if (typeof user.markModified === 'function') { + if (typeof user.markModified === "function") { user.markModified('preferences.webhooks'); } - return typeof cb === 'function' ? cb(null, user.preferences.webhooks) : void 0; + return typeof cb === "function" ? cb(null, user.preferences.webhooks) : void 0; }; diff --git a/common/script/ops/disableClasses.js b/common/script/ops/disableClasses.js index cf8294dedd..0b8dc9261e 100644 --- a/common/script/ops/disableClasses.js +++ b/common/script/ops/disableClasses.js @@ -2,12 +2,12 @@ import splitWhitespace from '../libs/splitWhitespace'; import { capByLevel } from '../statHelpers'; import _ from 'lodash'; -module.exports = function (user, req, cb) { - user.stats['class'] = 'warrior'; +module.exports = function(user, req, cb) { + user.stats["class"] = 'warrior'; user.flags.classSelected = true; user.preferences.disableClasses = true; user.preferences.autoAllocate = true; - user.stats.str = capByLevel(user.stats.lvl); + user.stats.str = api.capByLevel(user.stats.lvl); user.stats.points = 0; - return typeof cb === 'function' ? cb(null, _.pick(user, splitWhitespace('stats flags preferences'))) : void 0; + return typeof cb === "function" ? cb(null, _.pick(user, splitWhitespace('stats flags preferences'))) : void 0; }; diff --git a/common/script/ops/equip.js b/common/script/ops/equip.js index 621e3e1f67..8c07a364b1 100644 --- a/common/script/ops/equip.js +++ b/common/script/ops/equip.js @@ -1,24 +1,24 @@ import content from '../content/index'; import i18n from '../i18n'; -module.exports = function (user, req, cb) { +module.exports = function(user, req, cb) { var item, key, message, ref, type; ref = [req.params.type || 'equipped', req.params.key], type = ref[0], key = ref[1]; switch (type) { case 'mount': if (!user.items.mounts[key]) { - return typeof cb === 'function' ? cb({ + return typeof cb === "function" ? cb({ code: 404, - message: ':You do not own this mount.' + message: ":You do not own this mount." }) : void 0; } user.items.currentMount = user.items.currentMount === key ? '' : key; break; case 'pet': if (!user.items.pets[key]) { - return typeof cb === 'function' ? cb({ + return typeof cb === "function" ? cb({ code: 404, - message: ':You do not own this pet.' + message: ":You do not own this pet." }) : void 0; } user.items.currentPet = user.items.currentPet === key ? '' : key; @@ -27,13 +27,13 @@ module.exports = function (user, req, cb) { case 'equipped': item = content.gear.flat[key]; if (!user.items.gear.owned[key]) { - return typeof cb === 'function' ? cb({ + return typeof cb === "function" ? cb({ code: 404, - message: ':You do not own this gear.' + message: ":You do not own this gear." }) : void 0; } if (user.items.gear[type][item.type] === key) { - user.items.gear[type][item.type] = item.type + '_base_0'; + user.items.gear[type][item.type] = item.type + "_base_0"; message = i18n.t('messageUnEquipped', { itemText: item.text(req.language) }, req.language); @@ -41,11 +41,11 @@ module.exports = function (user, req, cb) { user.items.gear[type][item.type] = item.key; message = user.fns.handleTwoHanded(item, type, req); } - if (typeof user.markModified === 'function') { - user.markModified('items.gear.' + type); + if (typeof user.markModified === "function") { + user.markModified("items.gear." + type); } } - return typeof cb === 'function' ? cb((message ? { + return typeof cb === "function" ? cb((message ? { code: 200, message: message } : null), user.items) : void 0; diff --git a/common/script/ops/feed.js b/common/script/ops/feed.js index c5b0b39271..3c9b0f87fd 100644 --- a/common/script/ops/feed.js +++ b/common/script/ops/feed.js @@ -1,7 +1,7 @@ import content from '../content/index'; import i18n from '../i18n'; -module.exports = function (user, req, cb) { +module.exports = function(user, req, cb) { var egg, eggText, evolve, food, message, pet, petDisplayName, potion, potionText, ref, ref1, ref2, userPets; ref = req.params, pet = ref.pet, food = ref.food; food = content.food[food]; @@ -14,35 +14,35 @@ module.exports = function (user, req, cb) { egg: eggText }); if (!userPets[pet]) { - return typeof cb === 'function' ? cb({ + return typeof cb === "function" ? cb({ code: 404, message: i18n.t('messagePetNotFound', req.language) }) : void 0; } - if (!((ref2 = user.items.food) !== null ? ref2[food.key] : void 0)) { - return typeof cb === 'function' ? cb({ + if (!((ref2 = user.items.food) != null ? ref2[food.key] : void 0)) { + return typeof cb === "function" ? cb({ code: 404, message: i18n.t('messageFoodNotFound', req.language) }) : void 0; } if (content.specialPets[pet]) { - return typeof cb === 'function' ? cb({ + return typeof cb === "function" ? cb({ code: 401, message: i18n.t('messageCannotFeedPet', req.language) }) : void 0; } if (user.items.mounts[pet]) { - return typeof cb === 'function' ? cb({ + return typeof cb === "function" ? cb({ code: 401, message: i18n.t('messageAlreadyMount', req.language) }) : void 0; } message = ''; - evolve = function () { + evolve = function() { userPets[pet] = -1; user.items.mounts[pet] = true; if (pet === user.items.currentPet) { - user.items.currentPet = ''; + user.items.currentPet = ""; } return message = i18n.t('messageEvolve', { egg: petDisplayName @@ -69,7 +69,7 @@ module.exports = function (user, req, cb) { } } user.items.food[food.key]--; - return typeof cb === 'function' ? cb({ + return typeof cb === "function" ? cb({ code: 200, message: message }, { diff --git a/common/script/ops/getTag.js b/common/script/ops/getTag.js index 8380ef5296..06f3f24110 100644 --- a/common/script/ops/getTag.js +++ b/common/script/ops/getTag.js @@ -1,17 +1,17 @@ import _ from 'lodash'; import i18n from '../i18n'; -module.exports = function (user, req, cb) { +module.exports = function(user, req, cb) { var i, tid; tid = req.params.id; i = _.findIndex(user.tags, { id: tid }); if (!~i) { - return typeof cb === 'function' ? cb({ + return typeof cb === "function" ? cb({ code: 404, message: i18n.t('messageTagNotFound', req.language) }) : void 0; } - return typeof cb === 'function' ? cb(null, user.tags[i]) : void 0; + return typeof cb === "function" ? cb(null, user.tags[i]) : void 0; }; diff --git a/common/script/ops/getTags.js b/common/script/ops/getTags.js index bc05d1109e..af9419b050 100644 --- a/common/script/ops/getTags.js +++ b/common/script/ops/getTags.js @@ -1,3 +1,3 @@ -module.exports = function (user, req, cb) { - return typeof cb === 'function' ? cb(null, user.tags) : void 0; +module.exports = function(user, req, cb) { + return typeof cb === "function" ? cb(null, user.tags) : void 0; }; diff --git a/common/script/ops/hatch.js b/common/script/ops/hatch.js index 40fa13ee4b..6292e24bcb 100644 --- a/common/script/ops/hatch.js +++ b/common/script/ops/hatch.js @@ -1,30 +1,30 @@ import content from '../content/index'; import i18n from '../i18n'; -module.exports = function (user, req, cb) { +module.exports = function(user, req, cb) { var egg, hatchingPotion, pet, ref; ref = req.params, egg = ref.egg, hatchingPotion = ref.hatchingPotion; if (!(egg && hatchingPotion)) { - return typeof cb === 'function' ? cb({ + return typeof cb === "function" ? cb({ code: 400, - message: 'Please specify query.egg & query.hatchingPotion' + message: "Please specify query.egg & query.hatchingPotion" }) : void 0; } if (!(user.items.eggs[egg] > 0 && user.items.hatchingPotions[hatchingPotion] > 0)) { - return typeof cb === 'function' ? cb({ + return typeof cb === "function" ? cb({ code: 403, message: i18n.t('messageMissingEggPotion', req.language) }) : void 0; } if (content.hatchingPotions[hatchingPotion].premium && !content.dropEggs[egg]) { - return typeof cb === 'function' ? cb({ + return typeof cb === "function" ? cb({ code: 403, message: i18n.t('messageInvalidEggPotionCombo', req.language) }) : void 0; } - pet = egg + '-' + hatchingPotion; + pet = egg + "-" + hatchingPotion; if (user.items.pets[pet] && user.items.pets[pet] > 0) { - return typeof cb === 'function' ? cb({ + return typeof cb === "function" ? cb({ code: 403, message: i18n.t('messageAlreadyPet', req.language) }) : void 0; @@ -32,7 +32,7 @@ module.exports = function (user, req, cb) { user.items.pets[pet] = 5; user.items.eggs[egg]--; user.items.hatchingPotions[hatchingPotion]--; - return typeof cb === 'function' ? cb({ + return typeof cb === "function" ? cb({ code: 200, message: i18n.t('messageHatched', req.language) }, user.items) : void 0; diff --git a/common/script/ops/hourglassPurchase.js b/common/script/ops/hourglassPurchase.js index 99f17b0e08..4955898f0b 100644 --- a/common/script/ops/hourglassPurchase.js +++ b/common/script/ops/hourglassPurchase.js @@ -3,29 +3,29 @@ import i18n from '../i18n'; import _ from 'lodash'; import splitWhitespace from '../libs/splitWhitespace'; -module.exports = function (user, req, cb, analytics) { +module.exports = function(user, req, cb, analytics) { var analyticsData, key, ref, type; ref = req.params, type = ref.type, key = ref.key; if (!content.timeTravelStable[type]) { - return typeof cb === 'function' ? cb({ + return typeof cb === "function" ? cb({ code: 403, message: i18n.t('typeNotAllowedHourglass', req.language) + JSON.stringify(_.keys(content.timeTravelStable)) }) : void 0; } if (!_.contains(_.keys(content.timeTravelStable[type]), key)) { - return typeof cb === 'function' ? cb({ + return typeof cb === "function" ? cb({ code: 403, message: i18n.t(type + 'NotAllowedHourglass', req.language) }) : void 0; } if (user.items[type][key]) { - return typeof cb === 'function' ? cb({ + return typeof cb === "function" ? cb({ code: 403, message: i18n.t(type + 'AlreadyOwned', req.language) }) : void 0; } if (!(user.purchased.plan.consecutive.trinkets > 0)) { - return typeof cb === 'function' ? cb({ + return typeof cb === "function" ? cb({ code: 403, message: i18n.t('notEnoughHourglasses', req.language) }) : void 0; @@ -44,10 +44,10 @@ module.exports = function (user, req, cb, analytics) { acquireMethod: 'Hourglass', category: 'behavior' }; - if (analytics) { + if (analytics != null) { analytics.track('acquire item', analyticsData); } - return typeof cb === 'function' ? cb({ + return typeof cb === "function" ? cb({ code: 200, message: i18n.t('hourglassPurchase', req.language) }, _.pick(user, splitWhitespace('items purchased.plan.consecutive'))) : void 0; diff --git a/common/script/ops/openMysteryItem.js b/common/script/ops/openMysteryItem.js index 9536a206f5..eb28c605e0 100644 --- a/common/script/ops/openMysteryItem.js +++ b/common/script/ops/openMysteryItem.js @@ -1,17 +1,17 @@ import content from '../content/index'; -module.exports = function (user, req, cb, analytics) { +module.exports = function(user, req, cb, analytics) { var analyticsData, item, ref, ref1; - item = (ref = user.purchased.plan) !== null ? (ref1 = ref.mysteryItems) !== null ? ref1.shift() : void 0 : void 0; + item = (ref = user.purchased.plan) != null ? (ref1 = ref.mysteryItems) != null ? ref1.shift() : void 0 : void 0; if (!item) { - return typeof cb === 'function' ? cb({ + return typeof cb === "function" ? cb({ code: 400, - message: 'Empty' + message: "Empty" }) : void 0; } item = content.gear.flat[item]; user.items.gear.owned[item.key] = true; - if (typeof user.markModified === 'function') { + if (typeof user.markModified === "function") { user.markModified('purchased.plan.mysteryItems'); } item.notificationType = 'Mystery'; @@ -22,11 +22,11 @@ module.exports = function (user, req, cb, analytics) { acquireMethod: 'Subscriber', category: 'behavior' }; - if (analytics !== null) { + if (analytics != null) { analytics.track('open mystery item', analyticsData); } if (typeof window !== 'undefined') { - (user._tmp !== null ? user._tmp : user._tmp = {}).drop = item; + (user._tmp != null ? user._tmp : user._tmp = {}).drop = item; } - return typeof cb === 'function' ? cb(null, user.items.gear.owned) : void 0; + return typeof cb === "function" ? cb(null, user.items.gear.owned) : void 0; }; diff --git a/common/script/ops/purchase.js b/common/script/ops/purchase.js index 09e24b24fc..525eddab86 100644 --- a/common/script/ops/purchase.js +++ b/common/script/ops/purchase.js @@ -4,28 +4,28 @@ import _ from 'lodash'; import splitWhitespace from '../libs/splitWhitespace'; import planGemLimits from '../libs/planGemLimits'; -module.exports = function (user, req, cb, analytics) { +module.exports = function(user, req, cb, analytics) { var analyticsData, convCap, convRate, item, key, price, ref, ref1, ref2, ref3, type; ref = req.params, type = ref.type, key = ref.key; if (type === 'gems' && key === 'gem') { - ref1 = planGemLimits, convRate = ref1.convRate, convCap = ref1.convCap; + ref1 = api.planGemLimits, convRate = ref1.convRate, convCap = ref1.convCap; convCap += user.purchased.plan.consecutive.gemCapExtra; - if (!((ref2 = user.purchased) !== null ? (ref3 = ref2.plan) !== null ? ref3.customerId : void 0 : void 0)) { - return typeof cb === 'function' ? cb({ + if (!((ref2 = user.purchased) != null ? (ref3 = ref2.plan) != null ? ref3.customerId : void 0 : void 0)) { + return typeof cb === "function" ? cb({ code: 401, - message: 'Must subscribe to purchase gems with GP' + message: "Must subscribe to purchase gems with GP" }, req) : void 0; } if (!(user.stats.gp >= convRate)) { - return typeof cb === 'function' ? cb({ + return typeof cb === "function" ? cb({ code: 401, - message: 'Not enough Gold' + message: "Not enough Gold" }) : void 0; } if (user.purchased.plan.gemsBought >= convCap) { - return typeof cb === 'function' ? cb({ + return typeof cb === "function" ? cb({ code: 401, - message: 'You\'ve reached the Gold=>Gem conversion cap (' + convCap + ') for this month. We have this to prevent abuse / farming. The cap will reset within the first three days of next month.' + message: "You've reached the Gold=>Gem conversion cap (" + convCap + ") for this month. We have this to prevent abuse / farming. The cap will reset within the first three days of next month." }) : void 0; } user.balance += .25; @@ -38,24 +38,24 @@ module.exports = function (user, req, cb, analytics) { goldCost: convRate, category: 'behavior' }; - if (analytics !== null) { + if (analytics != null) { analytics.track('purchase gems', analyticsData); } - return typeof cb === 'function' ? cb({ + return typeof cb === "function" ? cb({ code: 200, - message: '+1 Gem' + message: "+1 Gem" }, _.pick(user, splitWhitespace('stats balance'))) : void 0; } if (type !== 'eggs' && type !== 'hatchingPotions' && type !== 'food' && type !== 'quests' && type !== 'gear') { - return typeof cb === 'function' ? cb({ + return typeof cb === "function" ? cb({ code: 404, - message: ':type must be in [eggs,hatchingPotions,food,quests,gear]' + message: ":type must be in [eggs,hatchingPotions,food,quests,gear]" }, req) : void 0; } if (type === 'gear') { item = content.gear.flat[key]; if (user.items.gear.owned[key]) { - return typeof cb === 'function' ? cb({ + return typeof cb === "function" ? cb({ code: 401, message: i18n.t('alreadyHave', req.language) }) : void 0; @@ -66,19 +66,19 @@ module.exports = function (user, req, cb, analytics) { price = item.value / 4; } if (!item) { - return typeof cb === 'function' ? cb({ + return typeof cb === "function" ? cb({ code: 404, - message: ':key not found for Content.' + type + message: ":key not found for Content." + type }, req) : void 0; } if (!item.canBuy(user)) { - return typeof cb === 'function' ? cb({ + return typeof cb === "function" ? cb({ code: 403, message: i18n.t('messageNotAvailable', req.language) }) : void 0; } if ((user.balance < price) || !user.balance) { - return typeof cb === 'function' ? cb({ + return typeof cb === "function" ? cb({ code: 403, message: i18n.t('notEnoughGems', req.language) }) : void 0; @@ -100,8 +100,8 @@ module.exports = function (user, req, cb, analytics) { gemCost: item.value, category: 'behavior' }; - if (analytics !== null) { + if (analytics != null) { analytics.track('acquire item', analyticsData); } - return typeof cb === 'function' ? cb(null, _.pick(user, splitWhitespace('items balance'))) : void 0; + return typeof cb === "function" ? cb(null, _.pick(user, splitWhitespace('items balance'))) : void 0; }; diff --git a/common/script/ops/readCard.js b/common/script/ops/readCard.js index ecfe7e718f..a6eb5c05f1 100644 --- a/common/script/ops/readCard.js +++ b/common/script/ops/readCard.js @@ -1,9 +1,10 @@ -module.exports = function readCard (user, req, cb) { - let cardType = req.params.cardType; - user.items.special[`${cardType}Received`].shift(); - if (user.markModified) { - user.markModified(`items.special.${cardType}Received`); +module.exports = function(user, req, cb) { + var cardType; + cardType = req.params.cardType; + user.items.special[cardType + "Received"].shift(); + if (typeof user.markModified === "function") { + user.markModified("items.special." + cardType + "Received"); } user.flags.cardReceived = false; - if (cb) cb(null, 'items.special flags.cardReceived'); + return typeof cb === "function" ? cb(null, 'items.special flags.cardReceived') : void 0; }; diff --git a/common/script/ops/rebirth.js b/common/script/ops/rebirth.js index 1370fce696..3971a82e61 100644 --- a/common/script/ops/rebirth.js +++ b/common/script/ops/rebirth.js @@ -4,10 +4,10 @@ import _ from 'lodash'; import { capByLevel } from '../statHelpers'; import { MAX_LEVEL } from '../constants'; -module.exports = function (user, req, cb, analytics) { +module.exports = function(user, req, cb, analytics) { var analyticsData, flags, gear, lvl, stats; - if (user.balance < 2 && user.stats.lvl < MAX_LEVEL) { - return typeof cb === 'function' ? cb({ + if (user.balance < 2 && user.stats.lvl < api.maxLevel) { + return typeof cb === "function" ? cb({ code: 401, message: i18n.t('notEnoughGems', req.language) }) : void 0; @@ -16,7 +16,7 @@ module.exports = function (user, req, cb, analytics) { uuid: user._id, category: 'behavior' }; - if (user.stats.lvl < MAX_LEVEL) { + if (user.stats.lvl < api.maxLevel) { user.balance -= 2; analyticsData.acquireMethod = 'Gems'; analyticsData.gemCost = 8; @@ -24,11 +24,11 @@ module.exports = function (user, req, cb, analytics) { analyticsData.gemCost = 0; analyticsData.acquireMethod = '> 100'; } - if (analytics !== null) { + if (analytics != null) { analytics.track('Rebirth', analyticsData); } - lvl = capByLevel(user.stats.lvl); - _.each(user.tasks, function (task) { + lvl = api.capByLevel(user.stats.lvl); + _.each(user.tasks, function(task) { if (task.type !== 'reward') { task.value = 0; } @@ -40,13 +40,13 @@ module.exports = function (user, req, cb, analytics) { stats.buffs = {}; stats.hp = 50; stats.lvl = 1; - stats['class'] = 'warrior'; - _.each(['per', 'int', 'con', 'str', 'points', 'gp', 'exp', 'mp'], function (value) { + stats["class"] = 'warrior'; + _.each(['per', 'int', 'con', 'str', 'points', 'gp', 'exp', 'mp'], function(value) { return stats[value] = 0; }); // TODO during refactoring: move all gear code from rebirth() to its own function and then call it in reset() as well gear = user.items.gear; - _.each(['equipped', 'costume'], function (type) { + _.each(['equipped', 'costume'], function(type) { gear[type] = {}; gear[type].armor = 'armor_base_0'; gear[type].weapon = 'weapon_warrior_0'; @@ -69,14 +69,14 @@ module.exports = function (user, req, cb, analytics) { } }); } - _.each(gear.owned, function (v, k) { + _.each(gear.owned, function(v, k) { if (gear.owned[k] && content.gear.flat[k].value) { gear.owned[k] = false; return true; } }); gear.owned.weapon_warrior_0 = true; - if (typeof user.markModified === 'function') { + if (typeof user.markModified === "function") { user.markModified('items.gear.owned'); } user.preferences.costume = false; @@ -96,5 +96,5 @@ module.exports = function (user, req, cb, analytics) { user.achievements.rebirthLevel = lvl; } user.stats.buffs = {}; - return typeof cb === 'function' ? cb(null, user) : void 0; + return typeof cb === "function" ? cb(null, user) : void 0; }; diff --git a/common/script/ops/releaseBoth.js b/common/script/ops/releaseBoth.js index 08d6a7226e..a782581f85 100644 --- a/common/script/ops/releaseBoth.js +++ b/common/script/ops/releaseBoth.js @@ -1,10 +1,10 @@ import content from '../content/index'; import i18n from '../i18n'; -module.exports = function (user, req, cb, analytics) { +module.exports = function(user, req, cb, analytics) { var analyticsData, animal, giveTriadBingo; if (user.balance < 1.5 && !user.achievements.triadBingo) { - return typeof cb === 'function' ? cb({ + return typeof cb === "function" ? cb({ code: 401, message: i18n.t('notEnoughGems', req.language) }) : void 0; @@ -17,13 +17,13 @@ module.exports = function (user, req, cb, analytics) { gemCost: 6, category: 'behavior' }; - if (typeof analytics !== 'undefined' && analytics !== null) { + if (typeof analytics !== "undefined" && analytics !== null) { analytics.track('release pets & mounts', analyticsData); } user.balance -= 1.5; } - user.items.currentMount = ''; - user.items.currentPet = ''; + user.items.currentMount = ""; + user.items.currentPet = ""; for (animal in content.pets) { if (user.items.pets[animal] === -1) { giveTriadBingo = false; @@ -46,5 +46,5 @@ module.exports = function (user, req, cb, analytics) { user.achievements.triadBingoCount++; } } - return typeof cb === 'function' ? cb(null, user) : void 0; + return typeof cb === "function" ? cb(null, user) : void 0; }; diff --git a/common/script/ops/releaseMounts.js b/common/script/ops/releaseMounts.js index 1cd4b1cb93..4aefab6b40 100644 --- a/common/script/ops/releaseMounts.js +++ b/common/script/ops/releaseMounts.js @@ -1,16 +1,16 @@ import content from '../content/index'; import i18n from '../i18n'; -module.exports = function (user, req, cb, analytics) { +module.exports = function(user, req, cb, analytics) { var analyticsData, mount; if (user.balance < 1) { - return typeof cb === 'function' ? cb({ + return typeof cb === "function" ? cb({ code: 401, message: i18n.t('notEnoughGems', req.language) }) : void 0; } else { user.balance -= 1; - user.items.currentMount = ''; + user.items.currentMount = ""; for (mount in content.pets) { user.items.mounts[mount] = null; } @@ -25,8 +25,8 @@ module.exports = function (user, req, cb, analytics) { gemCost: 4, category: 'behavior' }; - if (analytics !== null) { + if (analytics != null) { analytics.track('release mounts', analyticsData); } - return typeof cb === 'function' ? cb(null, user) : void 0; + return typeof cb === "function" ? cb(null, user) : void 0; }; diff --git a/common/script/ops/releasePets.js b/common/script/ops/releasePets.js index f26bbd8492..a4b452cd86 100644 --- a/common/script/ops/releasePets.js +++ b/common/script/ops/releasePets.js @@ -1,10 +1,10 @@ import content from '../content/index'; import i18n from '../i18n'; -module.exports = function (user, req, cb, analytics) { +module.exports = function(user, req, cb, analytics) { var analyticsData, pet; if (user.balance < 1) { - return typeof cb === 'function' ? cb({ + return typeof cb === "function" ? cb({ code: 401, message: i18n.t('notEnoughGems', req.language) }) : void 0; @@ -17,7 +17,7 @@ module.exports = function (user, req, cb, analytics) { user.achievements.beastMasterCount = 0; } user.achievements.beastMasterCount++; - user.items.currentPet = ''; + user.items.currentPet = ""; } analyticsData = { uuid: user._id, @@ -25,8 +25,8 @@ module.exports = function (user, req, cb, analytics) { gemCost: 4, category: 'behavior' }; - if (analytics !== null) { + if (analytics != null) { analytics.track('release pets', analyticsData); } - return typeof cb === 'function' ? cb(null, user) : void 0; + return typeof cb === "function" ? cb(null, user) : void 0; }; diff --git a/common/script/ops/reroll.js b/common/script/ops/reroll.js index 23f438abd8..f6a0862f1d 100644 --- a/common/script/ops/reroll.js +++ b/common/script/ops/reroll.js @@ -1,16 +1,16 @@ import i18n from '../i18n'; import _ from 'lodash'; -module.exports = function (user, req, cb, analytics) { +module.exports = function(user, req, cb, analytics) { var analyticsData; if (user.balance < 1) { - return typeof cb === 'function' ? cb({ + return typeof cb === "function" ? cb({ code: 401, message: i18n.t('notEnoughGems', req.language) }) : void 0; } user.balance--; - _.each(user.tasks, function (task) { + _.each(user.tasks, function(task) { if (task.type !== 'reward') { return task.value = 0; } @@ -22,8 +22,8 @@ module.exports = function (user, req, cb, analytics) { gemCost: 4, category: 'behavior' }; - if (analytics !== null) { + if (analytics != null) { analytics.track('Fortify Potion', analyticsData); } - return typeof cb === 'function' ? cb(null, user) : void 0; + return typeof cb === "function" ? cb(null, user) : void 0; }; diff --git a/common/script/ops/reset.js b/common/script/ops/reset.js index dbc0cc5b44..fbe87729e3 100644 --- a/common/script/ops/reset.js +++ b/common/script/ops/reset.js @@ -1,6 +1,6 @@ import _ from 'lodash'; -module.exports = function (user, req, cb) { +module.exports = function(user, req, cb) { var gear; user.habits = []; user.dailys = []; @@ -11,7 +11,7 @@ module.exports = function (user, req, cb) { user.stats.gp = 0; user.stats.exp = 0; gear = user.items.gear; - _.each(['equipped', 'costume'], function (type) { + _.each(['equipped', 'costume'], function(type) { gear[type].armor = 'armor_base_0'; gear[type].weapon = 'weapon_base_0'; gear[type].head = 'head_base_0'; @@ -20,16 +20,16 @@ module.exports = function (user, req, cb) { if (typeof gear.owned === 'undefined') { gear.owned = {}; } - _.each(gear.owned, function (v, k) { + _.each(gear.owned, function(v, k) { if (gear.owned[k]) { gear.owned[k] = false; } return true; }); gear.owned.weapon_warrior_0 = true; - if (typeof user.markModified === 'function') { + if (typeof user.markModified === "function") { user.markModified('items.gear.owned'); } user.preferences.costume = false; - return typeof cb === 'function' ? cb(null, user) : void 0; + return typeof cb === "function" ? cb(null, user) : void 0; }; diff --git a/common/script/ops/revive.js b/common/script/ops/revive.js index f0a2b7bb08..7b6fe8445f 100644 --- a/common/script/ops/revive.js +++ b/common/script/ops/revive.js @@ -2,12 +2,12 @@ import content from '../content/index'; import i18n from '../i18n'; import _ from 'lodash'; -module.exports = function (user, req, cb, analytics) { +module.exports = function(user, req, cb, analytics) { var analyticsData, base, cl, gearOwned, item, losableItems, lostItem, lostStat; if (!(user.stats.hp <= 0)) { - return typeof cb === 'function' ? cb({ + return typeof cb === "function" ? cb({ code: 400, - message: 'Cannot revive if not dead' + message: "Cannot revive if not dead" }) : void 0; } _.merge(user.stats, { @@ -18,7 +18,7 @@ module.exports = function (user, req, cb, analytics) { if (user.stats.lvl > 1) { user.stats.lvl--; } - lostStat = user.fns.randomVal(_.reduce(['str', 'con', 'per', 'int'], (function (m, k) { + lostStat = user.fns.randomVal(_.reduce(['str', 'con', 'per', 'int'], (function(m, k) { if (user.stats[k]) { m[k] = k; } @@ -27,10 +27,10 @@ module.exports = function (user, req, cb, analytics) { if (lostStat) { user.stats[lostStat]--; } - cl = user.stats['class']; - gearOwned = (typeof (base = user.items.gear.owned).toObject === 'function' ? base.toObject() : void 0) || user.items.gear.owned; + cl = user.stats["class"]; + gearOwned = (typeof (base = user.items.gear.owned).toObject === "function" ? base.toObject() : void 0) || user.items.gear.owned; losableItems = {}; - _.each(gearOwned, function (v, k) { + _.each(gearOwned, function(v, k) { var itm; if (v) { itm = content.gear.flat['' + k]; @@ -45,13 +45,13 @@ module.exports = function (user, req, cb, analytics) { if (item = content.gear.flat[lostItem]) { user.items.gear.owned[lostItem] = false; if (user.items.gear.equipped[item.type] === lostItem) { - user.items.gear.equipped[item.type] = item.type + '_base_0'; + user.items.gear.equipped[item.type] = item.type + "_base_0"; } if (user.items.gear.costume[item.type] === lostItem) { - user.items.gear.costume[item.type] = item.type + '_base_0'; + user.items.gear.costume[item.type] = item.type + "_base_0"; } } - if (typeof user.markModified === 'function') { + if (typeof user.markModified === "function") { user.markModified('items.gear'); } analyticsData = { @@ -60,10 +60,10 @@ module.exports = function (user, req, cb, analytics) { gaLabel: lostItem, category: 'behavior' }; - if (analytics !== null) { + if (analytics != null) { analytics.track('Death', analyticsData); } - return typeof cb === 'function' ? cb((item ? { + return typeof cb === "function" ? cb((item ? { code: 200, message: i18n.t('messageLostItem', { itemText: item.text(req.language) diff --git a/common/script/ops/score.js b/common/script/ops/score.js index 75f473a24f..ec0d2a70e2 100644 --- a/common/script/ops/score.js +++ b/common/script/ops/score.js @@ -2,7 +2,7 @@ import moment from 'moment'; import _ from 'lodash'; import i18n from '../i18n'; -module.exports = function (user, req, cb) { +module.exports = function(user, req, cb) { var addPoints, calculateDelta, calculateReverseDelta, changeTaskValue, delta, direction, gainMP, id, multiplier, num, options, ref, stats, subtractPoints, task, th; ref = req.params, id = ref.id, direction = ref.direction; task = user.tasks[id]; @@ -19,35 +19,35 @@ module.exports = function (user, req, cb) { }; task.value = +task.value; task.streak = ~~task.streak; - if (task.priority === null) { + if (task.priority == null) { task.priority = 1; } if (task.value > stats.gp && task.type === 'reward') { - return typeof cb === 'function' ? cb({ + return typeof cb === "function" ? cb({ code: 401, message: i18n.t('messageNotEnoughGold', req.language) }) : void 0; } delta = 0; - calculateDelta = function () { + calculateDelta = function() { var currVal, nextDelta, ref1; currVal = task.value < -47.27 ? -47.27 : task.value > 21.27 ? 21.27 : task.value; nextDelta = Math.pow(0.9747, currVal) * (direction === 'down' ? -1 : 1); - if (((ref1 = task.checklist) !== null ? ref1.length : void 0) > 0) { + if (((ref1 = task.checklist) != null ? ref1.length : void 0) > 0) { if (direction === 'down' && task.type === 'daily' && options.cron) { - nextDelta *= 1 - _.reduce(task.checklist, (function (m, i) { + nextDelta *= 1 - _.reduce(task.checklist, (function(m, i) { return m + (i.completed ? 1 : 0); }), 0) / task.checklist.length; } if (task.type === 'todo') { - nextDelta *= 1 + _.reduce(task.checklist, (function (m, i) { + nextDelta *= 1 + _.reduce(task.checklist, (function(m, i) { return m + (i.completed ? 1 : 0); }), 0); } } return nextDelta; }; - calculateReverseDelta = function () { + calculateReverseDelta = function() { var calc, closeEnough, currVal, diff, nextDelta, ref1, testVal; currVal = task.value < -47.27 ? -47.27 : task.value > 21.27 ? 21.27 : task.value; testVal = currVal + Math.pow(0.9747, currVal) * (direction === 'down' ? -1 : 1); @@ -65,17 +65,17 @@ module.exports = function (user, req, cb) { } } nextDelta = testVal - currVal; - if (((ref1 = task.checklist) !== null ? ref1.length : void 0) > 0) { + if (((ref1 = task.checklist) != null ? ref1.length : void 0) > 0) { if (task.type === 'todo') { - nextDelta *= 1 + _.reduce(task.checklist, (function (m, i) { + nextDelta *= 1 + _.reduce(task.checklist, (function(m, i) { return m + (i.completed ? 1 : 0); }), 0); } } return nextDelta; }; - changeTaskValue = function () { - return _.times(options.times, function () { + changeTaskValue = function() { + return _.times(options.times, function() { var nextDelta, ref1; nextDelta = !options.cron && direction === 'down' ? calculateReverseDelta() : calculateDelta(); if (task.type !== 'reward') { @@ -96,7 +96,7 @@ module.exports = function (user, req, cb) { return delta += nextDelta; }); }; - addPoints = function () { + addPoints = function() { var _crit, afterStreak, currStreak, gpMod, intBonus, perBonus, streakBonus; _crit = (delta > 0 ? user.fns.crit() : 1); if (_crit > 1) { @@ -108,7 +108,7 @@ module.exports = function (user, req, cb) { gpMod = delta * task.priority * _crit * perBonus; return stats.gp += task.streak ? (currStreak = direction === 'down' ? task.streak - 1 : task.streak, streakBonus = currStreak / 100 + 1, afterStreak = gpMod * streakBonus, currStreak > 0 ? gpMod > 0 ? user._tmp.streakBonus = afterStreak - gpMod : void 0 : void 0, afterStreak) : gpMod; }; - subtractPoints = function () { + subtractPoints = function() { var conBonus, hpMod; conBonus = 1 - (user._statsComputed.con / 250); if (conBonus < .1) { @@ -117,7 +117,7 @@ module.exports = function (user, req, cb) { hpMod = delta * conBonus * task.priority * 2; return stats.hp += Math.round(hpMod * 10) / 10; }; - gainMP = function (delta) { + gainMP = function(delta) { delta *= user._tmp.crit || 1; user.stats.mp += delta; if (user.stats.mp >= user._statsComputed.maxMP) { @@ -136,7 +136,7 @@ module.exports = function (user, req, cb) { subtractPoints(); } gainMP(_.max([0.25, .0025 * user._statsComputed.maxMP]) * (direction === 'down' ? -1 : 1)); - th = (task.history !== null ? task.history : task.history = []); + th = (task.history != null ? task.history : task.history = []); if (th[th.length - 1] && moment(th[th.length - 1].date).isSame(new Date, 'day')) { th[th.length - 1].value = task.value; } else { @@ -145,10 +145,10 @@ module.exports = function (user, req, cb) { value: task.value }); } - if (typeof user.markModified === 'function') { - user.markModified('habits.' + (_.findIndex(user.habits, { + if (typeof user.markModified === "function") { + user.markModified("habits." + (_.findIndex(user.habits, { id: task.id - })) + '.history'); + })) + ".history"); } break; case 'daily': @@ -189,7 +189,7 @@ module.exports = function (user, req, cb) { } addPoints(); multiplier = _.max([ - _.reduce(task.checklist, (function (m, i) { + _.reduce(task.checklist, (function(m, i) { return m + (i.completed ? 1 : 0); }), 1), 1 ]); @@ -214,7 +214,7 @@ module.exports = function (user, req, cb) { }, req); } } - if (typeof cb === 'function') { + if (typeof cb === "function") { cb(null, user); } return delta; diff --git a/common/script/ops/sell.js b/common/script/ops/sell.js index b41846554a..33e5f7d673 100644 --- a/common/script/ops/sell.js +++ b/common/script/ops/sell.js @@ -2,22 +2,22 @@ import content from '../content/index'; import _ from 'lodash'; import splitWhitespace from '../libs/splitWhitespace'; -module.exports = function (user, req, cb) { +module.exports = function(user, req, cb) { var key, ref, type; ref = req.params, key = ref.key, type = ref.type; if (type !== 'eggs' && type !== 'hatchingPotions' && type !== 'food') { - return typeof cb === 'function' ? cb({ + return typeof cb === "function" ? cb({ code: 404, - message: ':type not found. Must bes in [eggs, hatchingPotions, food]' + message: ":type not found. Must bes in [eggs, hatchingPotions, food]" }) : void 0; } if (!user.items[type][key]) { - return typeof cb === 'function' ? cb({ + return typeof cb === "function" ? cb({ code: 404, - message: ':key not found for user.items.' + type + message: ":key not found for user.items." + type }) : void 0; } user.items[type][key]--; user.stats.gp += content[type][key].value; - return typeof cb === 'function' ? cb(null, _.pick(user, splitWhitespace('stats items'))) : void 0; + return typeof cb === "function" ? cb(null, _.pick(user, splitWhitespace('stats items'))) : void 0; }; diff --git a/common/script/ops/sleep.js b/common/script/ops/sleep.js index c8ecc3d1ab..dec8095ad3 100644 --- a/common/script/ops/sleep.js +++ b/common/script/ops/sleep.js @@ -1,4 +1,4 @@ -module.exports = function (user, req, cb) { +module.exports = function(user, req, cb) { user.preferences.sleep = !user.preferences.sleep; - return typeof cb === 'function' ? cb(null, {}) : void 0; + return typeof cb === "function" ? cb(null, {}) : void 0; }; diff --git a/common/script/ops/sortTag.js b/common/script/ops/sortTag.js index 77cc0be7a4..85dcda169f 100644 --- a/common/script/ops/sortTag.js +++ b/common/script/ops/sortTag.js @@ -1,9 +1,9 @@ -module.exports = function (user, req, cb) { +module.exports = function(user, req, cb) { var from, ref, to; ref = req.query, to = ref.to, from = ref.from; - if (!((to !== null) && (from !== null))) { - return typeof cb === 'function' ? cb('?to=__&from=__ are required') : void 0; + if (!((to != null) && (from != null))) { + return typeof cb === "function" ? cb('?to=__&from=__ are required') : void 0; } user.tags.splice(to, 0, user.tags.splice(from, 1)[0]); - return typeof cb === 'function' ? cb(null, user.tags) : void 0; + return typeof cb === "function" ? cb(null, user.tags) : void 0; }; diff --git a/common/script/ops/sortTask.js b/common/script/ops/sortTask.js index bed1758aa7..73b60ebb06 100644 --- a/common/script/ops/sortTask.js +++ b/common/script/ops/sortTask.js @@ -1,30 +1,30 @@ import i18n from '../i18n'; import preenTodos from '../libs/preenTodos'; -module.exports = function (user, req, cb) { +module.exports = function(user, req, cb) { var from, id, movedTask, preenedTasks, ref, task, tasks, to; id = req.params.id; ref = req.query, to = ref.to, from = ref.from; task = user.tasks[id]; if (!task) { - return typeof cb === 'function' ? cb({ + return typeof cb === "function" ? cb({ code: 404, message: i18n.t('messageTaskNotFound', req.language) }) : void 0; } - if (!((to !== null) && (from !== null))) { - return typeof cb === 'function' ? cb('?to=__&from=__ are required') : void 0; + if (!((to != null) && (from != null))) { + return typeof cb === "function" ? cb('?to=__&from=__ are required') : void 0; } - tasks = user[task.type + 's']; + tasks = user[task.type + "s"]; if (task.type === 'todo' && tasks[from] !== task) { - preenedTasks = preenTodos(tasks); + preenedTasks = api.preenTodos(tasks); if (to !== -1) { to = tasks.indexOf(preenedTasks[to]); } from = tasks.indexOf(preenedTasks[from]); } if (tasks[from] !== task) { - return typeof cb === 'function' ? cb({ + return typeof cb === "function" ? cb({ code: 404, message: i18n.t('messageTaskNotFound', req.language) }) : void 0; @@ -35,5 +35,5 @@ module.exports = function (user, req, cb) { } else { tasks.splice(to, 0, movedTask); } - return typeof cb === 'function' ? cb(null, tasks) : void 0; + return typeof cb === "function" ? cb(null, tasks) : void 0; }; diff --git a/common/script/ops/unlock.js b/common/script/ops/unlock.js index 4d3adda2ca..c53a5997ec 100644 --- a/common/script/ops/unlock.js +++ b/common/script/ops/unlock.js @@ -2,27 +2,27 @@ import i18n from '../i18n'; import _ from 'lodash'; import splitWhitespace from '../libs/splitWhitespace'; -module.exports = function (user, req, cb, analytics) { +module.exports = function(user, req, cb, analytics) { var alreadyOwns, analyticsData, cost, fullSet, k, path, split, v; path = req.query.path; - fullSet = ~path.indexOf(','); + fullSet = ~path.indexOf(","); cost = ~path.indexOf('background.') ? fullSet ? 3.75 : 1.75 : fullSet ? 1.25 : 0.5; - alreadyOwns = !fullSet && user.fns.dotGet('purchased.' + path) === true; + alreadyOwns = !fullSet && user.fns.dotGet("purchased." + path) === true; if ((user.balance < cost || !user.balance) && !alreadyOwns) { - return typeof cb === 'function' ? cb({ + return typeof cb === "function" ? cb({ code: 401, message: i18n.t('notEnoughGems', req.language) }) : void 0; } if (fullSet) { - _.each(path.split(','), function (p) { + _.each(path.split(","), function(p) { if (~path.indexOf('gear.')) { - user.fns.dotSet('' + p, true); + user.fns.dotSet("" + p, true); true; } else { } - user.fns.dotSet('purchased.' + p, true); + user.fns.dotSet("purchased." + p, true); return true; }); } else { @@ -33,18 +33,18 @@ module.exports = function (user, req, cb, analytics) { if (k === 'background' && v === user.preferences.background) { v = ''; } - user.fns.dotSet('preferences.' + k, v); - return typeof cb === 'function' ? cb(null, req) : void 0; + user.fns.dotSet("preferences." + k, v); + return typeof cb === "function" ? cb(null, req) : void 0; } - user.fns.dotSet('purchased.' + path, true); + user.fns.dotSet("purchased." + path, true); } user.balance -= cost; if (~path.indexOf('gear.')) { - if (typeof user.markModified === 'function') { + if (typeof user.markModified === "function") { user.markModified('gear.owned'); } } else { - if (typeof user.markModified === 'function') { + if (typeof user.markModified === "function") { user.markModified('purchased'); } } @@ -56,8 +56,8 @@ module.exports = function (user, req, cb, analytics) { gemCost: cost / .25, category: 'behavior' }; - if (analytics !== null) { + if (analytics != null) { analytics.track('acquire item', analyticsData); } - return typeof cb === 'function' ? cb(null, _.pick(user, splitWhitespace('purchased preferences items'))) : void 0; + return typeof cb === "function" ? cb(null, _.pick(user, splitWhitespace('purchased preferences items'))) : void 0; }; diff --git a/common/script/ops/update.js b/common/script/ops/update.js index 963f8f6cba..12a100e372 100644 --- a/common/script/ops/update.js +++ b/common/script/ops/update.js @@ -1,9 +1,9 @@ import _ from 'lodash'; -module.exports = function (user, req, cb) { - _.each(req.body, function (v, k) { +module.exports = function(user, req, cb) { + _.each(req.body, function(v, k) { user.fns.dotSet(k, v); return true; }); - return typeof cb === 'function' ? cb(null, user) : void 0; + return typeof cb === "function" ? cb(null, user) : void 0; }; diff --git a/common/script/ops/updateTag.js b/common/script/ops/updateTag.js index d1b54e51b6..8e4019fa51 100644 --- a/common/script/ops/updateTag.js +++ b/common/script/ops/updateTag.js @@ -1,18 +1,18 @@ import i18n from '../i18n'; import _ from 'lodash'; -module.exports = function (user, req, cb) { +module.exports = function(user, req, cb) { var i, tid; tid = req.params.id; i = _.findIndex(user.tags, { id: tid }); if (!~i) { - return typeof cb === 'function' ? cb({ + return typeof cb === "function" ? cb({ code: 404, message: i18n.t('messageTagNotFound', req.language) }) : void 0; } user.tags[i].name = req.body.name; - return typeof cb === 'function' ? cb(null, user.tags[i]) : void 0; + return typeof cb === "function" ? cb(null, user.tags[i]) : void 0; }; diff --git a/common/script/ops/updateTask.js b/common/script/ops/updateTask.js index ede672c71e..eb7baee434 100644 --- a/common/script/ops/updateTask.js +++ b/common/script/ops/updateTask.js @@ -1,10 +1,10 @@ import i18n from '../i18n'; import _ from 'lodash'; -module.exports = function (user, req, cb) { +module.exports = function(user, req, cb) { var ref, task; - if (!(task = user.tasks[(ref = req.params) !== null ? ref.id : void 0])) { - return typeof cb === 'function' ? cb({ + if (!(task = user.tasks[(ref = req.params) != null ? ref.id : void 0])) { + return typeof cb === "function" ? cb({ code: 404, message: i18n.t('messageTaskNotFound', req.language) }) : void 0; @@ -13,8 +13,8 @@ module.exports = function (user, req, cb) { if (req.body.checklist) { task.checklist = req.body.checklist; } - if (typeof task.markModified === 'function') { + if (typeof task.markModified === "function") { task.markModified('tags'); } - return typeof cb === 'function' ? cb(null, task) : void 0; + return typeof cb === "function" ? cb(null, task) : void 0; }; diff --git a/common/script/ops/updateWebhook.js b/common/script/ops/updateWebhook.js index 19d712a027..e2775a40b4 100644 --- a/common/script/ops/updateWebhook.js +++ b/common/script/ops/updateWebhook.js @@ -1,9 +1,9 @@ import _ from 'lodash'; -module.exports = function (user, req, cb) { +module.exports = function(user, req, cb) { _.merge(user.preferences.webhooks[req.params.id], req.body); - if (typeof user.markModified === 'function') { + if (typeof user.markModified === "function") { user.markModified('preferences.webhooks'); } - return typeof cb === 'function' ? cb(null, user.preferences.webhooks) : void 0; + return typeof cb === "function" ? cb(null, user.preferences.webhooks) : void 0; }; diff --git a/test/common/user.ops.hourglassPurchase.test.js b/test/common/user.ops.hourglassPurchase.test.js index 0f4cff118f..b9c7369d21 100644 --- a/test/common/user.ops.hourglassPurchase.test.js +++ b/test/common/user.ops.hourglassPurchase.test.js @@ -107,7 +107,7 @@ describe('user.ops.hourglassPurchase', () => { }); }); - it.only('buys a mount', (done) => { + it('buys a mount', (done) => { user.purchased.plan.consecutive.trinkets = 2; user.ops.hourglassPurchase({params: {type: 'mounts', key: 'MantisShrimp-Base'}}, (response) => {