mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-17 14:47:53 +01:00
remove all changes from eslint --fix
This commit is contained in:
@@ -11,5 +11,5 @@ module.exports = function(user, req, cb) {
|
|||||||
user.stats.mp++;
|
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;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -108,7 +108,7 @@ module.exports = function(user, req, cb, analytics) {
|
|||||||
if (analytics != null) {
|
if (analytics != null) {
|
||||||
analytics.track('acquire item', analyticsData);
|
analytics.track('acquire item', analyticsData);
|
||||||
}
|
}
|
||||||
buyResp = _.pick(user, $w('items achievements stats flags'));
|
buyResp = _.pick(user, splitWhitespace('items achievements stats flags'));
|
||||||
if (armoireResp) {
|
if (armoireResp) {
|
||||||
buyResp["armoire"] = armoireResp;
|
buyResp["armoire"] = armoireResp;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,5 +39,5 @@ module.exports = function(user, req, cb, analytics) {
|
|||||||
return typeof cb === "function" ? cb({
|
return typeof cb === "function" ? cb({
|
||||||
code: 200,
|
code: 200,
|
||||||
message: i18n.t('hourglassPurchaseSet', req.language)
|
message: i18n.t('hourglassPurchaseSet', req.language)
|
||||||
}, _.pick(user, $w('items purchased.plan.consecutive'))) : void 0;
|
}, _.pick(user, splitWhitespace('items purchased.plan.consecutive'))) : void 0;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -27,5 +27,5 @@ module.exports = function(user, req, cb) {
|
|||||||
return typeof cb === "function" ? cb({
|
return typeof cb === "function" ? cb({
|
||||||
code: 200,
|
code: 200,
|
||||||
message: message
|
message: message
|
||||||
}, _.pick(user, $w('items stats'))) : void 0;
|
}, _.pick(user, splitWhitespace('items stats'))) : void 0;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -55,5 +55,5 @@ module.exports = function(user, req, cb, analytics) {
|
|||||||
});
|
});
|
||||||
user.flags.classSelected = false;
|
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;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
module.exports = function (user, req, cb) {
|
module.exports = function(user, req, cb) {
|
||||||
delete user.inbox.messages[req.params.id];
|
delete user.inbox.messages[req.params.id];
|
||||||
if (typeof user.markModified === 'function') {
|
if (typeof user.markModified === "function") {
|
||||||
user.markModified('inbox.messages.' + req.params.id);
|
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;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,14 +1,14 @@
|
|||||||
import i18n from '../i18n';
|
import i18n from '../i18n';
|
||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
|
|
||||||
module.exports = function (user, req, cb) {
|
module.exports = function(user, req, cb) {
|
||||||
var i, tag, tid;
|
var i, tag, tid;
|
||||||
tid = req.params.id;
|
tid = req.params.id;
|
||||||
i = _.findIndex(user.tags, {
|
i = _.findIndex(user.tags, {
|
||||||
id: tid
|
id: tid
|
||||||
});
|
});
|
||||||
if (!~i) {
|
if (!~i) {
|
||||||
return typeof cb === 'function' ? cb({
|
return typeof cb === "function" ? cb({
|
||||||
code: 404,
|
code: 404,
|
||||||
message: i18n.t('messageTagNotFound', req.language)
|
message: i18n.t('messageTagNotFound', req.language)
|
||||||
}) : void 0;
|
}) : void 0;
|
||||||
@@ -16,11 +16,11 @@ module.exports = function (user, req, cb) {
|
|||||||
tag = user.tags[i];
|
tag = user.tags[i];
|
||||||
delete user.filters[tag.id];
|
delete user.filters[tag.id];
|
||||||
user.tags.splice(i, 1);
|
user.tags.splice(i, 1);
|
||||||
_.each(user.tasks, function (task) {
|
_.each(user.tasks, function(task) {
|
||||||
return delete task.tags[tag.id];
|
return delete task.tags[tag.id];
|
||||||
});
|
});
|
||||||
_.each(['habits', 'dailys', 'todos', 'rewards'], function (type) {
|
_.each(['habits', 'dailys', 'todos', 'rewards'], function(type) {
|
||||||
return typeof user.markModified === 'function' ? user.markModified(type) : void 0;
|
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;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,17 +1,17 @@
|
|||||||
import i18n from '../i18n';
|
import i18n from '../i18n';
|
||||||
|
|
||||||
module.exports = function (user, req, cb) {
|
module.exports = function(user, req, cb) {
|
||||||
var i, ref, task;
|
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) {
|
if (!task) {
|
||||||
return typeof cb === 'function' ? cb({
|
return typeof cb === "function" ? cb({
|
||||||
code: 404,
|
code: 404,
|
||||||
message: i18n.t('messageTaskNotFound', req.language)
|
message: i18n.t('messageTaskNotFound', req.language)
|
||||||
}) : void 0;
|
}) : void 0;
|
||||||
}
|
}
|
||||||
i = user[task.type + 's'].indexOf(task);
|
i = user[task.type + "s"].indexOf(task);
|
||||||
if (~i) {
|
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;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
module.exports = function (user, req, cb) {
|
module.exports = function(user, req, cb) {
|
||||||
delete user.preferences.webhooks[req.params.id];
|
delete user.preferences.webhooks[req.params.id];
|
||||||
if (typeof user.markModified === 'function') {
|
if (typeof user.markModified === "function") {
|
||||||
user.markModified('preferences.webhooks');
|
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;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -2,12 +2,12 @@ import splitWhitespace from '../libs/splitWhitespace';
|
|||||||
import { capByLevel } from '../statHelpers';
|
import { capByLevel } from '../statHelpers';
|
||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
|
|
||||||
module.exports = function (user, req, cb) {
|
module.exports = function(user, req, cb) {
|
||||||
user.stats['class'] = 'warrior';
|
user.stats["class"] = 'warrior';
|
||||||
user.flags.classSelected = true;
|
user.flags.classSelected = true;
|
||||||
user.preferences.disableClasses = true;
|
user.preferences.disableClasses = true;
|
||||||
user.preferences.autoAllocate = true;
|
user.preferences.autoAllocate = true;
|
||||||
user.stats.str = capByLevel(user.stats.lvl);
|
user.stats.str = api.capByLevel(user.stats.lvl);
|
||||||
user.stats.points = 0;
|
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;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,24 +1,24 @@
|
|||||||
import content from '../content/index';
|
import content from '../content/index';
|
||||||
import i18n from '../i18n';
|
import i18n from '../i18n';
|
||||||
|
|
||||||
module.exports = function (user, req, cb) {
|
module.exports = function(user, req, cb) {
|
||||||
var item, key, message, ref, type;
|
var item, key, message, ref, type;
|
||||||
ref = [req.params.type || 'equipped', req.params.key], type = ref[0], key = ref[1];
|
ref = [req.params.type || 'equipped', req.params.key], type = ref[0], key = ref[1];
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case 'mount':
|
case 'mount':
|
||||||
if (!user.items.mounts[key]) {
|
if (!user.items.mounts[key]) {
|
||||||
return typeof cb === 'function' ? cb({
|
return typeof cb === "function" ? cb({
|
||||||
code: 404,
|
code: 404,
|
||||||
message: ':You do not own this mount.'
|
message: ":You do not own this mount."
|
||||||
}) : void 0;
|
}) : void 0;
|
||||||
}
|
}
|
||||||
user.items.currentMount = user.items.currentMount === key ? '' : key;
|
user.items.currentMount = user.items.currentMount === key ? '' : key;
|
||||||
break;
|
break;
|
||||||
case 'pet':
|
case 'pet':
|
||||||
if (!user.items.pets[key]) {
|
if (!user.items.pets[key]) {
|
||||||
return typeof cb === 'function' ? cb({
|
return typeof cb === "function" ? cb({
|
||||||
code: 404,
|
code: 404,
|
||||||
message: ':You do not own this pet.'
|
message: ":You do not own this pet."
|
||||||
}) : void 0;
|
}) : void 0;
|
||||||
}
|
}
|
||||||
user.items.currentPet = user.items.currentPet === key ? '' : key;
|
user.items.currentPet = user.items.currentPet === key ? '' : key;
|
||||||
@@ -27,13 +27,13 @@ module.exports = function (user, req, cb) {
|
|||||||
case 'equipped':
|
case 'equipped':
|
||||||
item = content.gear.flat[key];
|
item = content.gear.flat[key];
|
||||||
if (!user.items.gear.owned[key]) {
|
if (!user.items.gear.owned[key]) {
|
||||||
return typeof cb === 'function' ? cb({
|
return typeof cb === "function" ? cb({
|
||||||
code: 404,
|
code: 404,
|
||||||
message: ':You do not own this gear.'
|
message: ":You do not own this gear."
|
||||||
}) : void 0;
|
}) : void 0;
|
||||||
}
|
}
|
||||||
if (user.items.gear[type][item.type] === key) {
|
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', {
|
message = i18n.t('messageUnEquipped', {
|
||||||
itemText: item.text(req.language)
|
itemText: item.text(req.language)
|
||||||
}, req.language);
|
}, req.language);
|
||||||
@@ -41,11 +41,11 @@ module.exports = function (user, req, cb) {
|
|||||||
user.items.gear[type][item.type] = item.key;
|
user.items.gear[type][item.type] = item.key;
|
||||||
message = user.fns.handleTwoHanded(item, type, req);
|
message = user.fns.handleTwoHanded(item, type, req);
|
||||||
}
|
}
|
||||||
if (typeof user.markModified === 'function') {
|
if (typeof user.markModified === "function") {
|
||||||
user.markModified('items.gear.' + type);
|
user.markModified("items.gear." + type);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return typeof cb === 'function' ? cb((message ? {
|
return typeof cb === "function" ? cb((message ? {
|
||||||
code: 200,
|
code: 200,
|
||||||
message: message
|
message: message
|
||||||
} : null), user.items) : void 0;
|
} : null), user.items) : void 0;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import content from '../content/index';
|
import content from '../content/index';
|
||||||
import i18n from '../i18n';
|
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;
|
var egg, eggText, evolve, food, message, pet, petDisplayName, potion, potionText, ref, ref1, ref2, userPets;
|
||||||
ref = req.params, pet = ref.pet, food = ref.food;
|
ref = req.params, pet = ref.pet, food = ref.food;
|
||||||
food = content.food[food];
|
food = content.food[food];
|
||||||
@@ -14,35 +14,35 @@ module.exports = function (user, req, cb) {
|
|||||||
egg: eggText
|
egg: eggText
|
||||||
});
|
});
|
||||||
if (!userPets[pet]) {
|
if (!userPets[pet]) {
|
||||||
return typeof cb === 'function' ? cb({
|
return typeof cb === "function" ? cb({
|
||||||
code: 404,
|
code: 404,
|
||||||
message: i18n.t('messagePetNotFound', req.language)
|
message: i18n.t('messagePetNotFound', req.language)
|
||||||
}) : void 0;
|
}) : void 0;
|
||||||
}
|
}
|
||||||
if (!((ref2 = user.items.food) !== null ? ref2[food.key] : void 0)) {
|
if (!((ref2 = user.items.food) != null ? ref2[food.key] : void 0)) {
|
||||||
return typeof cb === 'function' ? cb({
|
return typeof cb === "function" ? cb({
|
||||||
code: 404,
|
code: 404,
|
||||||
message: i18n.t('messageFoodNotFound', req.language)
|
message: i18n.t('messageFoodNotFound', req.language)
|
||||||
}) : void 0;
|
}) : void 0;
|
||||||
}
|
}
|
||||||
if (content.specialPets[pet]) {
|
if (content.specialPets[pet]) {
|
||||||
return typeof cb === 'function' ? cb({
|
return typeof cb === "function" ? cb({
|
||||||
code: 401,
|
code: 401,
|
||||||
message: i18n.t('messageCannotFeedPet', req.language)
|
message: i18n.t('messageCannotFeedPet', req.language)
|
||||||
}) : void 0;
|
}) : void 0;
|
||||||
}
|
}
|
||||||
if (user.items.mounts[pet]) {
|
if (user.items.mounts[pet]) {
|
||||||
return typeof cb === 'function' ? cb({
|
return typeof cb === "function" ? cb({
|
||||||
code: 401,
|
code: 401,
|
||||||
message: i18n.t('messageAlreadyMount', req.language)
|
message: i18n.t('messageAlreadyMount', req.language)
|
||||||
}) : void 0;
|
}) : void 0;
|
||||||
}
|
}
|
||||||
message = '';
|
message = '';
|
||||||
evolve = function () {
|
evolve = function() {
|
||||||
userPets[pet] = -1;
|
userPets[pet] = -1;
|
||||||
user.items.mounts[pet] = true;
|
user.items.mounts[pet] = true;
|
||||||
if (pet === user.items.currentPet) {
|
if (pet === user.items.currentPet) {
|
||||||
user.items.currentPet = '';
|
user.items.currentPet = "";
|
||||||
}
|
}
|
||||||
return message = i18n.t('messageEvolve', {
|
return message = i18n.t('messageEvolve', {
|
||||||
egg: petDisplayName
|
egg: petDisplayName
|
||||||
@@ -69,7 +69,7 @@ module.exports = function (user, req, cb) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
user.items.food[food.key]--;
|
user.items.food[food.key]--;
|
||||||
return typeof cb === 'function' ? cb({
|
return typeof cb === "function" ? cb({
|
||||||
code: 200,
|
code: 200,
|
||||||
message: message
|
message: message
|
||||||
}, {
|
}, {
|
||||||
|
|||||||
@@ -1,17 +1,17 @@
|
|||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
import i18n from '../i18n';
|
import i18n from '../i18n';
|
||||||
|
|
||||||
module.exports = function (user, req, cb) {
|
module.exports = function(user, req, cb) {
|
||||||
var i, tid;
|
var i, tid;
|
||||||
tid = req.params.id;
|
tid = req.params.id;
|
||||||
i = _.findIndex(user.tags, {
|
i = _.findIndex(user.tags, {
|
||||||
id: tid
|
id: tid
|
||||||
});
|
});
|
||||||
if (!~i) {
|
if (!~i) {
|
||||||
return typeof cb === 'function' ? cb({
|
return typeof cb === "function" ? cb({
|
||||||
code: 404,
|
code: 404,
|
||||||
message: i18n.t('messageTagNotFound', req.language)
|
message: i18n.t('messageTagNotFound', req.language)
|
||||||
}) : void 0;
|
}) : void 0;
|
||||||
}
|
}
|
||||||
return typeof cb === 'function' ? cb(null, user.tags[i]) : void 0;
|
return typeof cb === "function" ? cb(null, user.tags[i]) : void 0;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
module.exports = function (user, req, cb) {
|
module.exports = function(user, req, cb) {
|
||||||
return typeof cb === 'function' ? cb(null, user.tags) : void 0;
|
return typeof cb === "function" ? cb(null, user.tags) : void 0;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,30 +1,30 @@
|
|||||||
import content from '../content/index';
|
import content from '../content/index';
|
||||||
import i18n from '../i18n';
|
import i18n from '../i18n';
|
||||||
|
|
||||||
module.exports = function (user, req, cb) {
|
module.exports = function(user, req, cb) {
|
||||||
var egg, hatchingPotion, pet, ref;
|
var egg, hatchingPotion, pet, ref;
|
||||||
ref = req.params, egg = ref.egg, hatchingPotion = ref.hatchingPotion;
|
ref = req.params, egg = ref.egg, hatchingPotion = ref.hatchingPotion;
|
||||||
if (!(egg && hatchingPotion)) {
|
if (!(egg && hatchingPotion)) {
|
||||||
return typeof cb === 'function' ? cb({
|
return typeof cb === "function" ? cb({
|
||||||
code: 400,
|
code: 400,
|
||||||
message: 'Please specify query.egg & query.hatchingPotion'
|
message: "Please specify query.egg & query.hatchingPotion"
|
||||||
}) : void 0;
|
}) : void 0;
|
||||||
}
|
}
|
||||||
if (!(user.items.eggs[egg] > 0 && user.items.hatchingPotions[hatchingPotion] > 0)) {
|
if (!(user.items.eggs[egg] > 0 && user.items.hatchingPotions[hatchingPotion] > 0)) {
|
||||||
return typeof cb === 'function' ? cb({
|
return typeof cb === "function" ? cb({
|
||||||
code: 403,
|
code: 403,
|
||||||
message: i18n.t('messageMissingEggPotion', req.language)
|
message: i18n.t('messageMissingEggPotion', req.language)
|
||||||
}) : void 0;
|
}) : void 0;
|
||||||
}
|
}
|
||||||
if (content.hatchingPotions[hatchingPotion].premium && !content.dropEggs[egg]) {
|
if (content.hatchingPotions[hatchingPotion].premium && !content.dropEggs[egg]) {
|
||||||
return typeof cb === 'function' ? cb({
|
return typeof cb === "function" ? cb({
|
||||||
code: 403,
|
code: 403,
|
||||||
message: i18n.t('messageInvalidEggPotionCombo', req.language)
|
message: i18n.t('messageInvalidEggPotionCombo', req.language)
|
||||||
}) : void 0;
|
}) : void 0;
|
||||||
}
|
}
|
||||||
pet = egg + '-' + hatchingPotion;
|
pet = egg + "-" + hatchingPotion;
|
||||||
if (user.items.pets[pet] && user.items.pets[pet] > 0) {
|
if (user.items.pets[pet] && user.items.pets[pet] > 0) {
|
||||||
return typeof cb === 'function' ? cb({
|
return typeof cb === "function" ? cb({
|
||||||
code: 403,
|
code: 403,
|
||||||
message: i18n.t('messageAlreadyPet', req.language)
|
message: i18n.t('messageAlreadyPet', req.language)
|
||||||
}) : void 0;
|
}) : void 0;
|
||||||
@@ -32,7 +32,7 @@ module.exports = function (user, req, cb) {
|
|||||||
user.items.pets[pet] = 5;
|
user.items.pets[pet] = 5;
|
||||||
user.items.eggs[egg]--;
|
user.items.eggs[egg]--;
|
||||||
user.items.hatchingPotions[hatchingPotion]--;
|
user.items.hatchingPotions[hatchingPotion]--;
|
||||||
return typeof cb === 'function' ? cb({
|
return typeof cb === "function" ? cb({
|
||||||
code: 200,
|
code: 200,
|
||||||
message: i18n.t('messageHatched', req.language)
|
message: i18n.t('messageHatched', req.language)
|
||||||
}, user.items) : void 0;
|
}, user.items) : void 0;
|
||||||
|
|||||||
@@ -3,29 +3,29 @@ import i18n from '../i18n';
|
|||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
import splitWhitespace from '../libs/splitWhitespace';
|
import splitWhitespace from '../libs/splitWhitespace';
|
||||||
|
|
||||||
module.exports = function (user, req, cb, analytics) {
|
module.exports = function(user, req, cb, analytics) {
|
||||||
var analyticsData, key, ref, type;
|
var analyticsData, key, ref, type;
|
||||||
ref = req.params, type = ref.type, key = ref.key;
|
ref = req.params, type = ref.type, key = ref.key;
|
||||||
if (!content.timeTravelStable[type]) {
|
if (!content.timeTravelStable[type]) {
|
||||||
return typeof cb === 'function' ? cb({
|
return typeof cb === "function" ? cb({
|
||||||
code: 403,
|
code: 403,
|
||||||
message: i18n.t('typeNotAllowedHourglass', req.language) + JSON.stringify(_.keys(content.timeTravelStable))
|
message: i18n.t('typeNotAllowedHourglass', req.language) + JSON.stringify(_.keys(content.timeTravelStable))
|
||||||
}) : void 0;
|
}) : void 0;
|
||||||
}
|
}
|
||||||
if (!_.contains(_.keys(content.timeTravelStable[type]), key)) {
|
if (!_.contains(_.keys(content.timeTravelStable[type]), key)) {
|
||||||
return typeof cb === 'function' ? cb({
|
return typeof cb === "function" ? cb({
|
||||||
code: 403,
|
code: 403,
|
||||||
message: i18n.t(type + 'NotAllowedHourglass', req.language)
|
message: i18n.t(type + 'NotAllowedHourglass', req.language)
|
||||||
}) : void 0;
|
}) : void 0;
|
||||||
}
|
}
|
||||||
if (user.items[type][key]) {
|
if (user.items[type][key]) {
|
||||||
return typeof cb === 'function' ? cb({
|
return typeof cb === "function" ? cb({
|
||||||
code: 403,
|
code: 403,
|
||||||
message: i18n.t(type + 'AlreadyOwned', req.language)
|
message: i18n.t(type + 'AlreadyOwned', req.language)
|
||||||
}) : void 0;
|
}) : void 0;
|
||||||
}
|
}
|
||||||
if (!(user.purchased.plan.consecutive.trinkets > 0)) {
|
if (!(user.purchased.plan.consecutive.trinkets > 0)) {
|
||||||
return typeof cb === 'function' ? cb({
|
return typeof cb === "function" ? cb({
|
||||||
code: 403,
|
code: 403,
|
||||||
message: i18n.t('notEnoughHourglasses', req.language)
|
message: i18n.t('notEnoughHourglasses', req.language)
|
||||||
}) : void 0;
|
}) : void 0;
|
||||||
@@ -44,10 +44,10 @@ module.exports = function (user, req, cb, analytics) {
|
|||||||
acquireMethod: 'Hourglass',
|
acquireMethod: 'Hourglass',
|
||||||
category: 'behavior'
|
category: 'behavior'
|
||||||
};
|
};
|
||||||
if (analytics) {
|
if (analytics != null) {
|
||||||
analytics.track('acquire item', analyticsData);
|
analytics.track('acquire item', analyticsData);
|
||||||
}
|
}
|
||||||
return typeof cb === 'function' ? cb({
|
return typeof cb === "function" ? cb({
|
||||||
code: 200,
|
code: 200,
|
||||||
message: i18n.t('hourglassPurchase', req.language)
|
message: i18n.t('hourglassPurchase', req.language)
|
||||||
}, _.pick(user, splitWhitespace('items purchased.plan.consecutive'))) : void 0;
|
}, _.pick(user, splitWhitespace('items purchased.plan.consecutive'))) : void 0;
|
||||||
|
|||||||
@@ -1,17 +1,17 @@
|
|||||||
import content from '../content/index';
|
import content from '../content/index';
|
||||||
|
|
||||||
module.exports = function (user, req, cb, analytics) {
|
module.exports = function(user, req, cb, analytics) {
|
||||||
var analyticsData, item, ref, ref1;
|
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) {
|
if (!item) {
|
||||||
return typeof cb === 'function' ? cb({
|
return typeof cb === "function" ? cb({
|
||||||
code: 400,
|
code: 400,
|
||||||
message: 'Empty'
|
message: "Empty"
|
||||||
}) : void 0;
|
}) : void 0;
|
||||||
}
|
}
|
||||||
item = content.gear.flat[item];
|
item = content.gear.flat[item];
|
||||||
user.items.gear.owned[item.key] = true;
|
user.items.gear.owned[item.key] = true;
|
||||||
if (typeof user.markModified === 'function') {
|
if (typeof user.markModified === "function") {
|
||||||
user.markModified('purchased.plan.mysteryItems');
|
user.markModified('purchased.plan.mysteryItems');
|
||||||
}
|
}
|
||||||
item.notificationType = 'Mystery';
|
item.notificationType = 'Mystery';
|
||||||
@@ -22,11 +22,11 @@ module.exports = function (user, req, cb, analytics) {
|
|||||||
acquireMethod: 'Subscriber',
|
acquireMethod: 'Subscriber',
|
||||||
category: 'behavior'
|
category: 'behavior'
|
||||||
};
|
};
|
||||||
if (analytics !== null) {
|
if (analytics != null) {
|
||||||
analytics.track('open mystery item', analyticsData);
|
analytics.track('open mystery item', analyticsData);
|
||||||
}
|
}
|
||||||
if (typeof window !== 'undefined') {
|
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;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -4,28 +4,28 @@ import _ from 'lodash';
|
|||||||
import splitWhitespace from '../libs/splitWhitespace';
|
import splitWhitespace from '../libs/splitWhitespace';
|
||||||
import planGemLimits from '../libs/planGemLimits';
|
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;
|
var analyticsData, convCap, convRate, item, key, price, ref, ref1, ref2, ref3, type;
|
||||||
ref = req.params, type = ref.type, key = ref.key;
|
ref = req.params, type = ref.type, key = ref.key;
|
||||||
if (type === 'gems' && key === 'gem') {
|
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;
|
convCap += user.purchased.plan.consecutive.gemCapExtra;
|
||||||
if (!((ref2 = user.purchased) !== null ? (ref3 = ref2.plan) !== null ? ref3.customerId : void 0 : void 0)) {
|
if (!((ref2 = user.purchased) != null ? (ref3 = ref2.plan) != null ? ref3.customerId : void 0 : void 0)) {
|
||||||
return typeof cb === 'function' ? cb({
|
return typeof cb === "function" ? cb({
|
||||||
code: 401,
|
code: 401,
|
||||||
message: 'Must subscribe to purchase gems with GP'
|
message: "Must subscribe to purchase gems with GP"
|
||||||
}, req) : void 0;
|
}, req) : void 0;
|
||||||
}
|
}
|
||||||
if (!(user.stats.gp >= convRate)) {
|
if (!(user.stats.gp >= convRate)) {
|
||||||
return typeof cb === 'function' ? cb({
|
return typeof cb === "function" ? cb({
|
||||||
code: 401,
|
code: 401,
|
||||||
message: 'Not enough Gold'
|
message: "Not enough Gold"
|
||||||
}) : void 0;
|
}) : void 0;
|
||||||
}
|
}
|
||||||
if (user.purchased.plan.gemsBought >= convCap) {
|
if (user.purchased.plan.gemsBought >= convCap) {
|
||||||
return typeof cb === 'function' ? cb({
|
return typeof cb === "function" ? cb({
|
||||||
code: 401,
|
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;
|
}) : void 0;
|
||||||
}
|
}
|
||||||
user.balance += .25;
|
user.balance += .25;
|
||||||
@@ -38,24 +38,24 @@ module.exports = function (user, req, cb, analytics) {
|
|||||||
goldCost: convRate,
|
goldCost: convRate,
|
||||||
category: 'behavior'
|
category: 'behavior'
|
||||||
};
|
};
|
||||||
if (analytics !== null) {
|
if (analytics != null) {
|
||||||
analytics.track('purchase gems', analyticsData);
|
analytics.track('purchase gems', analyticsData);
|
||||||
}
|
}
|
||||||
return typeof cb === 'function' ? cb({
|
return typeof cb === "function" ? cb({
|
||||||
code: 200,
|
code: 200,
|
||||||
message: '+1 Gem'
|
message: "+1 Gem"
|
||||||
}, _.pick(user, splitWhitespace('stats balance'))) : void 0;
|
}, _.pick(user, splitWhitespace('stats balance'))) : void 0;
|
||||||
}
|
}
|
||||||
if (type !== 'eggs' && type !== 'hatchingPotions' && type !== 'food' && type !== 'quests' && type !== 'gear') {
|
if (type !== 'eggs' && type !== 'hatchingPotions' && type !== 'food' && type !== 'quests' && type !== 'gear') {
|
||||||
return typeof cb === 'function' ? cb({
|
return typeof cb === "function" ? cb({
|
||||||
code: 404,
|
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;
|
}, req) : void 0;
|
||||||
}
|
}
|
||||||
if (type === 'gear') {
|
if (type === 'gear') {
|
||||||
item = content.gear.flat[key];
|
item = content.gear.flat[key];
|
||||||
if (user.items.gear.owned[key]) {
|
if (user.items.gear.owned[key]) {
|
||||||
return typeof cb === 'function' ? cb({
|
return typeof cb === "function" ? cb({
|
||||||
code: 401,
|
code: 401,
|
||||||
message: i18n.t('alreadyHave', req.language)
|
message: i18n.t('alreadyHave', req.language)
|
||||||
}) : void 0;
|
}) : void 0;
|
||||||
@@ -66,19 +66,19 @@ module.exports = function (user, req, cb, analytics) {
|
|||||||
price = item.value / 4;
|
price = item.value / 4;
|
||||||
}
|
}
|
||||||
if (!item) {
|
if (!item) {
|
||||||
return typeof cb === 'function' ? cb({
|
return typeof cb === "function" ? cb({
|
||||||
code: 404,
|
code: 404,
|
||||||
message: ':key not found for Content.' + type
|
message: ":key not found for Content." + type
|
||||||
}, req) : void 0;
|
}, req) : void 0;
|
||||||
}
|
}
|
||||||
if (!item.canBuy(user)) {
|
if (!item.canBuy(user)) {
|
||||||
return typeof cb === 'function' ? cb({
|
return typeof cb === "function" ? cb({
|
||||||
code: 403,
|
code: 403,
|
||||||
message: i18n.t('messageNotAvailable', req.language)
|
message: i18n.t('messageNotAvailable', req.language)
|
||||||
}) : void 0;
|
}) : void 0;
|
||||||
}
|
}
|
||||||
if ((user.balance < price) || !user.balance) {
|
if ((user.balance < price) || !user.balance) {
|
||||||
return typeof cb === 'function' ? cb({
|
return typeof cb === "function" ? cb({
|
||||||
code: 403,
|
code: 403,
|
||||||
message: i18n.t('notEnoughGems', req.language)
|
message: i18n.t('notEnoughGems', req.language)
|
||||||
}) : void 0;
|
}) : void 0;
|
||||||
@@ -100,8 +100,8 @@ module.exports = function (user, req, cb, analytics) {
|
|||||||
gemCost: item.value,
|
gemCost: item.value,
|
||||||
category: 'behavior'
|
category: 'behavior'
|
||||||
};
|
};
|
||||||
if (analytics !== null) {
|
if (analytics != null) {
|
||||||
analytics.track('acquire item', analyticsData);
|
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;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,9 +1,10 @@
|
|||||||
module.exports = function readCard (user, req, cb) {
|
module.exports = function(user, req, cb) {
|
||||||
let cardType = req.params.cardType;
|
var cardType;
|
||||||
user.items.special[`${cardType}Received`].shift();
|
cardType = req.params.cardType;
|
||||||
if (user.markModified) {
|
user.items.special[cardType + "Received"].shift();
|
||||||
user.markModified(`items.special.${cardType}Received`);
|
if (typeof user.markModified === "function") {
|
||||||
|
user.markModified("items.special." + cardType + "Received");
|
||||||
}
|
}
|
||||||
user.flags.cardReceived = false;
|
user.flags.cardReceived = false;
|
||||||
if (cb) cb(null, 'items.special flags.cardReceived');
|
return typeof cb === "function" ? cb(null, 'items.special flags.cardReceived') : void 0;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -4,10 +4,10 @@ import _ from 'lodash';
|
|||||||
import { capByLevel } from '../statHelpers';
|
import { capByLevel } from '../statHelpers';
|
||||||
import { MAX_LEVEL } from '../constants';
|
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;
|
var analyticsData, flags, gear, lvl, stats;
|
||||||
if (user.balance < 2 && user.stats.lvl < MAX_LEVEL) {
|
if (user.balance < 2 && user.stats.lvl < api.maxLevel) {
|
||||||
return typeof cb === 'function' ? cb({
|
return typeof cb === "function" ? cb({
|
||||||
code: 401,
|
code: 401,
|
||||||
message: i18n.t('notEnoughGems', req.language)
|
message: i18n.t('notEnoughGems', req.language)
|
||||||
}) : void 0;
|
}) : void 0;
|
||||||
@@ -16,7 +16,7 @@ module.exports = function (user, req, cb, analytics) {
|
|||||||
uuid: user._id,
|
uuid: user._id,
|
||||||
category: 'behavior'
|
category: 'behavior'
|
||||||
};
|
};
|
||||||
if (user.stats.lvl < MAX_LEVEL) {
|
if (user.stats.lvl < api.maxLevel) {
|
||||||
user.balance -= 2;
|
user.balance -= 2;
|
||||||
analyticsData.acquireMethod = 'Gems';
|
analyticsData.acquireMethod = 'Gems';
|
||||||
analyticsData.gemCost = 8;
|
analyticsData.gemCost = 8;
|
||||||
@@ -24,11 +24,11 @@ module.exports = function (user, req, cb, analytics) {
|
|||||||
analyticsData.gemCost = 0;
|
analyticsData.gemCost = 0;
|
||||||
analyticsData.acquireMethod = '> 100';
|
analyticsData.acquireMethod = '> 100';
|
||||||
}
|
}
|
||||||
if (analytics !== null) {
|
if (analytics != null) {
|
||||||
analytics.track('Rebirth', analyticsData);
|
analytics.track('Rebirth', analyticsData);
|
||||||
}
|
}
|
||||||
lvl = capByLevel(user.stats.lvl);
|
lvl = api.capByLevel(user.stats.lvl);
|
||||||
_.each(user.tasks, function (task) {
|
_.each(user.tasks, function(task) {
|
||||||
if (task.type !== 'reward') {
|
if (task.type !== 'reward') {
|
||||||
task.value = 0;
|
task.value = 0;
|
||||||
}
|
}
|
||||||
@@ -40,13 +40,13 @@ module.exports = function (user, req, cb, analytics) {
|
|||||||
stats.buffs = {};
|
stats.buffs = {};
|
||||||
stats.hp = 50;
|
stats.hp = 50;
|
||||||
stats.lvl = 1;
|
stats.lvl = 1;
|
||||||
stats['class'] = 'warrior';
|
stats["class"] = 'warrior';
|
||||||
_.each(['per', 'int', 'con', 'str', 'points', 'gp', 'exp', 'mp'], function (value) {
|
_.each(['per', 'int', 'con', 'str', 'points', 'gp', 'exp', 'mp'], function(value) {
|
||||||
return stats[value] = 0;
|
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
|
// 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;
|
gear = user.items.gear;
|
||||||
_.each(['equipped', 'costume'], function (type) {
|
_.each(['equipped', 'costume'], function(type) {
|
||||||
gear[type] = {};
|
gear[type] = {};
|
||||||
gear[type].armor = 'armor_base_0';
|
gear[type].armor = 'armor_base_0';
|
||||||
gear[type].weapon = 'weapon_warrior_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) {
|
if (gear.owned[k] && content.gear.flat[k].value) {
|
||||||
gear.owned[k] = false;
|
gear.owned[k] = false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
gear.owned.weapon_warrior_0 = true;
|
gear.owned.weapon_warrior_0 = true;
|
||||||
if (typeof user.markModified === 'function') {
|
if (typeof user.markModified === "function") {
|
||||||
user.markModified('items.gear.owned');
|
user.markModified('items.gear.owned');
|
||||||
}
|
}
|
||||||
user.preferences.costume = false;
|
user.preferences.costume = false;
|
||||||
@@ -96,5 +96,5 @@ module.exports = function (user, req, cb, analytics) {
|
|||||||
user.achievements.rebirthLevel = lvl;
|
user.achievements.rebirthLevel = lvl;
|
||||||
}
|
}
|
||||||
user.stats.buffs = {};
|
user.stats.buffs = {};
|
||||||
return typeof cb === 'function' ? cb(null, user) : void 0;
|
return typeof cb === "function" ? cb(null, user) : void 0;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
import content from '../content/index';
|
import content from '../content/index';
|
||||||
import i18n from '../i18n';
|
import i18n from '../i18n';
|
||||||
|
|
||||||
module.exports = function (user, req, cb, analytics) {
|
module.exports = function(user, req, cb, analytics) {
|
||||||
var analyticsData, animal, giveTriadBingo;
|
var analyticsData, animal, giveTriadBingo;
|
||||||
if (user.balance < 1.5 && !user.achievements.triadBingo) {
|
if (user.balance < 1.5 && !user.achievements.triadBingo) {
|
||||||
return typeof cb === 'function' ? cb({
|
return typeof cb === "function" ? cb({
|
||||||
code: 401,
|
code: 401,
|
||||||
message: i18n.t('notEnoughGems', req.language)
|
message: i18n.t('notEnoughGems', req.language)
|
||||||
}) : void 0;
|
}) : void 0;
|
||||||
@@ -17,13 +17,13 @@ module.exports = function (user, req, cb, analytics) {
|
|||||||
gemCost: 6,
|
gemCost: 6,
|
||||||
category: 'behavior'
|
category: 'behavior'
|
||||||
};
|
};
|
||||||
if (typeof analytics !== 'undefined' && analytics !== null) {
|
if (typeof analytics !== "undefined" && analytics !== null) {
|
||||||
analytics.track('release pets & mounts', analyticsData);
|
analytics.track('release pets & mounts', analyticsData);
|
||||||
}
|
}
|
||||||
user.balance -= 1.5;
|
user.balance -= 1.5;
|
||||||
}
|
}
|
||||||
user.items.currentMount = '';
|
user.items.currentMount = "";
|
||||||
user.items.currentPet = '';
|
user.items.currentPet = "";
|
||||||
for (animal in content.pets) {
|
for (animal in content.pets) {
|
||||||
if (user.items.pets[animal] === -1) {
|
if (user.items.pets[animal] === -1) {
|
||||||
giveTriadBingo = false;
|
giveTriadBingo = false;
|
||||||
@@ -46,5 +46,5 @@ module.exports = function (user, req, cb, analytics) {
|
|||||||
user.achievements.triadBingoCount++;
|
user.achievements.triadBingoCount++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return typeof cb === 'function' ? cb(null, user) : void 0;
|
return typeof cb === "function" ? cb(null, user) : void 0;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,16 +1,16 @@
|
|||||||
import content from '../content/index';
|
import content from '../content/index';
|
||||||
import i18n from '../i18n';
|
import i18n from '../i18n';
|
||||||
|
|
||||||
module.exports = function (user, req, cb, analytics) {
|
module.exports = function(user, req, cb, analytics) {
|
||||||
var analyticsData, mount;
|
var analyticsData, mount;
|
||||||
if (user.balance < 1) {
|
if (user.balance < 1) {
|
||||||
return typeof cb === 'function' ? cb({
|
return typeof cb === "function" ? cb({
|
||||||
code: 401,
|
code: 401,
|
||||||
message: i18n.t('notEnoughGems', req.language)
|
message: i18n.t('notEnoughGems', req.language)
|
||||||
}) : void 0;
|
}) : void 0;
|
||||||
} else {
|
} else {
|
||||||
user.balance -= 1;
|
user.balance -= 1;
|
||||||
user.items.currentMount = '';
|
user.items.currentMount = "";
|
||||||
for (mount in content.pets) {
|
for (mount in content.pets) {
|
||||||
user.items.mounts[mount] = null;
|
user.items.mounts[mount] = null;
|
||||||
}
|
}
|
||||||
@@ -25,8 +25,8 @@ module.exports = function (user, req, cb, analytics) {
|
|||||||
gemCost: 4,
|
gemCost: 4,
|
||||||
category: 'behavior'
|
category: 'behavior'
|
||||||
};
|
};
|
||||||
if (analytics !== null) {
|
if (analytics != null) {
|
||||||
analytics.track('release mounts', analyticsData);
|
analytics.track('release mounts', analyticsData);
|
||||||
}
|
}
|
||||||
return typeof cb === 'function' ? cb(null, user) : void 0;
|
return typeof cb === "function" ? cb(null, user) : void 0;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
import content from '../content/index';
|
import content from '../content/index';
|
||||||
import i18n from '../i18n';
|
import i18n from '../i18n';
|
||||||
|
|
||||||
module.exports = function (user, req, cb, analytics) {
|
module.exports = function(user, req, cb, analytics) {
|
||||||
var analyticsData, pet;
|
var analyticsData, pet;
|
||||||
if (user.balance < 1) {
|
if (user.balance < 1) {
|
||||||
return typeof cb === 'function' ? cb({
|
return typeof cb === "function" ? cb({
|
||||||
code: 401,
|
code: 401,
|
||||||
message: i18n.t('notEnoughGems', req.language)
|
message: i18n.t('notEnoughGems', req.language)
|
||||||
}) : void 0;
|
}) : void 0;
|
||||||
@@ -17,7 +17,7 @@ module.exports = function (user, req, cb, analytics) {
|
|||||||
user.achievements.beastMasterCount = 0;
|
user.achievements.beastMasterCount = 0;
|
||||||
}
|
}
|
||||||
user.achievements.beastMasterCount++;
|
user.achievements.beastMasterCount++;
|
||||||
user.items.currentPet = '';
|
user.items.currentPet = "";
|
||||||
}
|
}
|
||||||
analyticsData = {
|
analyticsData = {
|
||||||
uuid: user._id,
|
uuid: user._id,
|
||||||
@@ -25,8 +25,8 @@ module.exports = function (user, req, cb, analytics) {
|
|||||||
gemCost: 4,
|
gemCost: 4,
|
||||||
category: 'behavior'
|
category: 'behavior'
|
||||||
};
|
};
|
||||||
if (analytics !== null) {
|
if (analytics != null) {
|
||||||
analytics.track('release pets', analyticsData);
|
analytics.track('release pets', analyticsData);
|
||||||
}
|
}
|
||||||
return typeof cb === 'function' ? cb(null, user) : void 0;
|
return typeof cb === "function" ? cb(null, user) : void 0;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,16 +1,16 @@
|
|||||||
import i18n from '../i18n';
|
import i18n from '../i18n';
|
||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
|
|
||||||
module.exports = function (user, req, cb, analytics) {
|
module.exports = function(user, req, cb, analytics) {
|
||||||
var analyticsData;
|
var analyticsData;
|
||||||
if (user.balance < 1) {
|
if (user.balance < 1) {
|
||||||
return typeof cb === 'function' ? cb({
|
return typeof cb === "function" ? cb({
|
||||||
code: 401,
|
code: 401,
|
||||||
message: i18n.t('notEnoughGems', req.language)
|
message: i18n.t('notEnoughGems', req.language)
|
||||||
}) : void 0;
|
}) : void 0;
|
||||||
}
|
}
|
||||||
user.balance--;
|
user.balance--;
|
||||||
_.each(user.tasks, function (task) {
|
_.each(user.tasks, function(task) {
|
||||||
if (task.type !== 'reward') {
|
if (task.type !== 'reward') {
|
||||||
return task.value = 0;
|
return task.value = 0;
|
||||||
}
|
}
|
||||||
@@ -22,8 +22,8 @@ module.exports = function (user, req, cb, analytics) {
|
|||||||
gemCost: 4,
|
gemCost: 4,
|
||||||
category: 'behavior'
|
category: 'behavior'
|
||||||
};
|
};
|
||||||
if (analytics !== null) {
|
if (analytics != null) {
|
||||||
analytics.track('Fortify Potion', analyticsData);
|
analytics.track('Fortify Potion', analyticsData);
|
||||||
}
|
}
|
||||||
return typeof cb === 'function' ? cb(null, user) : void 0;
|
return typeof cb === "function" ? cb(null, user) : void 0;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
|
|
||||||
module.exports = function (user, req, cb) {
|
module.exports = function(user, req, cb) {
|
||||||
var gear;
|
var gear;
|
||||||
user.habits = [];
|
user.habits = [];
|
||||||
user.dailys = [];
|
user.dailys = [];
|
||||||
@@ -11,7 +11,7 @@ module.exports = function (user, req, cb) {
|
|||||||
user.stats.gp = 0;
|
user.stats.gp = 0;
|
||||||
user.stats.exp = 0;
|
user.stats.exp = 0;
|
||||||
gear = user.items.gear;
|
gear = user.items.gear;
|
||||||
_.each(['equipped', 'costume'], function (type) {
|
_.each(['equipped', 'costume'], function(type) {
|
||||||
gear[type].armor = 'armor_base_0';
|
gear[type].armor = 'armor_base_0';
|
||||||
gear[type].weapon = 'weapon_base_0';
|
gear[type].weapon = 'weapon_base_0';
|
||||||
gear[type].head = 'head_base_0';
|
gear[type].head = 'head_base_0';
|
||||||
@@ -20,16 +20,16 @@ module.exports = function (user, req, cb) {
|
|||||||
if (typeof gear.owned === 'undefined') {
|
if (typeof gear.owned === 'undefined') {
|
||||||
gear.owned = {};
|
gear.owned = {};
|
||||||
}
|
}
|
||||||
_.each(gear.owned, function (v, k) {
|
_.each(gear.owned, function(v, k) {
|
||||||
if (gear.owned[k]) {
|
if (gear.owned[k]) {
|
||||||
gear.owned[k] = false;
|
gear.owned[k] = false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
gear.owned.weapon_warrior_0 = true;
|
gear.owned.weapon_warrior_0 = true;
|
||||||
if (typeof user.markModified === 'function') {
|
if (typeof user.markModified === "function") {
|
||||||
user.markModified('items.gear.owned');
|
user.markModified('items.gear.owned');
|
||||||
}
|
}
|
||||||
user.preferences.costume = false;
|
user.preferences.costume = false;
|
||||||
return typeof cb === 'function' ? cb(null, user) : void 0;
|
return typeof cb === "function" ? cb(null, user) : void 0;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -2,12 +2,12 @@ import content from '../content/index';
|
|||||||
import i18n from '../i18n';
|
import i18n from '../i18n';
|
||||||
import _ from 'lodash';
|
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;
|
var analyticsData, base, cl, gearOwned, item, losableItems, lostItem, lostStat;
|
||||||
if (!(user.stats.hp <= 0)) {
|
if (!(user.stats.hp <= 0)) {
|
||||||
return typeof cb === 'function' ? cb({
|
return typeof cb === "function" ? cb({
|
||||||
code: 400,
|
code: 400,
|
||||||
message: 'Cannot revive if not dead'
|
message: "Cannot revive if not dead"
|
||||||
}) : void 0;
|
}) : void 0;
|
||||||
}
|
}
|
||||||
_.merge(user.stats, {
|
_.merge(user.stats, {
|
||||||
@@ -18,7 +18,7 @@ module.exports = function (user, req, cb, analytics) {
|
|||||||
if (user.stats.lvl > 1) {
|
if (user.stats.lvl > 1) {
|
||||||
user.stats.lvl--;
|
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]) {
|
if (user.stats[k]) {
|
||||||
m[k] = k;
|
m[k] = k;
|
||||||
}
|
}
|
||||||
@@ -27,10 +27,10 @@ module.exports = function (user, req, cb, analytics) {
|
|||||||
if (lostStat) {
|
if (lostStat) {
|
||||||
user.stats[lostStat]--;
|
user.stats[lostStat]--;
|
||||||
}
|
}
|
||||||
cl = user.stats['class'];
|
cl = user.stats["class"];
|
||||||
gearOwned = (typeof (base = user.items.gear.owned).toObject === 'function' ? base.toObject() : void 0) || user.items.gear.owned;
|
gearOwned = (typeof (base = user.items.gear.owned).toObject === "function" ? base.toObject() : void 0) || user.items.gear.owned;
|
||||||
losableItems = {};
|
losableItems = {};
|
||||||
_.each(gearOwned, function (v, k) {
|
_.each(gearOwned, function(v, k) {
|
||||||
var itm;
|
var itm;
|
||||||
if (v) {
|
if (v) {
|
||||||
itm = content.gear.flat['' + k];
|
itm = content.gear.flat['' + k];
|
||||||
@@ -45,13 +45,13 @@ module.exports = function (user, req, cb, analytics) {
|
|||||||
if (item = content.gear.flat[lostItem]) {
|
if (item = content.gear.flat[lostItem]) {
|
||||||
user.items.gear.owned[lostItem] = false;
|
user.items.gear.owned[lostItem] = false;
|
||||||
if (user.items.gear.equipped[item.type] === lostItem) {
|
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) {
|
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');
|
user.markModified('items.gear');
|
||||||
}
|
}
|
||||||
analyticsData = {
|
analyticsData = {
|
||||||
@@ -60,10 +60,10 @@ module.exports = function (user, req, cb, analytics) {
|
|||||||
gaLabel: lostItem,
|
gaLabel: lostItem,
|
||||||
category: 'behavior'
|
category: 'behavior'
|
||||||
};
|
};
|
||||||
if (analytics !== null) {
|
if (analytics != null) {
|
||||||
analytics.track('Death', analyticsData);
|
analytics.track('Death', analyticsData);
|
||||||
}
|
}
|
||||||
return typeof cb === 'function' ? cb((item ? {
|
return typeof cb === "function" ? cb((item ? {
|
||||||
code: 200,
|
code: 200,
|
||||||
message: i18n.t('messageLostItem', {
|
message: i18n.t('messageLostItem', {
|
||||||
itemText: item.text(req.language)
|
itemText: item.text(req.language)
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import moment from 'moment';
|
|||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
import i18n from '../i18n';
|
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;
|
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;
|
ref = req.params, id = ref.id, direction = ref.direction;
|
||||||
task = user.tasks[id];
|
task = user.tasks[id];
|
||||||
@@ -19,35 +19,35 @@ module.exports = function (user, req, cb) {
|
|||||||
};
|
};
|
||||||
task.value = +task.value;
|
task.value = +task.value;
|
||||||
task.streak = ~~task.streak;
|
task.streak = ~~task.streak;
|
||||||
if (task.priority === null) {
|
if (task.priority == null) {
|
||||||
task.priority = 1;
|
task.priority = 1;
|
||||||
}
|
}
|
||||||
if (task.value > stats.gp && task.type === 'reward') {
|
if (task.value > stats.gp && task.type === 'reward') {
|
||||||
return typeof cb === 'function' ? cb({
|
return typeof cb === "function" ? cb({
|
||||||
code: 401,
|
code: 401,
|
||||||
message: i18n.t('messageNotEnoughGold', req.language)
|
message: i18n.t('messageNotEnoughGold', req.language)
|
||||||
}) : void 0;
|
}) : void 0;
|
||||||
}
|
}
|
||||||
delta = 0;
|
delta = 0;
|
||||||
calculateDelta = function () {
|
calculateDelta = function() {
|
||||||
var currVal, nextDelta, ref1;
|
var currVal, nextDelta, ref1;
|
||||||
currVal = task.value < -47.27 ? -47.27 : task.value > 21.27 ? 21.27 : task.value;
|
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);
|
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) {
|
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);
|
return m + (i.completed ? 1 : 0);
|
||||||
}), 0) / task.checklist.length;
|
}), 0) / task.checklist.length;
|
||||||
}
|
}
|
||||||
if (task.type === 'todo') {
|
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);
|
return m + (i.completed ? 1 : 0);
|
||||||
}), 0);
|
}), 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nextDelta;
|
return nextDelta;
|
||||||
};
|
};
|
||||||
calculateReverseDelta = function () {
|
calculateReverseDelta = function() {
|
||||||
var calc, closeEnough, currVal, diff, nextDelta, ref1, testVal;
|
var calc, closeEnough, currVal, diff, nextDelta, ref1, testVal;
|
||||||
currVal = task.value < -47.27 ? -47.27 : task.value > 21.27 ? 21.27 : task.value;
|
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);
|
testVal = currVal + Math.pow(0.9747, currVal) * (direction === 'down' ? -1 : 1);
|
||||||
@@ -65,17 +65,17 @@ module.exports = function (user, req, cb) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
nextDelta = testVal - currVal;
|
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') {
|
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);
|
return m + (i.completed ? 1 : 0);
|
||||||
}), 0);
|
}), 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nextDelta;
|
return nextDelta;
|
||||||
};
|
};
|
||||||
changeTaskValue = function () {
|
changeTaskValue = function() {
|
||||||
return _.times(options.times, function () {
|
return _.times(options.times, function() {
|
||||||
var nextDelta, ref1;
|
var nextDelta, ref1;
|
||||||
nextDelta = !options.cron && direction === 'down' ? calculateReverseDelta() : calculateDelta();
|
nextDelta = !options.cron && direction === 'down' ? calculateReverseDelta() : calculateDelta();
|
||||||
if (task.type !== 'reward') {
|
if (task.type !== 'reward') {
|
||||||
@@ -96,7 +96,7 @@ module.exports = function (user, req, cb) {
|
|||||||
return delta += nextDelta;
|
return delta += nextDelta;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
addPoints = function () {
|
addPoints = function() {
|
||||||
var _crit, afterStreak, currStreak, gpMod, intBonus, perBonus, streakBonus;
|
var _crit, afterStreak, currStreak, gpMod, intBonus, perBonus, streakBonus;
|
||||||
_crit = (delta > 0 ? user.fns.crit() : 1);
|
_crit = (delta > 0 ? user.fns.crit() : 1);
|
||||||
if (_crit > 1) {
|
if (_crit > 1) {
|
||||||
@@ -108,7 +108,7 @@ module.exports = function (user, req, cb) {
|
|||||||
gpMod = delta * task.priority * _crit * perBonus;
|
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;
|
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;
|
var conBonus, hpMod;
|
||||||
conBonus = 1 - (user._statsComputed.con / 250);
|
conBonus = 1 - (user._statsComputed.con / 250);
|
||||||
if (conBonus < .1) {
|
if (conBonus < .1) {
|
||||||
@@ -117,7 +117,7 @@ module.exports = function (user, req, cb) {
|
|||||||
hpMod = delta * conBonus * task.priority * 2;
|
hpMod = delta * conBonus * task.priority * 2;
|
||||||
return stats.hp += Math.round(hpMod * 10) / 10;
|
return stats.hp += Math.round(hpMod * 10) / 10;
|
||||||
};
|
};
|
||||||
gainMP = function (delta) {
|
gainMP = function(delta) {
|
||||||
delta *= user._tmp.crit || 1;
|
delta *= user._tmp.crit || 1;
|
||||||
user.stats.mp += delta;
|
user.stats.mp += delta;
|
||||||
if (user.stats.mp >= user._statsComputed.maxMP) {
|
if (user.stats.mp >= user._statsComputed.maxMP) {
|
||||||
@@ -136,7 +136,7 @@ module.exports = function (user, req, cb) {
|
|||||||
subtractPoints();
|
subtractPoints();
|
||||||
}
|
}
|
||||||
gainMP(_.max([0.25, .0025 * user._statsComputed.maxMP]) * (direction === 'down' ? -1 : 1));
|
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')) {
|
if (th[th.length - 1] && moment(th[th.length - 1].date).isSame(new Date, 'day')) {
|
||||||
th[th.length - 1].value = task.value;
|
th[th.length - 1].value = task.value;
|
||||||
} else {
|
} else {
|
||||||
@@ -145,10 +145,10 @@ module.exports = function (user, req, cb) {
|
|||||||
value: task.value
|
value: task.value
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (typeof user.markModified === 'function') {
|
if (typeof user.markModified === "function") {
|
||||||
user.markModified('habits.' + (_.findIndex(user.habits, {
|
user.markModified("habits." + (_.findIndex(user.habits, {
|
||||||
id: task.id
|
id: task.id
|
||||||
})) + '.history');
|
})) + ".history");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'daily':
|
case 'daily':
|
||||||
@@ -189,7 +189,7 @@ module.exports = function (user, req, cb) {
|
|||||||
}
|
}
|
||||||
addPoints();
|
addPoints();
|
||||||
multiplier = _.max([
|
multiplier = _.max([
|
||||||
_.reduce(task.checklist, (function (m, i) {
|
_.reduce(task.checklist, (function(m, i) {
|
||||||
return m + (i.completed ? 1 : 0);
|
return m + (i.completed ? 1 : 0);
|
||||||
}), 1), 1
|
}), 1), 1
|
||||||
]);
|
]);
|
||||||
@@ -214,7 +214,7 @@ module.exports = function (user, req, cb) {
|
|||||||
}, req);
|
}, req);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (typeof cb === 'function') {
|
if (typeof cb === "function") {
|
||||||
cb(null, user);
|
cb(null, user);
|
||||||
}
|
}
|
||||||
return delta;
|
return delta;
|
||||||
|
|||||||
@@ -2,22 +2,22 @@ import content from '../content/index';
|
|||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
import splitWhitespace from '../libs/splitWhitespace';
|
import splitWhitespace from '../libs/splitWhitespace';
|
||||||
|
|
||||||
module.exports = function (user, req, cb) {
|
module.exports = function(user, req, cb) {
|
||||||
var key, ref, type;
|
var key, ref, type;
|
||||||
ref = req.params, key = ref.key, type = ref.type;
|
ref = req.params, key = ref.key, type = ref.type;
|
||||||
if (type !== 'eggs' && type !== 'hatchingPotions' && type !== 'food') {
|
if (type !== 'eggs' && type !== 'hatchingPotions' && type !== 'food') {
|
||||||
return typeof cb === 'function' ? cb({
|
return typeof cb === "function" ? cb({
|
||||||
code: 404,
|
code: 404,
|
||||||
message: ':type not found. Must bes in [eggs, hatchingPotions, food]'
|
message: ":type not found. Must bes in [eggs, hatchingPotions, food]"
|
||||||
}) : void 0;
|
}) : void 0;
|
||||||
}
|
}
|
||||||
if (!user.items[type][key]) {
|
if (!user.items[type][key]) {
|
||||||
return typeof cb === 'function' ? cb({
|
return typeof cb === "function" ? cb({
|
||||||
code: 404,
|
code: 404,
|
||||||
message: ':key not found for user.items.' + type
|
message: ":key not found for user.items." + type
|
||||||
}) : void 0;
|
}) : void 0;
|
||||||
}
|
}
|
||||||
user.items[type][key]--;
|
user.items[type][key]--;
|
||||||
user.stats.gp += content[type][key].value;
|
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;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
module.exports = function (user, req, cb) {
|
module.exports = function(user, req, cb) {
|
||||||
user.preferences.sleep = !user.preferences.sleep;
|
user.preferences.sleep = !user.preferences.sleep;
|
||||||
return typeof cb === 'function' ? cb(null, {}) : void 0;
|
return typeof cb === "function" ? cb(null, {}) : void 0;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
module.exports = function (user, req, cb) {
|
module.exports = function(user, req, cb) {
|
||||||
var from, ref, to;
|
var from, ref, to;
|
||||||
ref = req.query, to = ref.to, from = ref.from;
|
ref = req.query, to = ref.to, from = ref.from;
|
||||||
if (!((to !== null) && (from !== null))) {
|
if (!((to != null) && (from != null))) {
|
||||||
return typeof cb === 'function' ? cb('?to=__&from=__ are required') : void 0;
|
return typeof cb === "function" ? cb('?to=__&from=__ are required') : void 0;
|
||||||
}
|
}
|
||||||
user.tags.splice(to, 0, user.tags.splice(from, 1)[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;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,30 +1,30 @@
|
|||||||
import i18n from '../i18n';
|
import i18n from '../i18n';
|
||||||
import preenTodos from '../libs/preenTodos';
|
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;
|
var from, id, movedTask, preenedTasks, ref, task, tasks, to;
|
||||||
id = req.params.id;
|
id = req.params.id;
|
||||||
ref = req.query, to = ref.to, from = ref.from;
|
ref = req.query, to = ref.to, from = ref.from;
|
||||||
task = user.tasks[id];
|
task = user.tasks[id];
|
||||||
if (!task) {
|
if (!task) {
|
||||||
return typeof cb === 'function' ? cb({
|
return typeof cb === "function" ? cb({
|
||||||
code: 404,
|
code: 404,
|
||||||
message: i18n.t('messageTaskNotFound', req.language)
|
message: i18n.t('messageTaskNotFound', req.language)
|
||||||
}) : void 0;
|
}) : void 0;
|
||||||
}
|
}
|
||||||
if (!((to !== null) && (from !== null))) {
|
if (!((to != null) && (from != null))) {
|
||||||
return typeof cb === 'function' ? cb('?to=__&from=__ are required') : void 0;
|
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) {
|
if (task.type === 'todo' && tasks[from] !== task) {
|
||||||
preenedTasks = preenTodos(tasks);
|
preenedTasks = api.preenTodos(tasks);
|
||||||
if (to !== -1) {
|
if (to !== -1) {
|
||||||
to = tasks.indexOf(preenedTasks[to]);
|
to = tasks.indexOf(preenedTasks[to]);
|
||||||
}
|
}
|
||||||
from = tasks.indexOf(preenedTasks[from]);
|
from = tasks.indexOf(preenedTasks[from]);
|
||||||
}
|
}
|
||||||
if (tasks[from] !== task) {
|
if (tasks[from] !== task) {
|
||||||
return typeof cb === 'function' ? cb({
|
return typeof cb === "function" ? cb({
|
||||||
code: 404,
|
code: 404,
|
||||||
message: i18n.t('messageTaskNotFound', req.language)
|
message: i18n.t('messageTaskNotFound', req.language)
|
||||||
}) : void 0;
|
}) : void 0;
|
||||||
@@ -35,5 +35,5 @@ module.exports = function (user, req, cb) {
|
|||||||
} else {
|
} else {
|
||||||
tasks.splice(to, 0, movedTask);
|
tasks.splice(to, 0, movedTask);
|
||||||
}
|
}
|
||||||
return typeof cb === 'function' ? cb(null, tasks) : void 0;
|
return typeof cb === "function" ? cb(null, tasks) : void 0;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -2,27 +2,27 @@ import i18n from '../i18n';
|
|||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
import splitWhitespace from '../libs/splitWhitespace';
|
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;
|
var alreadyOwns, analyticsData, cost, fullSet, k, path, split, v;
|
||||||
path = req.query.path;
|
path = req.query.path;
|
||||||
fullSet = ~path.indexOf(',');
|
fullSet = ~path.indexOf(",");
|
||||||
cost = ~path.indexOf('background.') ? fullSet ? 3.75 : 1.75 : fullSet ? 1.25 : 0.5;
|
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) {
|
if ((user.balance < cost || !user.balance) && !alreadyOwns) {
|
||||||
return typeof cb === 'function' ? cb({
|
return typeof cb === "function" ? cb({
|
||||||
code: 401,
|
code: 401,
|
||||||
message: i18n.t('notEnoughGems', req.language)
|
message: i18n.t('notEnoughGems', req.language)
|
||||||
}) : void 0;
|
}) : void 0;
|
||||||
}
|
}
|
||||||
if (fullSet) {
|
if (fullSet) {
|
||||||
_.each(path.split(','), function (p) {
|
_.each(path.split(","), function(p) {
|
||||||
if (~path.indexOf('gear.')) {
|
if (~path.indexOf('gear.')) {
|
||||||
user.fns.dotSet('' + p, true);
|
user.fns.dotSet("" + p, true);
|
||||||
true;
|
true;
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
}
|
}
|
||||||
user.fns.dotSet('purchased.' + p, true);
|
user.fns.dotSet("purchased." + p, true);
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
@@ -33,18 +33,18 @@ module.exports = function (user, req, cb, analytics) {
|
|||||||
if (k === 'background' && v === user.preferences.background) {
|
if (k === 'background' && v === user.preferences.background) {
|
||||||
v = '';
|
v = '';
|
||||||
}
|
}
|
||||||
user.fns.dotSet('preferences.' + k, v);
|
user.fns.dotSet("preferences." + k, v);
|
||||||
return typeof cb === 'function' ? cb(null, req) : void 0;
|
return typeof cb === "function" ? cb(null, req) : void 0;
|
||||||
}
|
}
|
||||||
user.fns.dotSet('purchased.' + path, true);
|
user.fns.dotSet("purchased." + path, true);
|
||||||
}
|
}
|
||||||
user.balance -= cost;
|
user.balance -= cost;
|
||||||
if (~path.indexOf('gear.')) {
|
if (~path.indexOf('gear.')) {
|
||||||
if (typeof user.markModified === 'function') {
|
if (typeof user.markModified === "function") {
|
||||||
user.markModified('gear.owned');
|
user.markModified('gear.owned');
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (typeof user.markModified === 'function') {
|
if (typeof user.markModified === "function") {
|
||||||
user.markModified('purchased');
|
user.markModified('purchased');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -56,8 +56,8 @@ module.exports = function (user, req, cb, analytics) {
|
|||||||
gemCost: cost / .25,
|
gemCost: cost / .25,
|
||||||
category: 'behavior'
|
category: 'behavior'
|
||||||
};
|
};
|
||||||
if (analytics !== null) {
|
if (analytics != null) {
|
||||||
analytics.track('acquire item', analyticsData);
|
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;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
|
|
||||||
module.exports = function (user, req, cb) {
|
module.exports = function(user, req, cb) {
|
||||||
_.each(req.body, function (v, k) {
|
_.each(req.body, function(v, k) {
|
||||||
user.fns.dotSet(k, v);
|
user.fns.dotSet(k, v);
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
return typeof cb === 'function' ? cb(null, user) : void 0;
|
return typeof cb === "function" ? cb(null, user) : void 0;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,18 +1,18 @@
|
|||||||
import i18n from '../i18n';
|
import i18n from '../i18n';
|
||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
|
|
||||||
module.exports = function (user, req, cb) {
|
module.exports = function(user, req, cb) {
|
||||||
var i, tid;
|
var i, tid;
|
||||||
tid = req.params.id;
|
tid = req.params.id;
|
||||||
i = _.findIndex(user.tags, {
|
i = _.findIndex(user.tags, {
|
||||||
id: tid
|
id: tid
|
||||||
});
|
});
|
||||||
if (!~i) {
|
if (!~i) {
|
||||||
return typeof cb === 'function' ? cb({
|
return typeof cb === "function" ? cb({
|
||||||
code: 404,
|
code: 404,
|
||||||
message: i18n.t('messageTagNotFound', req.language)
|
message: i18n.t('messageTagNotFound', req.language)
|
||||||
}) : void 0;
|
}) : void 0;
|
||||||
}
|
}
|
||||||
user.tags[i].name = req.body.name;
|
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;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
import i18n from '../i18n';
|
import i18n from '../i18n';
|
||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
|
|
||||||
module.exports = function (user, req, cb) {
|
module.exports = function(user, req, cb) {
|
||||||
var ref, task;
|
var ref, task;
|
||||||
if (!(task = user.tasks[(ref = req.params) !== null ? ref.id : void 0])) {
|
if (!(task = user.tasks[(ref = req.params) != null ? ref.id : void 0])) {
|
||||||
return typeof cb === 'function' ? cb({
|
return typeof cb === "function" ? cb({
|
||||||
code: 404,
|
code: 404,
|
||||||
message: i18n.t('messageTaskNotFound', req.language)
|
message: i18n.t('messageTaskNotFound', req.language)
|
||||||
}) : void 0;
|
}) : void 0;
|
||||||
@@ -13,8 +13,8 @@ module.exports = function (user, req, cb) {
|
|||||||
if (req.body.checklist) {
|
if (req.body.checklist) {
|
||||||
task.checklist = req.body.checklist;
|
task.checklist = req.body.checklist;
|
||||||
}
|
}
|
||||||
if (typeof task.markModified === 'function') {
|
if (typeof task.markModified === "function") {
|
||||||
task.markModified('tags');
|
task.markModified('tags');
|
||||||
}
|
}
|
||||||
return typeof cb === 'function' ? cb(null, task) : void 0;
|
return typeof cb === "function" ? cb(null, task) : void 0;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
|
|
||||||
module.exports = function (user, req, cb) {
|
module.exports = function(user, req, cb) {
|
||||||
_.merge(user.preferences.webhooks[req.params.id], req.body);
|
_.merge(user.preferences.webhooks[req.params.id], req.body);
|
||||||
if (typeof user.markModified === 'function') {
|
if (typeof user.markModified === "function") {
|
||||||
user.markModified('preferences.webhooks');
|
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;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -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.purchased.plan.consecutive.trinkets = 2;
|
||||||
|
|
||||||
user.ops.hourglassPurchase({params: {type: 'mounts', key: 'MantisShrimp-Base'}}, (response) => {
|
user.ops.hourglassPurchase({params: {type: 'mounts', key: 'MantisShrimp-Base'}}, (response) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user