after merge
This commit is contained in:
@@ -1,15 +1,16 @@
|
||||
import get from 'lodash/get';
|
||||
import content from '../content/index';
|
||||
import i18n from '../i18n';
|
||||
import get from 'lodash/get';
|
||||
|
||||
let achievs = {};
|
||||
let achievsContent = content.achievements;
|
||||
const achievs = {};
|
||||
const achievsContent = content.achievements;
|
||||
let index = 0;
|
||||
|
||||
function contribText (contrib, backer, language) {
|
||||
if (!contrib && !backer) return;
|
||||
if (!contrib && !backer) return null;
|
||||
if (backer && backer.npc) return backer.npc;
|
||||
let lvl = contrib && contrib.level;
|
||||
|
||||
const lvl = contrib && contrib.level;
|
||||
if (lvl && lvl > 0) {
|
||||
let contribTitle = '';
|
||||
|
||||
@@ -29,6 +30,8 @@ function contribText (contrib, backer, language) {
|
||||
|
||||
return `${contribTitle} ${contrib.text}`;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
function _add (result, data) {
|
||||
@@ -38,17 +41,17 @@ function _add (result, data) {
|
||||
icon: data.icon,
|
||||
earned: data.earned,
|
||||
value: data.value,
|
||||
index: index++,
|
||||
index: index += 1,
|
||||
optionalCount: data.optionalCount,
|
||||
};
|
||||
}
|
||||
|
||||
function _addSimpleWithCustomPath (result, user, data) {
|
||||
let value = get(user, data.path);
|
||||
let thisContent = achievsContent[data.key];
|
||||
const value = get(user, data.path);
|
||||
const thisContent = achievsContent[data.key];
|
||||
|
||||
_add(result, {
|
||||
title: i18n.t(thisContent.titleKey, {key: value}, data.language),
|
||||
title: i18n.t(thisContent.titleKey, { key: value }, data.language),
|
||||
text: i18n.t(thisContent.textKey, data.language),
|
||||
icon: thisContent.icon,
|
||||
key: data.key,
|
||||
@@ -64,10 +67,10 @@ function _addQuest (result, user, data) {
|
||||
}
|
||||
|
||||
function _addSimple (result, user, data) {
|
||||
let value = user.achievements[data.path];
|
||||
const value = user.achievements[data.path];
|
||||
|
||||
let key = data.key || data.path;
|
||||
let thisContent = achievsContent[key];
|
||||
const key = data.key || data.path;
|
||||
const thisContent = achievsContent[key];
|
||||
|
||||
_add(result, {
|
||||
title: i18n.t(thisContent.titleKey, data.language),
|
||||
@@ -80,14 +83,14 @@ function _addSimple (result, user, data) {
|
||||
}
|
||||
|
||||
function _addSimpleWithMasterCount (result, user, data) {
|
||||
let language = data.language;
|
||||
let value = user.achievements[`${data.path}Count`] || 0;
|
||||
const { language } = data;
|
||||
const value = user.achievements[`${data.path}Count`] || 0;
|
||||
|
||||
let thisContent = achievsContent[data.path];
|
||||
const thisContent = achievsContent[data.path];
|
||||
|
||||
let text = i18n.t(thisContent.textKey, language);
|
||||
if (value > 0) {
|
||||
text += i18n.t(thisContent.text2Key, {count: value}, language);
|
||||
text += i18n.t(thisContent.text2Key, { count: value }, language);
|
||||
}
|
||||
|
||||
_add(result, {
|
||||
@@ -102,14 +105,14 @@ function _addSimpleWithMasterCount (result, user, data) {
|
||||
}
|
||||
|
||||
function _addSimpleWithCount (result, user, data) {
|
||||
let value = user.achievements[data.path] || 0;
|
||||
const value = user.achievements[data.path] || 0;
|
||||
|
||||
let key = data.key || data.path;
|
||||
let thisContent = achievsContent[key];
|
||||
const key = data.key || data.path;
|
||||
const thisContent = achievsContent[key];
|
||||
|
||||
_add(result, {
|
||||
title: i18n.t(thisContent.titleKey, data.language),
|
||||
text: i18n.t(thisContent.textKey, {count: value}, data.language),
|
||||
text: i18n.t(thisContent.textKey, { count: value }, data.language),
|
||||
icon: thisContent.icon,
|
||||
key,
|
||||
value,
|
||||
@@ -119,10 +122,10 @@ function _addSimpleWithCount (result, user, data) {
|
||||
}
|
||||
|
||||
function _addPlural (result, user, data) {
|
||||
let value = user.achievements[data.path] || 0;
|
||||
const value = user.achievements[data.path] || 0;
|
||||
|
||||
let key = data.key || data.path;
|
||||
let thisContent = achievsContent[key];
|
||||
const key = data.key || data.path;
|
||||
const thisContent = achievsContent[key];
|
||||
|
||||
let titleKey;
|
||||
let textKey;
|
||||
@@ -137,8 +140,8 @@ function _addPlural (result, user, data) {
|
||||
}
|
||||
|
||||
_add(result, {
|
||||
title: i18n.t(titleKey, {count: value}, data.language),
|
||||
text: i18n.t(textKey, {count: value}, data.language),
|
||||
title: i18n.t(titleKey, { count: value }, data.language),
|
||||
text: i18n.t(textKey, { count: value }, data.language),
|
||||
icon: thisContent.icon,
|
||||
key,
|
||||
value,
|
||||
@@ -152,14 +155,14 @@ function _addUltimateGear (result, user, data) {
|
||||
data.altPath = data.path;
|
||||
}
|
||||
|
||||
let value = user.achievements.ultimateGearSets[data.altPath];
|
||||
const value = user.achievements.ultimateGearSets[data.altPath];
|
||||
|
||||
let key = `${data.path}UltimateGear`;
|
||||
let thisContent = achievsContent[key];
|
||||
const key = `${data.path}UltimateGear`;
|
||||
const thisContent = achievsContent[key];
|
||||
|
||||
let localizedClass = i18n.t(data.path, data.language);
|
||||
let title = i18n.t(thisContent.titleKey, {ultClass: localizedClass}, data.language);
|
||||
let text = i18n.t(thisContent.textKey, {ultClass: localizedClass}, data.language);
|
||||
const localizedClass = i18n.t(data.path, data.language);
|
||||
const title = i18n.t(thisContent.titleKey, { ultClass: localizedClass }, data.language);
|
||||
const text = i18n.t(thisContent.textKey, { ultClass: localizedClass }, data.language);
|
||||
|
||||
_add(result, {
|
||||
title,
|
||||
@@ -172,44 +175,46 @@ function _addUltimateGear (result, user, data) {
|
||||
}
|
||||
|
||||
function _getBasicAchievements (user, language) {
|
||||
let result = {};
|
||||
const result = {};
|
||||
|
||||
_addPlural(result, user, {path: 'streak', language});
|
||||
_addPlural(result, user, {path: 'perfect', language});
|
||||
_addPlural(result, user, { path: 'streak', language });
|
||||
_addPlural(result, user, { path: 'perfect', language });
|
||||
|
||||
_addSimple(result, user, {path: 'partyUp', language});
|
||||
_addSimple(result, user, {path: 'partyOn', language});
|
||||
_addSimple(result, user, {path: 'joinedGuild', language});
|
||||
_addSimple(result, user, {path: 'royallyLoyal', language});
|
||||
_addSimple(result, user, {path: 'joinedChallenge', language});
|
||||
_addSimple(result, user, {path: 'invitedFriend', language});
|
||||
_addSimple(result, user, {path: 'lostMasterclasser', language});
|
||||
_addSimple(result, user, {path: 'mindOverMatter', language});
|
||||
_addSimple(result, user, {path: 'justAddWater', language});
|
||||
_addSimple(result, user, {path: 'backToBasics', language});
|
||||
_addSimple(result, user, {path: 'allYourBase', language});
|
||||
_addSimple(result, user, {path: 'dustDevil', language});
|
||||
_addSimple(result, user, {path: 'aridAuthority', language});
|
||||
_addSimple(result, user, { path: 'partyUp', language });
|
||||
_addSimple(result, user, { path: 'partyOn', language });
|
||||
_addSimple(result, user, { path: 'joinedGuild', language });
|
||||
_addSimple(result, user, { path: 'royallyLoyal', language });
|
||||
_addSimple(result, user, { path: 'joinedChallenge', language });
|
||||
_addSimple(result, user, { path: 'invitedFriend', language });
|
||||
_addSimple(result, user, { path: 'lostMasterclasser', language });
|
||||
_addSimple(result, user, { path: 'mindOverMatter', language });
|
||||
_addSimple(result, user, { path: 'justAddWater', language });
|
||||
_addSimple(result, user, { path: 'backToBasics', language });
|
||||
_addSimple(result, user, { path: 'allYourBase', language });
|
||||
_addSimple(result, user, { path: 'dustDevil', language });
|
||||
_addSimple(result, user, { path: 'aridAuthority', language });
|
||||
_addSimple(result, user, { path: 'monsterMagus', language });
|
||||
_addSimple(result, user, { path: 'undeadUndertaker', language });
|
||||
|
||||
_addSimpleWithMasterCount(result, user, {path: 'beastMaster', language});
|
||||
_addSimpleWithMasterCount(result, user, {path: 'mountMaster', language});
|
||||
_addSimpleWithMasterCount(result, user, {path: 'triadBingo', language});
|
||||
_addSimpleWithMasterCount(result, user, { path: 'beastMaster', language });
|
||||
_addSimpleWithMasterCount(result, user, { path: 'mountMaster', language });
|
||||
_addSimpleWithMasterCount(result, user, { path: 'triadBingo', language });
|
||||
|
||||
_addUltimateGear(result, user, {path: 'healer', language});
|
||||
_addUltimateGear(result, user, {path: 'rogue', language});
|
||||
_addUltimateGear(result, user, {path: 'warrior', language});
|
||||
_addUltimateGear(result, user, {path: 'mage', altPath: 'wizard', language});
|
||||
_addUltimateGear(result, user, { path: 'healer', language });
|
||||
_addUltimateGear(result, user, { path: 'rogue', language });
|
||||
_addUltimateGear(result, user, { path: 'warrior', language });
|
||||
_addUltimateGear(result, user, { path: 'mage', altPath: 'wizard', language });
|
||||
|
||||
let cardAchievements = ['greeting', 'thankyou', 'birthday', 'congrats', 'getwell', 'goodluck'];
|
||||
const cardAchievements = ['greeting', 'thankyou', 'birthday', 'congrats', 'getwell', 'goodluck'];
|
||||
cardAchievements.forEach(path => {
|
||||
_addSimpleWithCount(result, user, {path, key: `${path}Cards`, language});
|
||||
_addSimpleWithCount(result, user, { path, key: `${path}Cards`, language });
|
||||
});
|
||||
|
||||
let rebirthTitle;
|
||||
let rebirthText;
|
||||
|
||||
if (user.achievements.rebirths > 1) {
|
||||
rebirthTitle = i18n.t('rebirthText', {rebirths: user.achievements.rebirths}, language);
|
||||
rebirthTitle = i18n.t('rebirthText', { rebirths: user.achievements.rebirths }, language);
|
||||
} else {
|
||||
rebirthTitle = i18n.t('rebirthBegan', language);
|
||||
}
|
||||
@@ -217,7 +222,7 @@ function _getBasicAchievements (user, language) {
|
||||
if (!user.achievements.rebirthLevel) {
|
||||
rebirthText = i18n.t('rebirthOrbNoLevel', language);
|
||||
} else if (user.achievements.rebirthLevel < 100) {
|
||||
rebirthText = i18n.t('rebirthOrb', {level: user.achievements.rebirthLevel}, language);
|
||||
rebirthText = i18n.t('rebirthOrb', { level: user.achievements.rebirthLevel }, language);
|
||||
} else {
|
||||
rebirthText = i18n.t('rebirthOrb100', language);
|
||||
}
|
||||
@@ -235,41 +240,41 @@ function _getBasicAchievements (user, language) {
|
||||
}
|
||||
|
||||
function _getSeasonalAchievements (user, language) {
|
||||
let result = {};
|
||||
const result = {};
|
||||
|
||||
_addPlural(result, user, {path: 'habiticaDays', language});
|
||||
_addPlural(result, user, {path: 'habitBirthdays', language});
|
||||
_addPlural(result, user, { path: 'habiticaDays', language });
|
||||
_addPlural(result, user, { path: 'habitBirthdays', language });
|
||||
|
||||
let spellAchievements = ['snowball', 'spookySparkles', 'shinySeed', 'seafoam'];
|
||||
const spellAchievements = ['snowball', 'spookySparkles', 'shinySeed', 'seafoam'];
|
||||
spellAchievements.forEach(path => {
|
||||
_addSimpleWithCount(result, user, {path, language});
|
||||
_addSimpleWithCount(result, user, { path, language });
|
||||
});
|
||||
|
||||
let questAchievements = ['dilatory', 'stressbeast', 'burnout', 'bewilder', 'dysheartener'];
|
||||
const questAchievements = ['dilatory', 'stressbeast', 'burnout', 'bewilder', 'dysheartener'];
|
||||
questAchievements.forEach(path => {
|
||||
if (user.achievements.quests[path]) {
|
||||
_addQuest(result, user, {path, language});
|
||||
_addQuest(result, user, { path, language });
|
||||
}
|
||||
});
|
||||
|
||||
_addPlural(result, user, {path: 'costumeContests', language});
|
||||
_addPlural(result, user, { path: 'costumeContests', language });
|
||||
|
||||
let cardAchievements = ['nye', 'valentine'];
|
||||
const cardAchievements = ['nye', 'valentine'];
|
||||
cardAchievements.forEach(path => {
|
||||
_addSimpleWithCount(result, user, {path, key: `${path}Cards`, language});
|
||||
_addSimpleWithCount(result, user, { path, key: `${path}Cards`, language });
|
||||
});
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
function _getSpecialAchievements (user, language) {
|
||||
let result = {};
|
||||
const result = {};
|
||||
|
||||
_addPlural(result, user, {path: 'habitSurveys', language});
|
||||
_addPlural(result, user, { path: 'habitSurveys', language });
|
||||
|
||||
let contribKey = 'contributor';
|
||||
let contribContent = achievsContent[contribKey];
|
||||
let contributorAchiev = {
|
||||
const contribKey = 'contributor';
|
||||
const contribContent = achievsContent[contribKey];
|
||||
const contributorAchiev = {
|
||||
key: contribKey,
|
||||
text: i18n.t(contribContent.textKey, language),
|
||||
icon: contribContent.icon,
|
||||
@@ -285,23 +290,23 @@ function _getSpecialAchievements (user, language) {
|
||||
_add(result, contributorAchiev);
|
||||
|
||||
if (user.backer && user.backer.npc) {
|
||||
_addSimpleWithCustomPath(result, user, {key: 'npc', path: 'backer.npc', language});
|
||||
_addSimpleWithCustomPath(result, user, { key: 'npc', path: 'backer.npc', language });
|
||||
}
|
||||
|
||||
if (user.backer && user.backer.tier) {
|
||||
_addSimpleWithCustomPath(result, user, {key: 'kickstarter', path: 'backer.tier', language});
|
||||
_addSimpleWithCustomPath(result, user, { key: 'kickstarter', path: 'backer.tier', language });
|
||||
}
|
||||
|
||||
if (user.achievements.veteran) {
|
||||
_addSimple(result, user, {path: 'veteran', language});
|
||||
_addSimple(result, user, { path: 'veteran', language });
|
||||
}
|
||||
|
||||
if (user.achievements.originalUser) {
|
||||
_addSimple(result, user, {path: 'originalUser', language});
|
||||
_addSimple(result, user, { path: 'originalUser', language });
|
||||
}
|
||||
|
||||
if (user.achievements.kickstarter2019) {
|
||||
_addSimple(result, user, {path: 'kickstarter2019', language});
|
||||
_addSimple(result, user, { path: 'kickstarter2019', language });
|
||||
}
|
||||
|
||||
return result;
|
||||
@@ -309,7 +314,7 @@ function _getSpecialAchievements (user, language) {
|
||||
|
||||
// Build and return the given user's achievement data.
|
||||
achievs.getAchievementsForProfile = function getAchievementsForProfile (user, language) {
|
||||
let result = {
|
||||
const result = {
|
||||
basic: {
|
||||
label: 'Basic',
|
||||
achievements: _getBasicAchievements(user, language),
|
||||
@@ -328,4 +333,4 @@ achievs.getAchievementsForProfile = function getAchievementsForProfile (user, la
|
||||
|
||||
achievs.getContribText = contribText;
|
||||
|
||||
module.exports = achievs;
|
||||
export default achievs;
|
||||
|
||||
@@ -4,11 +4,7 @@ Are there tags applied?
|
||||
|
||||
// TODO move to client
|
||||
|
||||
module.exports = function appliedTags (userTags, taskTags = []) {
|
||||
let arr = userTags.filter(tag => {
|
||||
return taskTags.indexOf(tag.id) !== -1;
|
||||
}).map(tag => {
|
||||
return tag.name;
|
||||
});
|
||||
export default function appliedTags (userTags, taskTags = []) {
|
||||
const arr = userTags.filter(tag => taskTags.indexOf(tag.id) !== -1).map(tag => tag.name);
|
||||
return arr.join(', ');
|
||||
};
|
||||
}
|
||||
|
||||
@@ -2,4 +2,4 @@ import get from 'lodash/get';
|
||||
|
||||
// TODO remove completely, only used in client
|
||||
|
||||
module.exports = get;
|
||||
export default get;
|
||||
|
||||
@@ -2,4 +2,4 @@ import set from 'lodash/set';
|
||||
|
||||
// TODO remove completely, only used in client
|
||||
|
||||
module.exports = set;
|
||||
export default set;
|
||||
|
||||
@@ -3,13 +3,13 @@
|
||||
import _clone from 'lodash/clone';
|
||||
import _template from 'lodash/template';
|
||||
|
||||
import messages from '../../errors/commonErrorMessages';
|
||||
import messages from '../errors/commonErrorMessages';
|
||||
|
||||
export default function (msgKey, vars = {}) {
|
||||
let message = messages[msgKey];
|
||||
const message = messages[msgKey];
|
||||
if (!message) throw new Error(`Error processing the common message "${msgKey}".`);
|
||||
|
||||
let clonedVars = vars ? _clone(vars) : {};
|
||||
const clonedVars = vars ? _clone(vars) : {};
|
||||
|
||||
// TODO cache the result of template() ? More memory usage, faster output
|
||||
return _template(message)(clonedVars);
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
/* eslint-disable max-classes-per-file */
|
||||
import extendableBuiltin from './extendableBuiltin';
|
||||
|
||||
// Base class for custom application errors
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
// TODO use https://babeljs.io/docs/en/babel-plugin-transform-classes
|
||||
// Babel 6 doesn't support extending native class (Error, Array, ...)
|
||||
// This function makes it possible to extend native classes with the same results as Babel 5
|
||||
module.exports = function extendableBuiltin (klass) {
|
||||
export default function extendableBuiltin (klass) {
|
||||
function ExtendableBuiltin () {
|
||||
klass.apply(this, arguments);
|
||||
klass.apply(this, arguments); // eslint-disable-line prefer-rest-params
|
||||
}
|
||||
ExtendableBuiltin.prototype = Object.create(klass.prototype);
|
||||
Object.setPrototypeOf(ExtendableBuiltin, klass);
|
||||
|
||||
return ExtendableBuiltin;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import content from '../content/index';
|
||||
import get from 'lodash/get';
|
||||
import content from '../content/index';
|
||||
|
||||
module.exports = function getItemByPathAndType (type, path) {
|
||||
export default function getItemByPathAndType (type, path) {
|
||||
let item = get(content, path);
|
||||
|
||||
if (type === 'timeTravelersStable') {
|
||||
let [, animalType, key] = path.split('.');
|
||||
const [, animalType, key] = path.split('.');
|
||||
|
||||
item = {
|
||||
key,
|
||||
@@ -14,4 +14,4 @@ module.exports = function getItemByPathAndType (type, path) {
|
||||
}
|
||||
|
||||
return item;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
import _mapValues from 'lodash/mapValues';
|
||||
import i18n from '../i18n';
|
||||
import content from '../content/index';
|
||||
import { BadRequest } from './errors';
|
||||
import count from '../count';
|
||||
import * as count from '../count';
|
||||
|
||||
import isPinned from './isPinned';
|
||||
import isFreeRebirth from './isFreeRebirth';
|
||||
import getOfficialPinnedItems from './getOfficialPinnedItems';
|
||||
|
||||
import _mapValues from 'lodash/mapValues';
|
||||
|
||||
function lockQuest (quest, user) {
|
||||
if (quest.key === 'lostMasterclasser1') return !(user.achievements.quests.dilatoryDistress3 && user.achievements.quests.mayhemMistiflying3 && user.achievements.quests.stoikalmCalamity3 && user.achievements.quests.taskwoodsTerror3);
|
||||
@@ -20,7 +20,7 @@ function lockQuest (quest, user) {
|
||||
}
|
||||
|
||||
function isItemSuggested (officialPinnedItems, itemInfo) {
|
||||
return officialPinnedItems.findIndex(officialItem => {
|
||||
return officialPinnedItems.findIndex(officialItem => { // eslint-disable-line arrow-body-style
|
||||
return officialItem.type === itemInfo.pinType && officialItem.path === itemInfo.path;
|
||||
}) > -1;
|
||||
}
|
||||
@@ -46,18 +46,18 @@ function getDefaultGearProps (item, language) {
|
||||
};
|
||||
}
|
||||
|
||||
module.exports = function getItemInfo (user, type, item, officialPinnedItems, language = 'en') {
|
||||
export default function getItemInfo (user, type, item, officialPinnedItems, language = 'en') {
|
||||
if (officialPinnedItems === undefined) {
|
||||
officialPinnedItems = getOfficialPinnedItems(user);
|
||||
officialPinnedItems = getOfficialPinnedItems(user); // eslint-disable-line no-param-reassign
|
||||
}
|
||||
|
||||
let itemInfo;
|
||||
|
||||
switch (type) {
|
||||
switch (type) { // eslint-disable-line default-case
|
||||
case 'eggs':
|
||||
itemInfo = {
|
||||
key: item.key,
|
||||
text: i18n.t('egg', {eggType: item.text(language)}, language),
|
||||
text: i18n.t('egg', { eggType: item.text(language) }, language),
|
||||
notes: item.notes(language),
|
||||
value: item.value,
|
||||
class: `Pet_Egg_${item.key}`,
|
||||
@@ -71,7 +71,7 @@ module.exports = function getItemInfo (user, type, item, officialPinnedItems, la
|
||||
case 'hatchingPotions':
|
||||
itemInfo = {
|
||||
key: item.key,
|
||||
text: i18n.t('potion', {potionType: item.text(language)}),
|
||||
text: i18n.t('potion', { potionType: item.text(language) }),
|
||||
notes: item.notes(language),
|
||||
class: `Pet_HatchingPotion_${item.key}`,
|
||||
value: item.value,
|
||||
@@ -85,7 +85,7 @@ module.exports = function getItemInfo (user, type, item, officialPinnedItems, la
|
||||
case 'premiumHatchingPotion':
|
||||
itemInfo = {
|
||||
key: item.key,
|
||||
text: i18n.t('potion', {potionType: item.text(language)}),
|
||||
text: i18n.t('potion', { potionType: item.text(language) }),
|
||||
notes: `${item.notes(language)} ${item._addlNotes(language)}`,
|
||||
class: `Pet_HatchingPotion_${item.key}`,
|
||||
value: item.value,
|
||||
@@ -124,7 +124,7 @@ module.exports = function getItemInfo (user, type, item, officialPinnedItems, la
|
||||
};
|
||||
break;
|
||||
case 'quests': // eslint-disable-line no-case-declarations
|
||||
const locked = lockQuest(item, user);
|
||||
const locked = lockQuest(item, user); // eslint-disable-line no-case-declarations
|
||||
|
||||
itemInfo = {
|
||||
key: item.key,
|
||||
@@ -133,16 +133,16 @@ module.exports = function getItemInfo (user, type, item, officialPinnedItems, la
|
||||
group: item.group,
|
||||
value: item.goldValue ? item.goldValue : item.value,
|
||||
locked,
|
||||
previous: content.quests[item.previous] ? content.quests[item.previous].text(language) : null,
|
||||
previous: content.quests[item.previous]
|
||||
? content.quests[item.previous].text(language)
|
||||
: null,
|
||||
unlockCondition: item.unlockCondition,
|
||||
drop: item.drop,
|
||||
boss: item.boss,
|
||||
collect: item.collect ? _mapValues(item.collect, (o) => {
|
||||
return {
|
||||
count: o.count,
|
||||
text: o.text(),
|
||||
};
|
||||
}) : undefined,
|
||||
collect: item.collect ? _mapValues(item.collect, o => ({
|
||||
count: o.count,
|
||||
text: o.text(),
|
||||
})) : undefined,
|
||||
lvl: item.lvl,
|
||||
class: locked ? `inventory_quest_scroll_${item.key}_locked` : `inventory_quest_scroll_${item.key}`,
|
||||
purchaseType: 'quests',
|
||||
@@ -283,7 +283,7 @@ module.exports = function getItemInfo (user, type, item, officialPinnedItems, la
|
||||
};
|
||||
break;
|
||||
case 'card': {
|
||||
let spellInfo = content.spells.special[item.key];
|
||||
const spellInfo = content.spells.special[item.key];
|
||||
|
||||
itemInfo = {
|
||||
key: item.key,
|
||||
@@ -366,8 +366,8 @@ module.exports = function getItemInfo (user, type, item, officialPinnedItems, la
|
||||
itemInfo.isSuggested = isItemSuggested(officialPinnedItems, itemInfo);
|
||||
itemInfo.pinned = isPinned(user, itemInfo, officialPinnedItems);
|
||||
} else {
|
||||
throw new BadRequest(i18n.t('wrongItemType', {type}, language));
|
||||
throw new BadRequest(i18n.t('wrongItemType', { type }, language));
|
||||
}
|
||||
|
||||
return itemInfo;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,28 +1,28 @@
|
||||
import content from '../content/index';
|
||||
import SeasonalShopConfig from '../libs/shops-seasonal.config';
|
||||
import toArray from 'lodash/toArray';
|
||||
import content from '../content/index';
|
||||
import SeasonalShopConfig from './shops-seasonal.config';
|
||||
|
||||
const officialPinnedItems = content.officialPinnedItems;
|
||||
const { officialPinnedItems } = content;
|
||||
|
||||
let flatGearArray = toArray(content.gear.flat);
|
||||
const flatGearArray = toArray(content.gear.flat);
|
||||
|
||||
module.exports = function getOfficialPinnedItems (user) {
|
||||
let officialItemsArray = [...officialPinnedItems];
|
||||
export default function getOfficialPinnedItems (user) {
|
||||
const officialItemsArray = [...officialPinnedItems];
|
||||
|
||||
if (SeasonalShopConfig.pinnedSets && Boolean(user) && user.stats.class) {
|
||||
let setToAdd = SeasonalShopConfig.pinnedSets[user.stats.class];
|
||||
const setToAdd = SeasonalShopConfig.pinnedSets[user.stats.class];
|
||||
|
||||
// pinnedSets == current seasonal class set are always gold purchaseable
|
||||
|
||||
flatGearArray.filter((gear) => {
|
||||
return user.items.gear.owned[gear.key] === undefined && gear.set === setToAdd;
|
||||
}).map((gear) => {
|
||||
officialItemsArray.push({
|
||||
type: 'marketGear',
|
||||
path: `gear.flat.${gear.key}`,
|
||||
flatGearArray
|
||||
.filter(gear => user.items.gear.owned[gear.key] === undefined && gear.set === setToAdd)
|
||||
.forEach(gear => {
|
||||
officialItemsArray.push({
|
||||
type: 'marketGear',
|
||||
path: `gear.flat.${gear.key}`,
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
return officialItemsArray;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
// TODO move to client
|
||||
|
||||
module.exports = function gold (num) {
|
||||
export default function gold (num) {
|
||||
if (num) {
|
||||
return Math.floor(num);
|
||||
} else {
|
||||
return '0';
|
||||
}
|
||||
};
|
||||
return '0';
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
// Check if user has Class system enabled
|
||||
module.exports = function hasClass (member) {
|
||||
export default function hasClass (member) {
|
||||
return (
|
||||
member.stats.lvl >= 10 &&
|
||||
!member.preferences.disableClasses &&
|
||||
member.flags.classSelected
|
||||
member.stats.lvl >= 10
|
||||
&& !member.preferences.disableClasses
|
||||
&& member.flags.classSelected
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import compactArray from 'lodash/compact';
|
||||
import getItemInfo from './getItemInfo';
|
||||
import shops from './shops';
|
||||
import getOfficialPinnedItems from './getOfficialPinnedItems';
|
||||
import compactArray from 'lodash/compact';
|
||||
|
||||
import getItemByPathAndType from './getItemByPathAndType';
|
||||
import {checkPinnedAreasForNullEntries} from '../ops/pinnedGearUtils';
|
||||
import { checkPinnedAreasForNullEntries } from '../ops/pinnedGearUtils';
|
||||
|
||||
/**
|
||||
* Orders the pinned items so we always get our inAppRewards in the order
|
||||
@@ -15,12 +15,12 @@ import {checkPinnedAreasForNullEntries} from '../ops/pinnedGearUtils';
|
||||
* @return items of ordered inAppRewards
|
||||
*/
|
||||
function sortInAppRewards (user, items) {
|
||||
let pinnedItemsOrder = user.pinnedItemsOrder;
|
||||
const { pinnedItemsOrder } = user;
|
||||
let orderedItems = [];
|
||||
let unorderedItems = []; // what we want to add later
|
||||
const unorderedItems = []; // what we want to add later
|
||||
|
||||
items.forEach((item, index) => {
|
||||
let i = pinnedItemsOrder[index] === item.path ? index : pinnedItemsOrder.indexOf(item.path);
|
||||
const i = pinnedItemsOrder[index] === item.path ? index : pinnedItemsOrder.indexOf(item.path);
|
||||
if (i === -1) {
|
||||
unorderedItems.push(item);
|
||||
} else {
|
||||
@@ -32,27 +32,28 @@ function sortInAppRewards (user, items) {
|
||||
return orderedItems;
|
||||
}
|
||||
|
||||
module.exports = function getPinnedItems (user) {
|
||||
export default function getPinnedItems (user) {
|
||||
checkPinnedAreasForNullEntries(user);
|
||||
|
||||
let officialPinnedItems = getOfficialPinnedItems(user);
|
||||
const officialPinnedItems = getOfficialPinnedItems(user);
|
||||
|
||||
const officialPinnedItemsNotUnpinned = officialPinnedItems.filter(officialPin => {
|
||||
const isUnpinned = user.unpinnedItems.findIndex(unpinned => unpinned.path === officialPin.path) > -1;
|
||||
const isUnpinned = user.unpinnedItems
|
||||
.findIndex(unpinned => unpinned.path === officialPin.path) > -1;
|
||||
return !isUnpinned;
|
||||
});
|
||||
|
||||
const pinnedItems = officialPinnedItemsNotUnpinned.concat(user.pinnedItems);
|
||||
|
||||
let items = pinnedItems
|
||||
.map(({type, path}) => {
|
||||
let item = getItemByPathAndType(type, path);
|
||||
const items = pinnedItems
|
||||
.map(({ type, path }) => {
|
||||
const item = getItemByPathAndType(type, path);
|
||||
|
||||
return getItemInfo(user, type, item, officialPinnedItems);
|
||||
});
|
||||
|
||||
shops.checkMarketGearLocked(user, items);
|
||||
|
||||
let orderedItems = sortInAppRewards(user, items);
|
||||
const orderedItems = sortInAppRewards(user, items);
|
||||
return orderedItems;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import moment from 'moment';
|
||||
import { MAX_LEVEL } from '../constants';
|
||||
|
||||
module.exports = function isFreeRebirth (user) {
|
||||
export default function isFreeRebirth (user) {
|
||||
let daysFromLastFreeRebirth = user.flags.lastFreeRebirth;
|
||||
|
||||
if (daysFromLastFreeRebirth) {
|
||||
@@ -11,4 +11,4 @@ module.exports = function isFreeRebirth (user) {
|
||||
}
|
||||
|
||||
return user.stats.lvl >= MAX_LEVEL && daysFromLastFreeRebirth > 45;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
export default function isPinned (user, item, checkOfficialPinnedItems) {
|
||||
if (user === null) return false;
|
||||
|
||||
module.exports = function isPinned (user, item, checkOfficialPinnedItems /* getOfficialPinnedItems */) {
|
||||
if (user === null)
|
||||
return false;
|
||||
const isPinnedOfficial = checkOfficialPinnedItems !== undefined
|
||||
&& checkOfficialPinnedItems.findIndex(pinned => pinned.path === item.path) > -1;
|
||||
const isItemUnpinned = user.unpinnedItems !== undefined
|
||||
&& user.unpinnedItems.findIndex(unpinned => unpinned.path === item.path) > -1;
|
||||
const isItemPinned = user.pinnedItems !== undefined
|
||||
&& user.pinnedItems.findIndex(pinned => pinned.path === item.path) > -1;
|
||||
|
||||
const isPinnedOfficial = checkOfficialPinnedItems !== undefined && checkOfficialPinnedItems.findIndex(pinned => pinned.path === item.path) > -1;
|
||||
const isItemUnpinned = user.unpinnedItems !== undefined && user.unpinnedItems.findIndex(unpinned => unpinned.path === item.path) > -1;
|
||||
const isItemPinned = user.pinnedItems !== undefined && user.pinnedItems.findIndex(pinned => pinned.path === item.path) > -1;
|
||||
|
||||
if (isPinnedOfficial && !isItemUnpinned)
|
||||
return true;
|
||||
if (isPinnedOfficial && !isItemUnpinned) return true;
|
||||
|
||||
return isItemPinned;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -7,8 +7,6 @@ are any tags active?
|
||||
|
||||
// TODO move to client
|
||||
|
||||
module.exports = function noTags (tags) {
|
||||
return isEmpty(tags) || isEmpty(filter(tags, (t) => {
|
||||
return t;
|
||||
}));
|
||||
};
|
||||
export default function noTags (tags) {
|
||||
return isEmpty(tags) || isEmpty(filter(tags, t => t));
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// TODO move to client
|
||||
|
||||
module.exports = function percent (x, y, dir) {
|
||||
export default function percent (x, y, dir) {
|
||||
let roundFn;
|
||||
switch (dir) {
|
||||
case 'up':
|
||||
@@ -13,7 +13,7 @@ module.exports = function percent (x, y, dir) {
|
||||
roundFn = Math.round;
|
||||
}
|
||||
if (x === 0) {
|
||||
x = 1;
|
||||
x = 1; // eslint-disable-line no-param-reassign
|
||||
}
|
||||
return Math.max(0, roundFn(x / y * 100));
|
||||
};
|
||||
return Math.max(0, roundFn((x / y) * 100));
|
||||
}
|
||||
|
||||
@@ -5,11 +5,11 @@ import each from 'lodash/each';
|
||||
import set from 'lodash/set';
|
||||
import get from 'lodash/get';
|
||||
|
||||
module.exports = function pickDeep (obj, properties) {
|
||||
export default function pickDeep (obj, properties) {
|
||||
if (!Array.isArray(properties)) throw new Error('"properties" must be an array');
|
||||
|
||||
let result = {};
|
||||
each(properties, (prop) => set(result, prop, get(obj, prop)));
|
||||
const result = {};
|
||||
each(properties, prop => set(result, prop, get(obj, prop)));
|
||||
|
||||
return result;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
module.exports = {
|
||||
export default {
|
||||
convRate: 20,
|
||||
convCap: 25,
|
||||
};
|
||||
|
||||
@@ -3,10 +3,8 @@ import filter from 'lodash/filter';
|
||||
|
||||
// TODO used only in v2
|
||||
|
||||
module.exports = function preenTodos (tasks) {
|
||||
return filter(tasks, (t) => {
|
||||
return !t.completed || t.challenge && t.challenge.id || moment(t.dateCompleted).isAfter(moment().subtract({
|
||||
days: 3,
|
||||
}));
|
||||
});
|
||||
};
|
||||
export default function preenTodos (tasks) {
|
||||
return filter(tasks, t => !t.completed || t.challenge && t.challenge.id || moment(t.dateCompleted).isAfter(moment().subtract({ // eslint-disable-line
|
||||
days: 3,
|
||||
})));
|
||||
}
|
||||
|
||||
@@ -1,21 +1,19 @@
|
||||
import values from 'lodash/values';
|
||||
import keys from 'lodash/keys';
|
||||
|
||||
function trueRandom () {
|
||||
export function trueRandom () {
|
||||
return Math.random();
|
||||
}
|
||||
|
||||
// Get a random property from an object
|
||||
// returns random property (the value)
|
||||
module.exports = function randomVal (obj, options = {}) {
|
||||
let array = options.key ? keys(obj) : values(obj);
|
||||
let random = options.predictableRandom || trueRandom();
|
||||
export default function randomVal (obj, options = {}) {
|
||||
const array = options.key ? keys(obj) : values(obj);
|
||||
const random = options.predictableRandom || trueRandom();
|
||||
|
||||
array.sort();
|
||||
|
||||
let randomIndex = Math.floor(random * array.length);
|
||||
const randomIndex = Math.floor(random * array.length);
|
||||
|
||||
return array[randomIndex];
|
||||
};
|
||||
|
||||
module.exports.trueRandom = trueRandom;
|
||||
}
|
||||
|
||||
@@ -4,12 +4,14 @@ import values from 'lodash/values';
|
||||
import uuid from './uuid';
|
||||
|
||||
/*
|
||||
Reflists are arrays, but stored as objects. Mongoose has a helluvatime working with arrays (the main problem for our
|
||||
syncing issues) - so the goal is to move away from arrays to objects, since mongoose can reference elements by ID
|
||||
Reflists are arrays, but stored as objects.
|
||||
Mongoose has a helluvatime working with arrays (the main problem for our
|
||||
syncing issues) - so the goal is to move away from arrays to objects,
|
||||
since mongoose can reference elements by ID
|
||||
no problem. To maintain sorting, we use these helper functions:
|
||||
*/
|
||||
|
||||
module.exports = function refPush (reflist, item) {
|
||||
export default function refPush (reflist, item) {
|
||||
item.sort = isEmpty(reflist) ? 0 : maxBy(values(reflist), 'sort').sort + 1;
|
||||
|
||||
if (!(item.id && !reflist[item.id])) {
|
||||
@@ -19,4 +21,4 @@ module.exports = function refPush (reflist, item) {
|
||||
reflist[item.id] = item;
|
||||
|
||||
return reflist[item.id];
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { SEASONAL_SETS } from '../content/constants';
|
||||
|
||||
module.exports = {
|
||||
export default {
|
||||
opened: true,
|
||||
|
||||
currentSeason: 'Fall',
|
||||
|
||||
+136
-160
@@ -17,7 +17,7 @@ import featuredItems from '../content/shop-featuredItems';
|
||||
|
||||
import getOfficialPinnedItems from './getOfficialPinnedItems';
|
||||
|
||||
let shops = {};
|
||||
const shops = {};
|
||||
|
||||
/* Market */
|
||||
|
||||
@@ -30,18 +30,16 @@ shops.getMarketShop = function getMarketShop (user, language) {
|
||||
categories: shops.getMarketCategories(user, language),
|
||||
featured: {
|
||||
text: i18n.t('featuredItems'),
|
||||
items: featuredItems.market.map(i => {
|
||||
return getItemInfo(user, i.type, get(content, i.path));
|
||||
}),
|
||||
items: featuredItems.market.map(i => getItemInfo(user, i.type, get(content, i.path))),
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
shops.getMarketCategories = function getMarket (user, language) {
|
||||
let officialPinnedItems = getOfficialPinnedItems(user);
|
||||
const officialPinnedItems = getOfficialPinnedItems(user);
|
||||
|
||||
let categories = [];
|
||||
let eggsCategory = {
|
||||
const categories = [];
|
||||
const eggsCategory = {
|
||||
identifier: 'eggs',
|
||||
text: i18n.t('eggs', language),
|
||||
notes: i18n.t('dropsExplanationEggs', language),
|
||||
@@ -50,47 +48,39 @@ shops.getMarketCategories = function getMarket (user, language) {
|
||||
eggsCategory.items = sortBy(values(content.questEggs)
|
||||
.filter(egg => egg.canBuy(user))
|
||||
.concat(values(content.dropEggs))
|
||||
.map(egg => {
|
||||
return getItemInfo(user, 'eggs', egg, officialPinnedItems, language);
|
||||
}), 'key');
|
||||
.map(egg => getItemInfo(user, 'eggs', egg, officialPinnedItems, language)), 'key');
|
||||
categories.push(eggsCategory);
|
||||
|
||||
let hatchingPotionsCategory = {
|
||||
const hatchingPotionsCategory = {
|
||||
identifier: 'hatchingPotions',
|
||||
text: i18n.t('hatchingPotions', language),
|
||||
notes: i18n.t('dropsExplanation', language),
|
||||
};
|
||||
hatchingPotionsCategory.items = sortBy(values(content.hatchingPotions)
|
||||
.filter(hp => !hp.limited)
|
||||
.map(hatchingPotion => {
|
||||
return getItemInfo(user, 'hatchingPotions', hatchingPotion, officialPinnedItems, language);
|
||||
}), 'key');
|
||||
.map(hatchingPotion => getItemInfo(user, 'hatchingPotions', hatchingPotion, officialPinnedItems, language)), 'key');
|
||||
categories.push(hatchingPotionsCategory);
|
||||
|
||||
let premiumHatchingPotionsCategory = {
|
||||
const premiumHatchingPotionsCategory = {
|
||||
identifier: 'premiumHatchingPotions',
|
||||
text: i18n.t('magicHatchingPotions', language),
|
||||
notes: i18n.t('premiumPotionNoDropExplanation', language),
|
||||
};
|
||||
premiumHatchingPotionsCategory.items = sortBy(values(content.hatchingPotions)
|
||||
.filter(hp => hp.limited && hp.canBuy(user))
|
||||
.map(premiumHatchingPotion => {
|
||||
return getItemInfo(user, 'premiumHatchingPotion', premiumHatchingPotion, officialPinnedItems, language);
|
||||
}), 'key');
|
||||
.map(premiumHatchingPotion => getItemInfo(user, 'premiumHatchingPotion', premiumHatchingPotion, officialPinnedItems, language)), 'key');
|
||||
if (premiumHatchingPotionsCategory.items.length > 0) {
|
||||
categories.push(premiumHatchingPotionsCategory);
|
||||
}
|
||||
|
||||
let foodCategory = {
|
||||
const foodCategory = {
|
||||
identifier: 'food',
|
||||
text: i18n.t('food', language),
|
||||
notes: i18n.t('dropsExplanation', language),
|
||||
};
|
||||
foodCategory.items = sortBy(values(content.food)
|
||||
.filter(food => food.canDrop || food.key === 'Saddle')
|
||||
.map(foodItem => {
|
||||
return getItemInfo(user, 'food', foodItem, officialPinnedItems, language);
|
||||
}), 'key');
|
||||
.map(foodItem => getItemInfo(user, 'food', foodItem, officialPinnedItems, language)), 'key');
|
||||
categories.push(foodCategory);
|
||||
|
||||
return categories;
|
||||
@@ -99,27 +89,26 @@ shops.getMarketCategories = function getMarket (user, language) {
|
||||
function getClassName (classType, language) {
|
||||
if (classType === 'wizard') {
|
||||
return i18n.t('mage', language);
|
||||
} else {
|
||||
return i18n.t(classType, language);
|
||||
}
|
||||
return i18n.t(classType, language);
|
||||
}
|
||||
|
||||
// TODO Refactor the `.locked` logic
|
||||
shops.checkMarketGearLocked = function checkMarketGearLocked (user, items) {
|
||||
let result = filter(items, ['pinType', 'marketGear']);
|
||||
const result = filter(items, ['pinType', 'marketGear']);
|
||||
const officialPinnedItems = getOfficialPinnedItems(user);
|
||||
let availableGear = map(updateStore(user), (item) => getItemInfo(user, 'marketGear', item, officialPinnedItems).path);
|
||||
for (let gear of result) {
|
||||
const availableGear = map(updateStore(user), item => getItemInfo(user, 'marketGear', item, officialPinnedItems).path);
|
||||
for (const gear of result) {
|
||||
if (gear.klass !== user.stats.class) {
|
||||
gear.locked = true;
|
||||
}
|
||||
|
||||
if (!gear.locked && !availableGear.includes(gear.path)) {
|
||||
if (!gear.locked && !availableGear.includes(gear.path)) {
|
||||
gear.locked = true;
|
||||
}
|
||||
|
||||
if (Boolean(gear.specialClass) && Boolean(gear.set)) {
|
||||
let currentSet = gear.set === seasonalShopConfig.pinnedSets[gear.specialClass];
|
||||
const currentSet = gear.set === seasonalShopConfig.pinnedSets[gear.specialClass];
|
||||
|
||||
gear.locked = currentSet && user.stats.class !== gear.specialClass;
|
||||
}
|
||||
@@ -128,7 +117,7 @@ shops.checkMarketGearLocked = function checkMarketGearLocked (user, items) {
|
||||
gear.locked = !gear.canOwn(user);
|
||||
}
|
||||
|
||||
let itemOwned = user.items.gear.owned[gear.key];
|
||||
const itemOwned = user.items.gear.owned[gear.key];
|
||||
|
||||
if (itemOwned === false && !availableGear.includes(gear.path)) {
|
||||
gear.locked = true;
|
||||
@@ -145,37 +134,37 @@ shops.checkMarketGearLocked = function checkMarketGearLocked (user, items) {
|
||||
};
|
||||
|
||||
shops.getMarketGearCategories = function getMarketGear (user, language) {
|
||||
let categories = [];
|
||||
let officialPinnedItems = getOfficialPinnedItems(user);
|
||||
const categories = [];
|
||||
const officialPinnedItems = getOfficialPinnedItems(user);
|
||||
|
||||
for (let classType of content.classes) {
|
||||
let category = {
|
||||
for (const classType of content.classes) {
|
||||
const category = {
|
||||
identifier: classType,
|
||||
text: getClassName(classType, language),
|
||||
};
|
||||
|
||||
let result = filter(content.gear.flat, function findClassGear (gearItem) {
|
||||
const result = filter(content.gear.flat, gearItem => {
|
||||
if (gearItem.klass === classType) return true;
|
||||
let classShift = {
|
||||
const classShift = {
|
||||
items: user.items,
|
||||
stats: {
|
||||
class: classType,
|
||||
},
|
||||
};
|
||||
if (gearItem.specialClass === classType && user.items.gear.owned[gearItem.key] !== false) return gearItem.canOwn(classShift);
|
||||
if (
|
||||
gearItem.specialClass === classType
|
||||
&& user.items.gear.owned[gearItem.key] !== false
|
||||
) return gearItem.canOwn(classShift);
|
||||
return false;
|
||||
});
|
||||
|
||||
category.items = map(result, (e) => {
|
||||
return getItemInfo(user, 'marketGear', e, officialPinnedItems);
|
||||
});
|
||||
category.items = map(result, e => getItemInfo(user, 'marketGear', e, officialPinnedItems));
|
||||
|
||||
let specialGear = filter(content.gear.flat, (gear) => {
|
||||
return user.items.gear.owned[gear.key] === false &&
|
||||
gear.specialClass === classType &&
|
||||
gear.klass === 'special';
|
||||
});
|
||||
const specialGear = filter(content.gear.flat, gear => user.items.gear.owned[gear.key] === false
|
||||
&& gear.specialClass === classType
|
||||
&& gear.klass === 'special');
|
||||
|
||||
each(specialGear, (gear) => {
|
||||
each(specialGear, gear => {
|
||||
category.items.push(getItemInfo(user, 'marketGear', gear));
|
||||
});
|
||||
|
||||
@@ -183,21 +172,17 @@ shops.getMarketGearCategories = function getMarketGear (user, language) {
|
||||
categories.push(category);
|
||||
}
|
||||
|
||||
let nonClassCategory = {
|
||||
const nonClassCategory = {
|
||||
identifier: 'none',
|
||||
text: i18n.t('none', language),
|
||||
};
|
||||
|
||||
let specialNonClassGear = filter(content.gear.flat, (gear) => {
|
||||
return !user.items.gear.owned[gear.key] &&
|
||||
content.classes.indexOf(gear.klass) === -1 &&
|
||||
content.classes.indexOf(gear.specialClass) === -1 &&
|
||||
(gear.canOwn && gear.canOwn(user));
|
||||
});
|
||||
const specialNonClassGear = filter(content.gear.flat, gear => !user.items.gear.owned[gear.key]
|
||||
&& content.classes.indexOf(gear.klass) === -1
|
||||
&& content.classes.indexOf(gear.specialClass) === -1
|
||||
&& (gear.canOwn && gear.canOwn(user)));
|
||||
|
||||
nonClassCategory.items = map(specialNonClassGear, (e) => {
|
||||
return getItemInfo(user, 'marketGear', e);
|
||||
});
|
||||
nonClassCategory.items = map(specialNonClassGear, e => getItemInfo(user, 'marketGear', e));
|
||||
|
||||
shops.checkMarketGearLocked(user, nonClassCategory.items);
|
||||
categories.push(nonClassCategory);
|
||||
@@ -215,16 +200,14 @@ shops.getQuestShop = function getQuestShop (user, language) {
|
||||
categories: shops.getQuestShopCategories(user, language),
|
||||
featured: {
|
||||
text: i18n.t('featuredQuests'),
|
||||
items: featuredItems.quests.map(i => {
|
||||
return getItemInfo(user, i.type, get(content, i.path));
|
||||
}),
|
||||
items: featuredItems.quests.map(i => getItemInfo(user, i.type, get(content, i.path))),
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
shops.getQuestShopCategories = function getQuestShopCategories (user, language) {
|
||||
let categories = [];
|
||||
let officialPinnedItems = getOfficialPinnedItems(user);
|
||||
const categories = [];
|
||||
const officialPinnedItems = getOfficialPinnedItems(user);
|
||||
|
||||
/*
|
||||
* ---------------------------------------------------------------
|
||||
@@ -280,32 +263,28 @@ shops.getQuestShopCategories = function getQuestShopCategories (user, language)
|
||||
*
|
||||
*/
|
||||
|
||||
let bundleCategory = {
|
||||
const bundleCategory = {
|
||||
identifier: 'bundle',
|
||||
text: i18n.t('questBundles', language),
|
||||
};
|
||||
|
||||
bundleCategory.items = sortBy(values(content.bundles)
|
||||
.filter(bundle => bundle.type === 'quests' && bundle.canBuy())
|
||||
.map(bundle => {
|
||||
return getItemInfo(user, 'bundles', bundle, officialPinnedItems, language);
|
||||
}));
|
||||
.map(bundle => getItemInfo(user, 'bundles', bundle, officialPinnedItems, language)));
|
||||
|
||||
if (bundleCategory.items.length > 0) {
|
||||
categories.push(bundleCategory);
|
||||
}
|
||||
|
||||
each(content.userCanOwnQuestCategories, type => {
|
||||
let category = {
|
||||
const category = {
|
||||
identifier: type,
|
||||
text: i18n.t(`${type}Quests`, language),
|
||||
};
|
||||
|
||||
category.items = content.questsByLevel
|
||||
.filter(quest => quest.canBuy(user) && quest.category === type)
|
||||
.map(quest => {
|
||||
return getItemInfo(user, 'quests', quest, officialPinnedItems, language);
|
||||
});
|
||||
.map(quest => getItemInfo(user, 'quests', quest, officialPinnedItems, language));
|
||||
|
||||
categories.push(category);
|
||||
});
|
||||
@@ -316,7 +295,7 @@ shops.getQuestShopCategories = function getQuestShopCategories (user, language)
|
||||
/* Time Travelers */
|
||||
|
||||
shops.getTimeTravelersShop = function getTimeTravelersShop (user, language) {
|
||||
let hasTrinkets = user.purchased.plan.consecutive.trinkets > 0;
|
||||
const hasTrinkets = user.purchased.plan.consecutive.trinkets > 0;
|
||||
|
||||
return {
|
||||
identifier: 'timeTravelersShop',
|
||||
@@ -329,78 +308,71 @@ shops.getTimeTravelersShop = function getTimeTravelersShop (user, language) {
|
||||
};
|
||||
|
||||
shops.getTimeTravelersCategories = function getTimeTravelersCategories (user, language) {
|
||||
let categories = [];
|
||||
let stable = {pets: 'Pet-', mounts: 'Mount_Icon_'};
|
||||
const categories = [];
|
||||
const stable = { pets: 'Pet-', mounts: 'Mount_Icon_' };
|
||||
|
||||
let officialPinnedItems = getOfficialPinnedItems(user);
|
||||
const officialPinnedItems = getOfficialPinnedItems(user);
|
||||
|
||||
let questCategory = {
|
||||
const questCategory = {
|
||||
identifier: 'quests',
|
||||
text: i18n.t('quests', language),
|
||||
items: [],
|
||||
};
|
||||
for (let key in content.quests) {
|
||||
for (const key in content.quests) {
|
||||
if (content.quests[key].category === 'timeTravelers') {
|
||||
let item = getItemInfo(user, 'quests', content.quests[key], officialPinnedItems, language);
|
||||
const item = getItemInfo(user, 'quests', content.quests[key], officialPinnedItems, language);
|
||||
questCategory.items.push(item);
|
||||
}
|
||||
}
|
||||
categories.push(questCategory);
|
||||
|
||||
for (let type in stable) {
|
||||
if (stable.hasOwnProperty(type)) {
|
||||
let category = {
|
||||
identifier: type,
|
||||
text: i18n.t(type, language),
|
||||
items: [],
|
||||
};
|
||||
for (const type of Object.keys(stable)) {
|
||||
const category = {
|
||||
identifier: type,
|
||||
text: i18n.t(type, language),
|
||||
items: [],
|
||||
};
|
||||
|
||||
for (let key in content.timeTravelStable[type]) {
|
||||
if (content.timeTravelStable[type].hasOwnProperty(key)) {
|
||||
if (!user.items[type][key]) {
|
||||
let item = getItemInfo(user, 'timeTravelersStable', {
|
||||
key,
|
||||
type,
|
||||
}, officialPinnedItems, language);
|
||||
category.items.push(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (category.items.length > 0) {
|
||||
categories.push(category);
|
||||
for (const key of Object.keys(content.timeTravelStable[type])) {
|
||||
if (!user.items[type][key]) {
|
||||
const item = getItemInfo(user, 'timeTravelersStable', {
|
||||
key,
|
||||
type,
|
||||
}, officialPinnedItems, language);
|
||||
category.items.push(item);
|
||||
}
|
||||
}
|
||||
|
||||
if (category.items.length > 0) {
|
||||
categories.push(category);
|
||||
}
|
||||
}
|
||||
|
||||
let sets = content.timeTravelerStore(user);
|
||||
for (let setKey in sets) {
|
||||
if (sets.hasOwnProperty(setKey)) {
|
||||
let set = sets[setKey];
|
||||
let category = {
|
||||
identifier: set.key,
|
||||
text: set.text(language),
|
||||
path: `mystery.${set.key}`,
|
||||
pinType: 'mystery_set',
|
||||
purchaseAll: true,
|
||||
};
|
||||
const sets = content.timeTravelerStore(user);
|
||||
for (const setKey of Object.keys(sets)) {
|
||||
const set = sets[setKey];
|
||||
const category = {
|
||||
identifier: set.key,
|
||||
text: set.text(language),
|
||||
path: `mystery.${set.key}`,
|
||||
pinType: 'mystery_set',
|
||||
purchaseAll: true,
|
||||
};
|
||||
|
||||
category.items = map(set.items, item => {
|
||||
return {
|
||||
key: item.key,
|
||||
text: item.text(language),
|
||||
notes: item.notes(language),
|
||||
type: item.type,
|
||||
purchaseType: 'gear',
|
||||
value: 1,
|
||||
locked: false,
|
||||
currency: 'hourglasses',
|
||||
class: `shop_${item.key}`,
|
||||
pinKey: `timeTravelers!gear.flat.${item.key}`,
|
||||
};
|
||||
});
|
||||
if (category.items.length > 0) {
|
||||
categories.push(category);
|
||||
}
|
||||
category.items = map(set.items, item => ({
|
||||
key: item.key,
|
||||
text: item.text(language),
|
||||
notes: item.notes(language),
|
||||
type: item.type,
|
||||
purchaseType: 'gear',
|
||||
value: 1,
|
||||
locked: false,
|
||||
currency: 'hourglasses',
|
||||
class: `shop_${item.key}`,
|
||||
pinKey: `timeTravelers!gear.flat.${item.key}`,
|
||||
}));
|
||||
if (category.items.length > 0) {
|
||||
categories.push(category);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -410,19 +382,21 @@ shops.getTimeTravelersCategories = function getTimeTravelersCategories (user, la
|
||||
|
||||
/* Seasonal */
|
||||
|
||||
let flatGearArray = toArray(content.gear.flat);
|
||||
const flatGearArray = toArray(content.gear.flat);
|
||||
|
||||
shops.getSeasonalGearBySet = function getSeasonalGearBySet (user, set, officialPinnedItems, language, ignoreAlreadyOwned = false) {
|
||||
return flatGearArray.filter((gear) => {
|
||||
if (!ignoreAlreadyOwned && user.items.gear.owned[gear.key] !== undefined)
|
||||
return false;
|
||||
shops.getSeasonalGearBySet = function getSeasonalGearBySet (
|
||||
user, set, officialPinnedItems,
|
||||
language, ignoreAlreadyOwned = false,
|
||||
) {
|
||||
return flatGearArray.filter(gear => {
|
||||
if (!ignoreAlreadyOwned && user.items.gear.owned[gear.key] !== undefined) return false;
|
||||
|
||||
return gear.set === set;
|
||||
}).map(gear => {
|
||||
let currentSet = gear.set === seasonalShopConfig.pinnedSets[gear.specialClass];
|
||||
const currentSet = gear.set === seasonalShopConfig.pinnedSets[gear.specialClass];
|
||||
|
||||
// only the current season set can be purchased by gold
|
||||
let itemInfo = getItemInfo(null, currentSet ? 'marketGear' : 'gear', gear, officialPinnedItems, language);
|
||||
const itemInfo = getItemInfo(null, currentSet ? 'marketGear' : 'gear', gear, officialPinnedItems, language);
|
||||
itemInfo.locked = currentSet && user.stats.class !== gear.specialClass;
|
||||
|
||||
return itemInfo;
|
||||
@@ -430,9 +404,9 @@ shops.getSeasonalGearBySet = function getSeasonalGearBySet (user, set, officialP
|
||||
};
|
||||
|
||||
shops.getSeasonalShop = function getSeasonalShop (user, language) {
|
||||
let officialPinnedItems = getOfficialPinnedItems(user);
|
||||
const officialPinnedItems = getOfficialPinnedItems(user);
|
||||
|
||||
let resObject = {
|
||||
const resObject = {
|
||||
identifier: 'seasonalShop',
|
||||
text: i18n.t('seasonalShop'),
|
||||
notes: i18n.t(`seasonalShop${seasonalShopConfig.currentSeason}Text`),
|
||||
@@ -441,7 +415,13 @@ shops.getSeasonalShop = function getSeasonalShop (user, language) {
|
||||
categories: this.getSeasonalShopCategories(user, language),
|
||||
featured: {
|
||||
text: i18n.t(seasonalShopConfig.featuredSet),
|
||||
items: shops.getSeasonalGearBySet(user, seasonalShopConfig.featuredSet, officialPinnedItems, language, true),
|
||||
items: shops.getSeasonalGearBySet(
|
||||
user,
|
||||
seasonalShopConfig.featuredSet,
|
||||
officialPinnedItems,
|
||||
language,
|
||||
true,
|
||||
),
|
||||
},
|
||||
};
|
||||
|
||||
@@ -453,7 +433,7 @@ shops.getSeasonalShop = function getSeasonalShop (user, language) {
|
||||
// setKey: i18n.t('setTranslationString', language),
|
||||
// };
|
||||
shops.getSeasonalShopCategories = function getSeasonalShopCategories (user, language) {
|
||||
let officialPinnedItems = getOfficialPinnedItems(user);
|
||||
const officialPinnedItems = getOfficialPinnedItems(user);
|
||||
|
||||
const AVAILABLE_SPELLS = [
|
||||
...seasonalShopConfig.availableSpells,
|
||||
@@ -463,44 +443,42 @@ shops.getSeasonalShopCategories = function getSeasonalShopCategories (user, lang
|
||||
...seasonalShopConfig.availableQuests,
|
||||
];
|
||||
|
||||
let categories = [];
|
||||
const categories = [];
|
||||
|
||||
let spells = pickBy(content.spells.special, (spell, key) => {
|
||||
return AVAILABLE_SPELLS.indexOf(key) !== -1;
|
||||
});
|
||||
const spells = pickBy(
|
||||
content.spells.special,
|
||||
(spell, key) => AVAILABLE_SPELLS.indexOf(key) !== -1,
|
||||
);
|
||||
|
||||
if (keys(spells).length > 0) {
|
||||
let category = {
|
||||
const category = {
|
||||
identifier: 'spells',
|
||||
text: i18n.t('seasonalItems', language),
|
||||
};
|
||||
|
||||
category.items = map(spells, (spell) => {
|
||||
return getItemInfo(user, 'seasonalSpell', spell, officialPinnedItems, language);
|
||||
});
|
||||
category.items = map(
|
||||
spells,
|
||||
spell => getItemInfo(user, 'seasonalSpell', spell, officialPinnedItems, language),
|
||||
);
|
||||
|
||||
categories.push(category);
|
||||
}
|
||||
|
||||
let quests = pickBy(content.quests, (quest, key) => {
|
||||
return AVAILABLE_QUESTS.indexOf(key) !== -1;
|
||||
});
|
||||
const quests = pickBy(content.quests, (quest, key) => AVAILABLE_QUESTS.indexOf(key) !== -1);
|
||||
|
||||
if (keys(quests).length > 0) {
|
||||
let category = {
|
||||
const category = {
|
||||
identifier: 'quests',
|
||||
text: i18n.t('quests', language),
|
||||
};
|
||||
|
||||
category.items = map(quests, (quest) => {
|
||||
return getItemInfo(user, 'seasonalQuest', quest, officialPinnedItems, language);
|
||||
});
|
||||
category.items = map(quests, quest => getItemInfo(user, 'seasonalQuest', quest, officialPinnedItems, language));
|
||||
|
||||
categories.push(category);
|
||||
}
|
||||
|
||||
for (let set of seasonalShopConfig.availableSets) {
|
||||
let category = {
|
||||
for (const set of seasonalShopConfig.availableSets) {
|
||||
const category = {
|
||||
identifier: set,
|
||||
text: i18n.t(set),
|
||||
};
|
||||
@@ -508,7 +486,7 @@ shops.getSeasonalShopCategories = function getSeasonalShopCategories (user, lang
|
||||
category.items = shops.getSeasonalGearBySet(user, set, officialPinnedItems, language, false);
|
||||
|
||||
if (category.items.length > 0) {
|
||||
let item = category.items[0];
|
||||
const item = category.items[0];
|
||||
|
||||
category.specialClass = item.specialClass;
|
||||
category.event = item.event;
|
||||
@@ -520,18 +498,16 @@ shops.getSeasonalShopCategories = function getSeasonalShopCategories (user, lang
|
||||
};
|
||||
|
||||
shops.getBackgroundShopSets = function getBackgroundShopSets (language) {
|
||||
let sets = [];
|
||||
let officialPinnedItems = getOfficialPinnedItems();
|
||||
const sets = [];
|
||||
const officialPinnedItems = getOfficialPinnedItems();
|
||||
|
||||
eachRight(content.backgrounds, (group, key) => {
|
||||
let set = {
|
||||
const set = {
|
||||
identifier: key,
|
||||
text: i18n.t(key, language),
|
||||
};
|
||||
|
||||
set.items = map(group, (background) => {
|
||||
return getItemInfo(null, 'background', background, officialPinnedItems, language);
|
||||
});
|
||||
set.items = map(group, background => getItemInfo(null, 'background', background, officialPinnedItems, language));
|
||||
|
||||
sets.push(set);
|
||||
});
|
||||
@@ -539,4 +515,4 @@ shops.getBackgroundShopSets = function getBackgroundShopSets (language) {
|
||||
return sets;
|
||||
};
|
||||
|
||||
module.exports = shops;
|
||||
export default shops;
|
||||
|
||||
@@ -4,11 +4,10 @@ Silver amount from their money
|
||||
|
||||
// TODO move to client
|
||||
|
||||
module.exports = function silver (num) {
|
||||
export default function silver (num) {
|
||||
if (num) {
|
||||
let centCount = Math.floor((num - Math.floor(num)) * 100);
|
||||
const centCount = Math.floor((num - Math.floor(num)) * 100);
|
||||
return `0${centCount}`.slice(-2);
|
||||
} else {
|
||||
return '00';
|
||||
}
|
||||
};
|
||||
return '00';
|
||||
}
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
module.exports = function splitWhitespace (s) {
|
||||
export default function splitWhitespace (s) {
|
||||
return s.split(' ');
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,27 +1,27 @@
|
||||
import each from 'lodash/each';
|
||||
import get from 'lodash/get';
|
||||
import values from 'lodash/values';
|
||||
import content from '../content/index';
|
||||
import content from '../content/index'; // eslint-disable-line import/no-cycle
|
||||
import * as statHelpers from '../statHelpers';
|
||||
|
||||
function equipmentStatBonusComputed (stat, user) {
|
||||
let gear = content.gear.flat;
|
||||
const gear = content.gear.flat;
|
||||
let gearBonus = 0;
|
||||
let classBonus = 0;
|
||||
|
||||
// toObject is required here due to lodash values not working well with mongoose doc objects.
|
||||
// if toObject doesn't exist, we can assume the object is already plain JSON
|
||||
// see http://stackoverflow.com/questions/25767334/underscore-js-keys-and-omit-not-working-as-expected
|
||||
let equipped = user.items.gear.equipped;
|
||||
let equippedKeys = values(!equipped.toObject ? equipped : equipped.toObject());
|
||||
const { equipped } = user.items.gear;
|
||||
const equippedKeys = values(!equipped.toObject ? equipped : equipped.toObject());
|
||||
|
||||
each(equippedKeys, (equippedItem) => {
|
||||
let item = gear[equippedItem];
|
||||
each(equippedKeys, equippedItem => {
|
||||
const item = gear[equippedItem];
|
||||
|
||||
if (item) {
|
||||
let equipmentStat = item[stat];
|
||||
let classBonusMultiplier = item.klass === user.stats.class ||
|
||||
item.specialClass === user.stats.class ? 0.5 : 0;
|
||||
const equipmentStat = item[stat];
|
||||
const classBonusMultiplier = item.klass === user.stats.class
|
||||
|| item.specialClass === user.stats.class ? 0.5 : 0;
|
||||
gearBonus += equipmentStat;
|
||||
classBonus += equipmentStat * classBonusMultiplier;
|
||||
}
|
||||
@@ -33,18 +33,18 @@ function equipmentStatBonusComputed (stat, user) {
|
||||
};
|
||||
}
|
||||
|
||||
module.exports = function statsComputed (user) {
|
||||
let statBreakdown = {
|
||||
export default function statsComputed (user) {
|
||||
const statBreakdown = {
|
||||
gearBonus: {},
|
||||
classBonus: {},
|
||||
baseStat: {},
|
||||
buff: {},
|
||||
levelBonus: {},
|
||||
};
|
||||
each(['per', 'con', 'str', 'int'], (stat) => {
|
||||
let baseStat = get(user, 'stats')[stat];
|
||||
let buff = get(user, 'stats.buffs')[stat];
|
||||
let equipmentBonus = equipmentStatBonusComputed(stat, user);
|
||||
each(['per', 'con', 'str', 'int'], stat => {
|
||||
const baseStat = get(user, 'stats')[stat];
|
||||
const buff = get(user, 'stats.buffs')[stat];
|
||||
const equipmentBonus = equipmentStatBonusComputed(stat, user);
|
||||
|
||||
statBreakdown[stat] = equipmentBonus.gearBonus + equipmentBonus.classBonus + baseStat + buff;
|
||||
statBreakdown[stat] += Math.floor(statHelpers.capByLevel(user.stats.lvl) / 2);
|
||||
@@ -59,4 +59,4 @@ module.exports = function statsComputed (user) {
|
||||
statBreakdown.maxMP = statBreakdown.int * 2 + 30;
|
||||
|
||||
return statBreakdown;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -2,20 +2,21 @@ import { v4 as uuid } from 'uuid';
|
||||
import defaults from 'lodash/defaults';
|
||||
import moment from 'moment';
|
||||
|
||||
// Even though Mongoose handles task defaults, we want to make sure defaults are set on the client-side before
|
||||
// Even though Mongoose handles task defaults,
|
||||
// we want to make sure defaults are set on the client-side before
|
||||
// sending up to the server for performance
|
||||
|
||||
// TODO move to client code?
|
||||
|
||||
const tasksTypes = ['habit', 'daily', 'todo', 'reward'];
|
||||
|
||||
module.exports = function taskDefaults (task, user) {
|
||||
export default function taskDefaults (task, user) {
|
||||
if (!task.type || tasksTypes.indexOf(task.type) === -1) {
|
||||
task.type = 'habit';
|
||||
}
|
||||
|
||||
let defaultId = uuid();
|
||||
let defaultTaskObj = {
|
||||
const defaultId = uuid();
|
||||
const defaultTaskObj = {
|
||||
_id: defaultId,
|
||||
text: task._id || defaultId,
|
||||
notes: '',
|
||||
@@ -65,9 +66,9 @@ module.exports = function taskDefaults (task, user) {
|
||||
}
|
||||
|
||||
if (task.type === 'daily') {
|
||||
let now = moment().zone(user.preferences.timezoneOffset);
|
||||
let startOfDay = now.clone().startOf('day');
|
||||
let startOfDayWithCDSTime = startOfDay
|
||||
const now = moment().zone(user.preferences.timezoneOffset);
|
||||
const startOfDay = now.clone().startOf('day');
|
||||
const startOfDayWithCDSTime = startOfDay
|
||||
.clone()
|
||||
.add({
|
||||
hours: user.preferences.dayStart,
|
||||
@@ -85,9 +86,9 @@ module.exports = function taskDefaults (task, user) {
|
||||
su: true,
|
||||
},
|
||||
// If cron will happen today, start the daily yesterday
|
||||
startDate: startOfDayWithCDSTime.isAfter(now) ?
|
||||
startOfDay.clone().subtract(1, 'day').toDate() :
|
||||
startOfDay.toDate(),
|
||||
startDate: startOfDayWithCDSTime.isAfter(now)
|
||||
? startOfDay.clone().subtract(1, 'day').toDate()
|
||||
: startOfDay.toDate(),
|
||||
everyX: 1,
|
||||
frequency: 'weekly',
|
||||
daysOfMonth: [],
|
||||
@@ -97,4 +98,4 @@ module.exports = function taskDefaults (task, user) {
|
||||
}
|
||||
|
||||
return task;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -8,29 +8,29 @@ import content from '../content/index';
|
||||
// Return the list of gear items available for purchase
|
||||
// TODO: Remove updateStore once the new client is live
|
||||
|
||||
let sortOrder = reduce(content.gearTypes, (accumulator, val, key) => {
|
||||
const sortOrder = reduce(content.gearTypes, (accumulator, val, key) => {
|
||||
accumulator[val] = key;
|
||||
return accumulator;
|
||||
}, {});
|
||||
|
||||
module.exports = function updateStore (user) {
|
||||
export default function updateStore (user) {
|
||||
let changes = [];
|
||||
|
||||
each(content.gearTypes, (type) => {
|
||||
let found = lodashFind(content.gear.tree[type][user.stats.class], (item) => {
|
||||
return !user.items.gear.owned[item.key];
|
||||
});
|
||||
each(content.gearTypes, type => {
|
||||
const found = lodashFind(
|
||||
content.gear.tree[type][user.stats.class],
|
||||
item => !user.items.gear.owned[item.key],
|
||||
);
|
||||
|
||||
if (found) changes.push(found);
|
||||
});
|
||||
|
||||
changes = changes.concat(filter(content.gear.flat, (val) => {
|
||||
changes = changes.concat(filter(content.gear.flat, val => {
|
||||
if (['special', 'mystery', 'armoire'].indexOf(val.klass) !== -1 && !user.items.gear.owned[val.key] && (val.canOwn ? val.canOwn(user) : false)) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}));
|
||||
|
||||
return sortBy(changes, (change) => sortOrder[change.type]);
|
||||
};
|
||||
return sortBy(changes, change => sortOrder[change.type]);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import uuid from 'uuid';
|
||||
|
||||
// TODO remove this file completely
|
||||
module.exports = uuid.v4;
|
||||
export default uuid.v4;
|
||||
|
||||
Reference in New Issue
Block a user