remove all changes from eslint --fix

This commit is contained in:
Matteo Pagliazzi
2016-03-08 17:45:14 +01:00
parent eeebe4c342
commit 5a2daabada
37 changed files with 224 additions and 223 deletions

View File

@@ -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;
};

View File

@@ -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;
}

View File

@@ -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;
};

View File

@@ -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;
};

View File

@@ -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;
};

View File

@@ -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;
};

View File

@@ -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;
};

View File

@@ -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;
};

View File

@@ -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;
};

View File

@@ -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;
};

View File

@@ -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;

View File

@@ -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
}, {

View File

@@ -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;
};

View File

@@ -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;
};

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;
};

View File

@@ -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;
};

View File

@@ -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;
};

View File

@@ -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;
};

View File

@@ -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;
};

View File

@@ -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;
};

View File

@@ -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;
};

View File

@@ -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;
};

View File

@@ -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;
};

View File

@@ -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)

View File

@@ -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;

View File

@@ -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;
};

View File

@@ -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;
};

View File

@@ -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;
};

View File

@@ -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;
};

View File

@@ -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;
};

View File

@@ -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;
};

View File

@@ -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;
};

View File

@@ -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;
};

View File

@@ -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;
};

View File

@@ -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) => {