start upgrading eslint
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
{
|
||||
"extends": [
|
||||
"habitrpg/browser",
|
||||
"habitrpg/esnext"
|
||||
"habitrpg/lib/node",
|
||||
]
|
||||
}
|
||||
|
||||
@@ -16,8 +16,8 @@ export const CHAT_FLAG_FROM_SHADOW_MUTE = 10; // a shadow-muted user's post star
|
||||
// @TODO use those constants to replace hard-coded numbers
|
||||
|
||||
export const SUPPORTED_SOCIAL_NETWORKS = [
|
||||
{key: 'facebook', name: 'Facebook'},
|
||||
{key: 'google', name: 'Google'},
|
||||
{ key: 'facebook', name: 'Facebook' },
|
||||
{ key: 'google', name: 'Google' },
|
||||
];
|
||||
|
||||
export const GUILDS_PER_PAGE = 30; // number of guilds to return per page when using pagination
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import each from 'lodash/each';
|
||||
|
||||
let achievementsData = {};
|
||||
const achievementsData = {};
|
||||
|
||||
let worldQuestAchievs = {
|
||||
const worldQuestAchievs = {
|
||||
dilatoryQuest: {
|
||||
icon: 'achievement-dilatory',
|
||||
titleKey: 'achievementDilatory',
|
||||
@@ -31,7 +31,7 @@ let worldQuestAchievs = {
|
||||
};
|
||||
Object.assign(achievementsData, worldQuestAchievs);
|
||||
|
||||
let seasonalSpellAchievs = {
|
||||
const seasonalSpellAchievs = {
|
||||
snowball: {
|
||||
icon: 'achievement-snowball',
|
||||
titleKey: 'annoyingFriends',
|
||||
@@ -55,7 +55,7 @@ let seasonalSpellAchievs = {
|
||||
};
|
||||
Object.assign(achievementsData, seasonalSpellAchievs);
|
||||
|
||||
let masterAchievs = {
|
||||
const masterAchievs = {
|
||||
beastMaster: {
|
||||
icon: 'achievement-rat',
|
||||
titleKey: 'beastMasterName',
|
||||
@@ -77,7 +77,7 @@ let masterAchievs = {
|
||||
};
|
||||
Object.assign(achievementsData, masterAchievs);
|
||||
|
||||
let basicAchievs = {
|
||||
const basicAchievs = {
|
||||
partyUp: {
|
||||
icon: 'achievement-partyUp',
|
||||
titleKey: 'partyUpName',
|
||||
@@ -160,7 +160,7 @@ let basicAchievs = {
|
||||
};
|
||||
Object.assign(achievementsData, basicAchievs);
|
||||
|
||||
let specialAchievs = {
|
||||
const specialAchievs = {
|
||||
contributor: {
|
||||
icon: 'achievement-boot',
|
||||
titleKey: 'contribName',
|
||||
@@ -201,7 +201,7 @@ let specialAchievs = {
|
||||
};
|
||||
Object.assign(achievementsData, specialAchievs);
|
||||
|
||||
let holidayAchievs = {
|
||||
const holidayAchievs = {
|
||||
habiticaDays: {
|
||||
icon: 'achievement-habiticaDay',
|
||||
singularTitleKey: 'habiticaDay',
|
||||
@@ -226,7 +226,7 @@ let holidayAchievs = {
|
||||
};
|
||||
Object.assign(achievementsData, holidayAchievs);
|
||||
|
||||
let ultimateGearAchievs = ['healer', 'rogue', 'warrior', 'mage'].reduce((achievs, type) => {
|
||||
const ultimateGearAchievs = ['healer', 'rogue', 'warrior', 'mage'].reduce((achievs, type) => {
|
||||
achievs[`${type}UltimateGear`] = {
|
||||
icon: `achievement-ultimate-${type}`,
|
||||
titleKey: 'ultimGearName',
|
||||
@@ -236,7 +236,7 @@ let ultimateGearAchievs = ['healer', 'rogue', 'warrior', 'mage'].reduce((achievs
|
||||
}, {});
|
||||
Object.assign(achievementsData, ultimateGearAchievs);
|
||||
|
||||
let cardAchievs = ['greeting', 'thankyou', 'nye', 'valentine', 'birthday', 'congrats', 'getwell', 'goodluck'].reduce((achievs, type) => {
|
||||
const cardAchievs = ['greeting', 'thankyou', 'nye', 'valentine', 'birthday', 'congrats', 'getwell', 'goodluck'].reduce((achievs, type) => {
|
||||
achievs[`${type}Cards`] = {
|
||||
icon: `achievement-${type}`,
|
||||
titleKey: `${type}CardAchievementTitle`,
|
||||
|
||||
@@ -2,7 +2,7 @@ import forOwn from 'lodash/forOwn';
|
||||
import t from '../translation';
|
||||
|
||||
/* eslint-disable camelcase */
|
||||
let backgrounds = {
|
||||
const backgrounds = {
|
||||
backgrounds062014: {
|
||||
beach: {
|
||||
text: t('backgroundBeachText'),
|
||||
@@ -948,10 +948,10 @@ let backgrounds = {
|
||||
};
|
||||
/* eslint-enable quote-props */
|
||||
|
||||
let flat = {};
|
||||
const flat = {};
|
||||
|
||||
forOwn(backgrounds, function prefillBackgroundSet (backgroundsInSet, set) {
|
||||
forOwn(backgroundsInSet, function prefillBackground (background, bgKey) {
|
||||
forOwn(backgrounds, (backgroundsInSet, set) => {
|
||||
forOwn(backgroundsInSet, (background, bgKey) => {
|
||||
background.key = bgKey;
|
||||
background.set = set;
|
||||
background.price = 7;
|
||||
|
||||
@@ -4,23 +4,23 @@ import sets from '../sets.js';
|
||||
export default prefill({
|
||||
0: {},
|
||||
1: {},
|
||||
2: {price: 2, set: sets.baseHair1},
|
||||
2: { price: 2, set: sets.baseHair1 },
|
||||
3: {},
|
||||
4: {price: 2, set: sets.baseHair1},
|
||||
5: {price: 2, set: sets.baseHair1},
|
||||
6: {price: 2, set: sets.baseHair1},
|
||||
7: {price: 2, set: sets.baseHair1},
|
||||
8: {price: 2, set: sets.baseHair1},
|
||||
9: {price: 2, set: sets.baseHair2},
|
||||
10: {price: 2, set: sets.baseHair2},
|
||||
11: {price: 2, set: sets.baseHair2},
|
||||
12: {price: 2, set: sets.baseHair2},
|
||||
13: {price: 2, set: sets.baseHair2},
|
||||
14: {price: 2, set: sets.baseHair2},
|
||||
15: {price: 2, set: sets.baseHair3},
|
||||
16: {price: 2, set: sets.baseHair3},
|
||||
17: {price: 2, set: sets.baseHair3},
|
||||
18: {price: 2, set: sets.baseHair3},
|
||||
19: {price: 2, set: sets.baseHair3},
|
||||
20: {price: 2, set: sets.baseHair3},
|
||||
4: { price: 2, set: sets.baseHair1 },
|
||||
5: { price: 2, set: sets.baseHair1 },
|
||||
6: { price: 2, set: sets.baseHair1 },
|
||||
7: { price: 2, set: sets.baseHair1 },
|
||||
8: { price: 2, set: sets.baseHair1 },
|
||||
9: { price: 2, set: sets.baseHair2 },
|
||||
10: { price: 2, set: sets.baseHair2 },
|
||||
11: { price: 2, set: sets.baseHair2 },
|
||||
12: { price: 2, set: sets.baseHair2 },
|
||||
13: { price: 2, set: sets.baseHair2 },
|
||||
14: { price: 2, set: sets.baseHair2 },
|
||||
15: { price: 2, set: sets.baseHair3 },
|
||||
16: { price: 2, set: sets.baseHair3 },
|
||||
17: { price: 2, set: sets.baseHair3 },
|
||||
18: { price: 2, set: sets.baseHair3 },
|
||||
19: { price: 2, set: sets.baseHair3 },
|
||||
20: { price: 2, set: sets.baseHair3 },
|
||||
});
|
||||
|
||||
@@ -3,7 +3,7 @@ import prefill from '../prefill.js';
|
||||
|
||||
export default prefill({
|
||||
0: {},
|
||||
1: {price: 2, set: sets.facialHair},
|
||||
2: {price: 2, set: sets.facialHair},
|
||||
3: {price: 2, set: sets.facialHair},
|
||||
1: { price: 2, set: sets.facialHair },
|
||||
2: { price: 2, set: sets.facialHair },
|
||||
3: { price: 2, set: sets.facialHair },
|
||||
});
|
||||
|
||||
@@ -8,43 +8,43 @@ export default prefill({
|
||||
red: {},
|
||||
black: {},
|
||||
|
||||
candycane: {price: 2, set: sets.winterHairColors},
|
||||
frost: {price: 2, set: sets.winterHairColors},
|
||||
winternight: {price: 2, set: sets.winterHairColors},
|
||||
holly: {price: 2, set: sets.winterHairColors},
|
||||
candycane: { price: 2, set: sets.winterHairColors },
|
||||
frost: { price: 2, set: sets.winterHairColors },
|
||||
winternight: { price: 2, set: sets.winterHairColors },
|
||||
holly: { price: 2, set: sets.winterHairColors },
|
||||
|
||||
pblue: {price: 2, set: sets.pastelHairColors},
|
||||
pgreen: {price: 2, set: sets.pastelHairColors},
|
||||
porange: {price: 2, set: sets.pastelHairColors},
|
||||
ppink: {price: 2, set: sets.pastelHairColors},
|
||||
ppurple: {price: 2, set: sets.pastelHairColors},
|
||||
pyellow: {price: 2, set: sets.pastelHairColors},
|
||||
pblue: { price: 2, set: sets.pastelHairColors },
|
||||
pgreen: { price: 2, set: sets.pastelHairColors },
|
||||
porange: { price: 2, set: sets.pastelHairColors },
|
||||
ppink: { price: 2, set: sets.pastelHairColors },
|
||||
ppurple: { price: 2, set: sets.pastelHairColors },
|
||||
pyellow: { price: 2, set: sets.pastelHairColors },
|
||||
|
||||
rainbow: {price: 2, set: sets.rainbowHairColors},
|
||||
yellow: {price: 2, set: sets.rainbowHairColors},
|
||||
green: {price: 2, set: sets.rainbowHairColors},
|
||||
purple: {price: 2, set: sets.rainbowHairColors},
|
||||
blue: {price: 2, set: sets.rainbowHairColors},
|
||||
TRUred: {price: 2, set: sets.rainbowHairColors},
|
||||
rainbow: { price: 2, set: sets.rainbowHairColors },
|
||||
yellow: { price: 2, set: sets.rainbowHairColors },
|
||||
green: { price: 2, set: sets.rainbowHairColors },
|
||||
purple: { price: 2, set: sets.rainbowHairColors },
|
||||
blue: { price: 2, set: sets.rainbowHairColors },
|
||||
TRUred: { price: 2, set: sets.rainbowHairColors },
|
||||
|
||||
pblue2: {price: 2, set: sets.shimmerHairColors},
|
||||
pgreen2: {price: 2, set: sets.shimmerHairColors},
|
||||
porange2: {price: 2, set: sets.shimmerHairColors},
|
||||
ppink2: {price: 2, set: sets.shimmerHairColors},
|
||||
ppurple2: {price: 2, set: sets.shimmerHairColors},
|
||||
pyellow2: {price: 2, set: sets.shimmerHairColors},
|
||||
pblue2: { price: 2, set: sets.shimmerHairColors },
|
||||
pgreen2: { price: 2, set: sets.shimmerHairColors },
|
||||
porange2: { price: 2, set: sets.shimmerHairColors },
|
||||
ppink2: { price: 2, set: sets.shimmerHairColors },
|
||||
ppurple2: { price: 2, set: sets.shimmerHairColors },
|
||||
pyellow2: { price: 2, set: sets.shimmerHairColors },
|
||||
|
||||
candycorn: {price: 2, set: sets.hauntedHairColors},
|
||||
ghostwhite: {price: 2, set: sets.hauntedHairColors},
|
||||
halloween: {price: 2, set: sets.hauntedHairColors},
|
||||
midnight: {price: 2, set: sets.hauntedHairColors},
|
||||
pumpkin: {price: 2, set: sets.hauntedHairColors},
|
||||
zombie: {price: 2, set: sets.hauntedHairColors},
|
||||
candycorn: { price: 2, set: sets.hauntedHairColors },
|
||||
ghostwhite: { price: 2, set: sets.hauntedHairColors },
|
||||
halloween: { price: 2, set: sets.hauntedHairColors },
|
||||
midnight: { price: 2, set: sets.hauntedHairColors },
|
||||
pumpkin: { price: 2, set: sets.hauntedHairColors },
|
||||
zombie: { price: 2, set: sets.hauntedHairColors },
|
||||
|
||||
aurora: {price: 2, set: sets.winteryHairColors},
|
||||
festive: {price: 2, set: sets.winteryHairColors},
|
||||
hollygreen: {price: 2, set: sets.winteryHairColors},
|
||||
peppermint: {price: 2, set: sets.winteryHairColors},
|
||||
snowy: {price: 2, set: sets.winteryHairColors},
|
||||
winterstar: {price: 2, set: sets.winteryHairColors},
|
||||
aurora: { price: 2, set: sets.winteryHairColors },
|
||||
festive: { price: 2, set: sets.winteryHairColors },
|
||||
hollygreen: { price: 2, set: sets.winteryHairColors },
|
||||
peppermint: { price: 2, set: sets.winteryHairColors },
|
||||
snowy: { price: 2, set: sets.winteryHairColors },
|
||||
winterstar: { price: 2, set: sets.winteryHairColors },
|
||||
});
|
||||
|
||||
@@ -3,6 +3,6 @@ import prefill from '../prefill.js';
|
||||
|
||||
export default prefill({
|
||||
0: {},
|
||||
1: {price: 2, set: sets.facialHair},
|
||||
2: {price: 2, set: sets.facialHair},
|
||||
1: { price: 2, set: sets.facialHair },
|
||||
2: { price: 2, set: sets.facialHair },
|
||||
});
|
||||
|
||||
@@ -3,10 +3,10 @@ import sets from '../sets.js';
|
||||
|
||||
export default prefill({
|
||||
0: {},
|
||||
1: {price: 2, set: sets.topHair},
|
||||
2: {price: 2, set: sets.topHair},
|
||||
3: {price: 2, set: sets.topHair},
|
||||
4: {price: 2, set: sets.topHair},
|
||||
5: {price: 2, set: sets.topHair},
|
||||
6: {price: 2, set: sets.topHair},
|
||||
1: { price: 2, set: sets.topHair },
|
||||
2: { price: 2, set: sets.topHair },
|
||||
3: { price: 2, set: sets.topHair },
|
||||
4: { price: 2, set: sets.topHair },
|
||||
5: { price: 2, set: sets.topHair },
|
||||
6: { price: 2, set: sets.topHair },
|
||||
});
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
import forOwn from 'lodash/forOwn';
|
||||
import clone from 'lodash/clone';
|
||||
import hair from './hair';
|
||||
import shirts from './shirt.js';
|
||||
import skins from './skin.js';
|
||||
import sizes from './size.js';
|
||||
import backgrounds from './backgrounds.js';
|
||||
import chairs from './chair.js';
|
||||
import forOwn from 'lodash/forOwn';
|
||||
import clone from 'lodash/clone';
|
||||
|
||||
let reorderedBgs = {};
|
||||
const reorderedBgs = {};
|
||||
|
||||
forOwn(backgrounds, function restructureBackgroundSet (value, key) {
|
||||
forOwn(value, function restructureBackground (bgObject, bgKey) {
|
||||
let bg = clone(bgObject);
|
||||
forOwn(backgrounds, (value, key) => {
|
||||
forOwn(value, (bgObject, bgKey) => {
|
||||
const bg = clone(bgObject);
|
||||
bg.set = {
|
||||
text: key,
|
||||
key,
|
||||
@@ -22,7 +22,7 @@ forOwn(backgrounds, function restructureBackgroundSet (value, key) {
|
||||
});
|
||||
|
||||
|
||||
let appearances = {
|
||||
const appearances = {
|
||||
hair,
|
||||
shirt: shirts,
|
||||
size: sizes,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import forOwn from 'lodash/forOwn';
|
||||
|
||||
export default function prefillAppearances (obj) {
|
||||
forOwn(obj, function prefillAppearance (value, key) {
|
||||
forOwn(obj, (value, key) => {
|
||||
value.key = key;
|
||||
if (!value.price) {
|
||||
value.price = 0;
|
||||
|
||||
@@ -2,22 +2,36 @@ import t from '../translation';
|
||||
import prefill from './prefill.js';
|
||||
|
||||
export default prefill({
|
||||
baseHair1: {setPrice: 5, text: t('hairSet1')},
|
||||
baseHair2: {setPrice: 5, text: t('hairSet2')},
|
||||
baseHair3: {setPrice: 5, text: t('hairSet3')},
|
||||
facialHair: {setPrice: 5, text: t('bodyFacialHair')},
|
||||
specialShirts: {setPrice: 5, text: t('specialShirts')},
|
||||
winterHairColors: {setPrice: 5, availableUntil: '2016-01-01'},
|
||||
pastelHairColors: {setPrice: 5, availableUntil: '2016-01-01'},
|
||||
rainbowHairColors: {setPrice: 5, text: t('rainbowColors')},
|
||||
shimmerHairColors: {setPrice: 5, availableFrom: '2019-04-09', availableUntil: '2019-05-02', text: t('shimmerColors')},
|
||||
hauntedHairColors: {setPrice: 5, availableFrom: '2018-10-11', availableUntil: '2018-11-02', text: t('hauntedColors')},
|
||||
winteryHairColors: {setPrice: 5, availableFrom: '2019-01-08', availableUntil: '2019-02-02', text: t('winteryColors')},
|
||||
rainbowSkins: {setPrice: 5, text: t('rainbowSkins')},
|
||||
animalSkins: {setPrice: 5, text: t('animalSkins')},
|
||||
pastelSkins: {setPrice: 5, availableFrom: '2019-04-09', availableUntil: '2019-05-02', text: t('pastelSkins')},
|
||||
spookySkins: {setPrice: 5, availableUntil: '2016-01-01', text: t('spookySkins')},
|
||||
supernaturalSkins: {setPrice: 5, availableFrom: '2018-10-11', availableUntil: '2018-11-02', text: t('supernaturalSkins')},
|
||||
splashySkins: {setPrice: 5, availableFrom: '2019-07-02', availableUntil: '2019-08-02', text: t('splashySkins')},
|
||||
winterySkins: {setPrice: 5, availableFrom: '2019-01-08', availableUntil: '2019-02-02', text: t('winterySkins')},
|
||||
baseHair1: { setPrice: 5, text: t('hairSet1') },
|
||||
baseHair2: { setPrice: 5, text: t('hairSet2') },
|
||||
baseHair3: { setPrice: 5, text: t('hairSet3') },
|
||||
facialHair: { setPrice: 5, text: t('bodyFacialHair') },
|
||||
specialShirts: { setPrice: 5, text: t('specialShirts') },
|
||||
winterHairColors: { setPrice: 5, availableUntil: '2016-01-01' },
|
||||
pastelHairColors: { setPrice: 5, availableUntil: '2016-01-01' },
|
||||
rainbowHairColors: { setPrice: 5, text: t('rainbowColors') },
|
||||
shimmerHairColors: {
|
||||
setPrice: 5, availableFrom: '2019-04-09', availableUntil: '2019-05-02', text: t('shimmerColors'),
|
||||
},
|
||||
hauntedHairColors: {
|
||||
setPrice: 5, availableFrom: '2018-10-11', availableUntil: '2018-11-02', text: t('hauntedColors'),
|
||||
},
|
||||
winteryHairColors: {
|
||||
setPrice: 5, availableFrom: '2019-01-08', availableUntil: '2019-02-02', text: t('winteryColors'),
|
||||
},
|
||||
rainbowSkins: { setPrice: 5, text: t('rainbowSkins') },
|
||||
animalSkins: { setPrice: 5, text: t('animalSkins') },
|
||||
pastelSkins: {
|
||||
setPrice: 5, availableFrom: '2019-04-09', availableUntil: '2019-05-02', text: t('pastelSkins'),
|
||||
},
|
||||
spookySkins: { setPrice: 5, availableUntil: '2016-01-01', text: t('spookySkins') },
|
||||
supernaturalSkins: {
|
||||
setPrice: 5, availableFrom: '2018-10-11', availableUntil: '2018-11-02', text: t('supernaturalSkins'),
|
||||
},
|
||||
splashySkins: {
|
||||
setPrice: 5, availableFrom: '2019-07-02', availableUntil: '2019-08-02', text: t('splashySkins'),
|
||||
},
|
||||
winterySkins: {
|
||||
setPrice: 5, availableFrom: '2019-01-08', availableUntil: '2019-02-02', text: t('winterySkins'),
|
||||
},
|
||||
});
|
||||
|
||||
@@ -9,15 +9,15 @@ export default prefill({
|
||||
white: {},
|
||||
yellow: {},
|
||||
|
||||
convict: {price: 2, set: sets.specialShirts},
|
||||
cross: {price: 2, set: sets.specialShirts},
|
||||
fire: {price: 2, set: sets.specialShirts},
|
||||
horizon: {price: 2, set: sets.specialShirts},
|
||||
ocean: {price: 2, set: sets.specialShirts},
|
||||
purple: {price: 2, set: sets.specialShirts},
|
||||
rainbow: {price: 2, set: sets.specialShirts},
|
||||
redblue: {price: 2, set: sets.specialShirts},
|
||||
thunder: {price: 2, set: sets.specialShirts},
|
||||
tropical: {price: 2, set: sets.specialShirts},
|
||||
zombie: {price: 2, set: sets.specialShirts},
|
||||
convict: { price: 2, set: sets.specialShirts },
|
||||
cross: { price: 2, set: sets.specialShirts },
|
||||
fire: { price: 2, set: sets.specialShirts },
|
||||
horizon: { price: 2, set: sets.specialShirts },
|
||||
ocean: { price: 2, set: sets.specialShirts },
|
||||
purple: { price: 2, set: sets.specialShirts },
|
||||
rainbow: { price: 2, set: sets.specialShirts },
|
||||
redblue: { price: 2, set: sets.specialShirts },
|
||||
thunder: { price: 2, set: sets.specialShirts },
|
||||
tropical: { price: 2, set: sets.specialShirts },
|
||||
zombie: { price: 2, set: sets.specialShirts },
|
||||
});
|
||||
|
||||
@@ -12,66 +12,66 @@ export default prefill({
|
||||
'c3e1dc': {},
|
||||
'6bd049': {},
|
||||
|
||||
'eb052b': {price: 2, set: sets.rainbowSkins},
|
||||
'f69922': {price: 2, set: sets.rainbowSkins},
|
||||
'f5d70f': {price: 2, set: sets.rainbowSkins},
|
||||
'0ff591': {price: 2, set: sets.rainbowSkins},
|
||||
'2b43f6': {price: 2, set: sets.rainbowSkins},
|
||||
'd7a9f7': {price: 2, set: sets.rainbowSkins},
|
||||
'800ed0': {price: 2, set: sets.rainbowSkins},
|
||||
'rainbow': {price: 2, set: sets.rainbowSkins},
|
||||
'eb052b': { price: 2, set: sets.rainbowSkins },
|
||||
'f69922': { price: 2, set: sets.rainbowSkins },
|
||||
'f5d70f': { price: 2, set: sets.rainbowSkins },
|
||||
'0ff591': { price: 2, set: sets.rainbowSkins },
|
||||
'2b43f6': { price: 2, set: sets.rainbowSkins },
|
||||
'd7a9f7': { price: 2, set: sets.rainbowSkins },
|
||||
'800ed0': { price: 2, set: sets.rainbowSkins },
|
||||
'rainbow': { price: 2, set: sets.rainbowSkins },
|
||||
|
||||
'bear': {price: 2, set: sets.animalSkins},
|
||||
'cactus': {price: 2, set: sets.animalSkins},
|
||||
'fox': {price: 2, set: sets.animalSkins},
|
||||
'lion': {price: 2, set: sets.animalSkins},
|
||||
'panda': {price: 2, set: sets.animalSkins},
|
||||
'pig': {price: 2, set: sets.animalSkins},
|
||||
'tiger': {price: 2, set: sets.animalSkins},
|
||||
'wolf': {price: 2, set: sets.animalSkins},
|
||||
'bear': { price: 2, set: sets.animalSkins },
|
||||
'cactus': { price: 2, set: sets.animalSkins },
|
||||
'fox': { price: 2, set: sets.animalSkins },
|
||||
'lion': { price: 2, set: sets.animalSkins },
|
||||
'panda': { price: 2, set: sets.animalSkins },
|
||||
'pig': { price: 2, set: sets.animalSkins },
|
||||
'tiger': { price: 2, set: sets.animalSkins },
|
||||
'wolf': { price: 2, set: sets.animalSkins },
|
||||
|
||||
'pastelPink': {price: 2, set: sets.pastelSkins},
|
||||
'pastelOrange': {price: 2, set: sets.pastelSkins},
|
||||
'pastelYellow': {price: 2, set: sets.pastelSkins},
|
||||
'pastelGreen': {price: 2, set: sets.pastelSkins},
|
||||
'pastelBlue': {price: 2, set: sets.pastelSkins},
|
||||
'pastelPurple': {price: 2, set: sets.pastelSkins},
|
||||
'pastelRainbowChevron': {price: 2, set: sets.pastelSkins},
|
||||
'pastelRainbowDiagonal': {price: 2, set: sets.pastelSkins},
|
||||
'pastelPink': { price: 2, set: sets.pastelSkins },
|
||||
'pastelOrange': { price: 2, set: sets.pastelSkins },
|
||||
'pastelYellow': { price: 2, set: sets.pastelSkins },
|
||||
'pastelGreen': { price: 2, set: sets.pastelSkins },
|
||||
'pastelBlue': { price: 2, set: sets.pastelSkins },
|
||||
'pastelPurple': { price: 2, set: sets.pastelSkins },
|
||||
'pastelRainbowChevron': { price: 2, set: sets.pastelSkins },
|
||||
'pastelRainbowDiagonal': { price: 2, set: sets.pastelSkins },
|
||||
|
||||
'monster': {price: 2, set: sets.spookySkins},
|
||||
'pumpkin': {price: 2, set: sets.spookySkins},
|
||||
'skeleton': {price: 2, set: sets.spookySkins},
|
||||
'zombie': {price: 2, set: sets.spookySkins},
|
||||
'ghost': {price: 2, set: sets.spookySkins},
|
||||
'shadow': {price: 2, set: sets.spookySkins},
|
||||
'monster': { price: 2, set: sets.spookySkins },
|
||||
'pumpkin': { price: 2, set: sets.spookySkins },
|
||||
'skeleton': { price: 2, set: sets.spookySkins },
|
||||
'zombie': { price: 2, set: sets.spookySkins },
|
||||
'ghost': { price: 2, set: sets.spookySkins },
|
||||
'shadow': { price: 2, set: sets.spookySkins },
|
||||
|
||||
'candycorn': {price: 2, set: sets.supernaturalSkins},
|
||||
'ogre': {price: 2, set: sets.supernaturalSkins},
|
||||
'pumpkin2': {price: 2, set: sets.supernaturalSkins},
|
||||
'reptile': {price: 2, set: sets.supernaturalSkins},
|
||||
'shadow2': {price: 2, set: sets.supernaturalSkins},
|
||||
'skeleton2': {price: 2, set: sets.supernaturalSkins},
|
||||
'transparent': {price: 2, set: sets.supernaturalSkins},
|
||||
'zombie2': {price: 2, set: sets.supernaturalSkins},
|
||||
'candycorn': { price: 2, set: sets.supernaturalSkins },
|
||||
'ogre': { price: 2, set: sets.supernaturalSkins },
|
||||
'pumpkin2': { price: 2, set: sets.supernaturalSkins },
|
||||
'reptile': { price: 2, set: sets.supernaturalSkins },
|
||||
'shadow2': { price: 2, set: sets.supernaturalSkins },
|
||||
'skeleton2': { price: 2, set: sets.supernaturalSkins },
|
||||
'transparent': { price: 2, set: sets.supernaturalSkins },
|
||||
'zombie2': { price: 2, set: sets.supernaturalSkins },
|
||||
|
||||
'clownfish': {price: 2, set: sets.splashySkins},
|
||||
'deepocean': {price: 2, set: sets.splashySkins},
|
||||
'merblue': {price: 2, set: sets.splashySkins},
|
||||
'mergold': {price: 2, set: sets.splashySkins},
|
||||
'mergreen': {price: 2, set: sets.splashySkins},
|
||||
'merruby': {price: 2, set: sets.splashySkins},
|
||||
'shark': {price: 2, set: sets.splashySkins},
|
||||
'tropicalwater': {price: 2, set: sets.splashySkins},
|
||||
'clownfish': { price: 2, set: sets.splashySkins },
|
||||
'deepocean': { price: 2, set: sets.splashySkins },
|
||||
'merblue': { price: 2, set: sets.splashySkins },
|
||||
'mergold': { price: 2, set: sets.splashySkins },
|
||||
'mergreen': { price: 2, set: sets.splashySkins },
|
||||
'merruby': { price: 2, set: sets.splashySkins },
|
||||
'shark': { price: 2, set: sets.splashySkins },
|
||||
'tropicalwater': { price: 2, set: sets.splashySkins },
|
||||
|
||||
'aurora': {price: 2, set: sets.winterySkins},
|
||||
'dapper': {price: 2, set: sets.winterySkins},
|
||||
'festive': {price: 2, set: sets.winterySkins},
|
||||
'holly': {price: 2, set: sets.winterySkins},
|
||||
'polar': {price: 2, set: sets.winterySkins},
|
||||
'sugar': {price: 2, set: sets.winterySkins},
|
||||
'snowy': {price: 2, set: sets.winterySkins},
|
||||
'winterstar': {price: 2, set: sets.winterySkins},
|
||||
'aurora': { price: 2, set: sets.winterySkins },
|
||||
'dapper': { price: 2, set: sets.winterySkins },
|
||||
'festive': { price: 2, set: sets.winterySkins },
|
||||
'holly': { price: 2, set: sets.winterySkins },
|
||||
'polar': { price: 2, set: sets.winterySkins },
|
||||
'sugar': { price: 2, set: sets.winterySkins },
|
||||
'snowy': { price: 2, set: sets.winterySkins },
|
||||
'winterstar': { price: 2, set: sets.winterySkins },
|
||||
|
||||
/* eslint-enable quote-props */
|
||||
});
|
||||
|
||||
@@ -203,19 +203,19 @@ export const GEAR_TYPES = [
|
||||
];
|
||||
|
||||
export const ITEM_LIST = {
|
||||
weapon: { localeKey: 'weapon', isEquipment: true },
|
||||
armor: { localeKey: 'armor', isEquipment: true },
|
||||
head: { localeKey: 'headgear', isEquipment: true },
|
||||
shield: { localeKey: 'offhand', isEquipment: true },
|
||||
back: { localeKey: 'back', isEquipment: true },
|
||||
body: { localeKey: 'body', isEquipment: true },
|
||||
headAccessory: { localeKey: 'headAccessory', isEquipment: true },
|
||||
eyewear: { localeKey: 'eyewear', isEquipment: true },
|
||||
weapon: { localeKey: 'weapon', isEquipment: true },
|
||||
armor: { localeKey: 'armor', isEquipment: true },
|
||||
head: { localeKey: 'headgear', isEquipment: true },
|
||||
shield: { localeKey: 'offhand', isEquipment: true },
|
||||
back: { localeKey: 'back', isEquipment: true },
|
||||
body: { localeKey: 'body', isEquipment: true },
|
||||
headAccessory: { localeKey: 'headAccessory', isEquipment: true },
|
||||
eyewear: { localeKey: 'eyewear', isEquipment: true },
|
||||
hatchingPotions: { localeKey: 'hatchingPotion', isEquipment: false },
|
||||
premiumHatchingPotions: { localeKey: 'hatchingPotion', isEquipment: false },
|
||||
eggs: { localeKey: 'eggSingular', isEquipment: false },
|
||||
quests: { localeKey: 'quest', isEquipment: false },
|
||||
food: { localeKey: 'foodTextThe', isEquipment: false },
|
||||
eggs: { localeKey: 'eggSingular', isEquipment: false },
|
||||
quests: { localeKey: 'quest', isEquipment: false },
|
||||
food: { localeKey: 'foodTextThe', isEquipment: false },
|
||||
Saddle: { localeKey: 'foodSaddleText', isEquipment: false },
|
||||
bundles: { localeKey: 'discountBundle', isEquipment: false },
|
||||
};
|
||||
@@ -264,6 +264,10 @@ export const QUEST_SERIES_ACHIEVEMENTS = {
|
||||
};
|
||||
|
||||
export const ANIMAL_COLOR_ACHIEVEMENTS = [
|
||||
{color: 'Base', petAchievement: 'backToBasics', petNotificationType: 'ACHIEVEMENT_BACK_TO_BASICS', mountAchievement: 'allYourBase', mountNotificationType: 'ACHIEVEMENT_ALL_YOUR_BASE'},
|
||||
{color: 'Desert', petAchievement: 'dustDevil', petNotificationType: 'ACHIEVEMENT_DUST_DEVIL', mountAchievement: 'aridAuthority', mountNotificationType: 'ACHIEVEMENT_ARID_AUTHORITY'},
|
||||
{
|
||||
color: 'Base', petAchievement: 'backToBasics', petNotificationType: 'ACHIEVEMENT_BACK_TO_BASICS', mountAchievement: 'allYourBase', mountNotificationType: 'ACHIEVEMENT_ALL_YOUR_BASE',
|
||||
},
|
||||
{
|
||||
color: 'Desert', petAchievement: 'dustDevil', petNotificationType: 'ACHIEVEMENT_DUST_DEVIL', mountAchievement: 'aridAuthority', mountNotificationType: 'ACHIEVEMENT_ARID_AUTHORITY',
|
||||
},
|
||||
];
|
||||
|
||||
@@ -19,13 +19,11 @@ function applyEggDefaults (set, config) {
|
||||
}
|
||||
|
||||
function hasQuestAchievementFunction (key) {
|
||||
return (user) => {
|
||||
return user.achievements.quests &&
|
||||
user.achievements.quests[key] > 0;
|
||||
};
|
||||
return user => user.achievements.quests
|
||||
&& user.achievements.quests[key] > 0;
|
||||
}
|
||||
|
||||
let drops = {
|
||||
const drops = {
|
||||
Wolf: {
|
||||
text: t('dropEggWolfText'),
|
||||
mountText: t('dropEggWolfMountText'),
|
||||
@@ -73,7 +71,7 @@ let drops = {
|
||||
},
|
||||
};
|
||||
|
||||
let quests = {
|
||||
const quests = {
|
||||
Gryphon: {
|
||||
text: t('questEggGryphonText'),
|
||||
mountText: t('questEggGryphonMountText'),
|
||||
@@ -150,11 +148,11 @@ let quests = {
|
||||
mountText: t('questEggTRexMountText'),
|
||||
adjective: t('questEggTRexAdjective'),
|
||||
canBuy (user) {
|
||||
let questAchievements = user.achievements.quests;
|
||||
const questAchievements = user.achievements.quests;
|
||||
|
||||
return questAchievements && (
|
||||
questAchievements.trex > 0 ||
|
||||
questAchievements.trex_undead > 0
|
||||
questAchievements.trex > 0
|
||||
|| questAchievements.trex_undead > 0
|
||||
);
|
||||
},
|
||||
},
|
||||
@@ -406,7 +404,7 @@ applyEggDefaults(quests, {
|
||||
},
|
||||
});
|
||||
|
||||
let all = assign({}, drops, quests);
|
||||
const all = assign({}, drops, quests);
|
||||
|
||||
export {
|
||||
drops,
|
||||
|
||||
@@ -2,7 +2,7 @@ import t from './translation';
|
||||
|
||||
const NUMBER_OF_QUESTIONS = 12;
|
||||
|
||||
let faq = {
|
||||
const faq = {
|
||||
questions: [],
|
||||
stillNeedHelp: {
|
||||
ios: t('iosFaqStillNeedHelp'),
|
||||
@@ -11,7 +11,7 @@ let faq = {
|
||||
};
|
||||
|
||||
for (let i = 0; i <= NUMBER_OF_QUESTIONS; i++) {
|
||||
let question = {
|
||||
const question = {
|
||||
question: t(`faqQuestion${i}`),
|
||||
ios: t(`iosFaqAnswer${i}`),
|
||||
android: t(`androidFaqAnswer${i}`),
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
import {armor as baseArmor} from './sets/base';
|
||||
import { armor as baseArmor } from './sets/base';
|
||||
|
||||
import {armor as warriorArmor} from './sets/warrior';
|
||||
import {armor as rogueArmor} from './sets/rogue';
|
||||
import {armor as healerArmor} from './sets/healer';
|
||||
import {armor as wizardArmor} from './sets/wizard';
|
||||
import { armor as warriorArmor } from './sets/warrior';
|
||||
import { armor as rogueArmor } from './sets/rogue';
|
||||
import { armor as healerArmor } from './sets/healer';
|
||||
import { armor as wizardArmor } from './sets/wizard';
|
||||
|
||||
import {armor as specialArmor} from './sets/special';
|
||||
import {armor as mysteryArmor} from './sets/mystery';
|
||||
import {armor as armoireArmor} from './sets/armoire';
|
||||
import { armor as specialArmor } from './sets/special';
|
||||
import { armor as mysteryArmor } from './sets/mystery';
|
||||
import { armor as armoireArmor } from './sets/armoire';
|
||||
|
||||
let armor = {
|
||||
const armor = {
|
||||
base: baseArmor,
|
||||
|
||||
warrior: warriorArmor,
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
import {back as baseBack} from './sets/base';
|
||||
import { back as baseBack } from './sets/base';
|
||||
|
||||
import {back as mysteryBack} from './sets/mystery';
|
||||
import {back as specialBack} from './sets/special';
|
||||
import { back as mysteryBack } from './sets/mystery';
|
||||
import { back as specialBack } from './sets/special';
|
||||
|
||||
let back = {
|
||||
const back = {
|
||||
base: baseBack,
|
||||
mystery: mysteryBack,
|
||||
special: specialBack,
|
||||
};
|
||||
|
||||
export default back;
|
||||
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import {body as baseBody} from './sets/base';
|
||||
import { body as baseBody } from './sets/base';
|
||||
|
||||
import {body as mysteryBody} from './sets/mystery';
|
||||
import {body as specialBody} from './sets/special';
|
||||
import {body as armoireBody} from './sets/armoire';
|
||||
import { body as mysteryBody } from './sets/mystery';
|
||||
import { body as specialBody } from './sets/special';
|
||||
import { body as armoireBody } from './sets/armoire';
|
||||
|
||||
let body = {
|
||||
const body = {
|
||||
base: baseBody,
|
||||
mystery: mysteryBody,
|
||||
special: specialBody,
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import {eyewear as baseEyewear} from './sets/base';
|
||||
import { eyewear as baseEyewear } from './sets/base';
|
||||
|
||||
import {eyewear as armoireEyewear} from './sets/armoire';
|
||||
import {eyewear as mysteryEyewear} from './sets/mystery';
|
||||
import {eyewear as specialEyewear} from './sets/special';
|
||||
import { eyewear as armoireEyewear } from './sets/armoire';
|
||||
import { eyewear as mysteryEyewear } from './sets/mystery';
|
||||
import { eyewear as specialEyewear } from './sets/special';
|
||||
|
||||
let eyewear = {
|
||||
const eyewear = {
|
||||
base: baseEyewear,
|
||||
special: specialEyewear,
|
||||
mystery: mysteryEyewear,
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
import isBoolean from 'lodash/isBoolean';
|
||||
|
||||
export function ownsItem (item) {
|
||||
return (user) => {
|
||||
return item && isBoolean(user.items.gear.owned[item]);
|
||||
};
|
||||
return user => item && isBoolean(user.items.gear.owned[item]);
|
||||
}
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import {headAccessory as baseHeadAccessory} from './sets/base';
|
||||
import { headAccessory as baseHeadAccessory } from './sets/base';
|
||||
|
||||
import {headAccessory as specialHeadAccessory} from './sets/special';
|
||||
import {headAccessory as mysteryHeadAccessory} from './sets/mystery';
|
||||
import {headAccessory as armoireHeadAccessory} from './sets/armoire';
|
||||
import { headAccessory as specialHeadAccessory } from './sets/special';
|
||||
import { headAccessory as mysteryHeadAccessory } from './sets/mystery';
|
||||
import { headAccessory as armoireHeadAccessory } from './sets/armoire';
|
||||
|
||||
let headAccessory = {
|
||||
const headAccessory = {
|
||||
base: baseHeadAccessory,
|
||||
special: specialHeadAccessory,
|
||||
mystery: mysteryHeadAccessory,
|
||||
@@ -12,4 +12,3 @@ let headAccessory = {
|
||||
};
|
||||
|
||||
export default headAccessory;
|
||||
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
import {head as baseHead} from './sets/base';
|
||||
import { head as baseHead } from './sets/base';
|
||||
|
||||
import {head as healerHead} from './sets/healer';
|
||||
import {head as rogueHead} from './sets/rogue';
|
||||
import {head as warriorHead} from './sets/warrior';
|
||||
import {head as wizardHead} from './sets/wizard';
|
||||
import { head as healerHead } from './sets/healer';
|
||||
import { head as rogueHead } from './sets/rogue';
|
||||
import { head as warriorHead } from './sets/warrior';
|
||||
import { head as wizardHead } from './sets/wizard';
|
||||
|
||||
import {head as armoireHead} from './sets/armoire';
|
||||
import {head as mysteryHead} from './sets/mystery';
|
||||
import {head as specialHead} from './sets/special';
|
||||
import { head as armoireHead } from './sets/armoire';
|
||||
import { head as mysteryHead } from './sets/mystery';
|
||||
import { head as specialHead } from './sets/special';
|
||||
|
||||
let head = {
|
||||
const head = {
|
||||
base: baseHead,
|
||||
|
||||
warrior: warriorHead,
|
||||
|
||||
@@ -17,7 +17,7 @@ import body from './body';
|
||||
import headAccessory from './head-accessory';
|
||||
import eyewear from './eyewear';
|
||||
|
||||
let gear = {
|
||||
const gear = {
|
||||
weapon,
|
||||
armor,
|
||||
head,
|
||||
@@ -32,15 +32,15 @@ let gear = {
|
||||
The gear is exported as a tree (defined above), and a flat list (eg, {weapon_healer_1: .., shield_special_0: ...}) since
|
||||
they are needed in different forms at different points in the app
|
||||
*/
|
||||
let flat = {};
|
||||
const flat = {};
|
||||
|
||||
each(GEAR_TYPES, (type) => {
|
||||
let allGearTypes = CLASSES.concat(['base', 'special', 'mystery', 'armoire']);
|
||||
each(GEAR_TYPES, type => {
|
||||
const allGearTypes = CLASSES.concat(['base', 'special', 'mystery', 'armoire']);
|
||||
|
||||
each(allGearTypes, (klass) => {
|
||||
each(allGearTypes, klass => {
|
||||
each(gear[type][klass], (item, index) => {
|
||||
let key = `${type}_${klass}_${index}`;
|
||||
let set = `${klass}-${index}`;
|
||||
const key = `${type}_${klass}_${index}`;
|
||||
const set = `${klass}-${index}`;
|
||||
|
||||
defaults(item, {
|
||||
type,
|
||||
@@ -52,21 +52,17 @@ each(GEAR_TYPES, (type) => {
|
||||
int: 0,
|
||||
per: 0,
|
||||
con: 0,
|
||||
canBuy: () => {
|
||||
return false;
|
||||
},
|
||||
canBuy: () => false,
|
||||
});
|
||||
|
||||
if (item.event) {
|
||||
let canOwnFuncTrue = () => {
|
||||
return true;
|
||||
};
|
||||
let _canOwn = item.canOwn || canOwnFuncTrue;
|
||||
const canOwnFuncTrue = () => true;
|
||||
const _canOwn = item.canOwn || canOwnFuncTrue;
|
||||
|
||||
item.canOwn = (user) => {
|
||||
let userHasOwnedItem = ownsItem(key)(user);
|
||||
let eventIsCurrent = moment().isAfter(item.event.start) && moment().isBefore(item.event.end);
|
||||
let compatibleWithUserClass = item.specialClass ? user.stats.class === item.specialClass : true;
|
||||
item.canOwn = user => {
|
||||
const userHasOwnedItem = ownsItem(key)(user);
|
||||
const eventIsCurrent = moment().isAfter(item.event.start) && moment().isBefore(item.event.end);
|
||||
const compatibleWithUserClass = item.specialClass ? user.stats.class === item.specialClass : true;
|
||||
|
||||
return _canOwn(user) && (userHasOwnedItem || eventIsCurrent) && compatibleWithUserClass;
|
||||
};
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { ownsItem } from '../gear-helper';
|
||||
import t from '../../translation';
|
||||
|
||||
let armor = {
|
||||
const armor = {
|
||||
lunarArmor: {
|
||||
text: t('armorArmoireLunarArmorText'),
|
||||
notes: t('armorArmoireLunarArmorNotes', { str: 7, int: 7 }),
|
||||
@@ -500,7 +500,7 @@ let armor = {
|
||||
},
|
||||
};
|
||||
|
||||
let body = {
|
||||
const body = {
|
||||
cozyScarf: {
|
||||
text: t('bodyArmoireCozyScarfText'),
|
||||
notes: t('bodyArmoireCozyScarfNotes', { attrs: 5 }),
|
||||
@@ -512,7 +512,7 @@ let body = {
|
||||
},
|
||||
};
|
||||
|
||||
let eyewear = {
|
||||
const eyewear = {
|
||||
plagueDoctorMask: {
|
||||
text: t('eyewearArmoirePlagueDoctorMaskText'),
|
||||
notes: t('eyewearArmoirePlagueDoctorMaskNotes', { attrs: 5 }),
|
||||
@@ -531,7 +531,7 @@ let eyewear = {
|
||||
},
|
||||
};
|
||||
|
||||
let head = {
|
||||
const head = {
|
||||
lunarCrown: {
|
||||
text: t('headArmoireLunarCrownText'),
|
||||
notes: t('headArmoireLunarCrownNotes', { con: 7, per: 7 }),
|
||||
@@ -1022,7 +1022,7 @@ let head = {
|
||||
},
|
||||
};
|
||||
|
||||
let shield = {
|
||||
const shield = {
|
||||
gladiatorShield: {
|
||||
text: t('shieldArmoireGladiatorShieldText'),
|
||||
notes: t('shieldArmoireGladiatorShieldNotes', { con: 5, str: 5 }),
|
||||
@@ -1301,7 +1301,7 @@ let shield = {
|
||||
},
|
||||
};
|
||||
|
||||
let headAccessory = {
|
||||
const headAccessory = {
|
||||
comicalArrow: {
|
||||
text: t('headAccessoryArmoireComicalArrowText'),
|
||||
notes: t('headAccessoryArmoireComicalArrowNotes', { str: 10 }),
|
||||
@@ -1319,7 +1319,7 @@ let headAccessory = {
|
||||
},
|
||||
};
|
||||
|
||||
let weapon = {
|
||||
const weapon = {
|
||||
basicCrossbow: {
|
||||
text: t('weaponArmoireBasicCrossbowText'),
|
||||
notes: t('weaponArmoireBasicCrossbowNotes', { str: 5, per: 5, con: 5 }),
|
||||
@@ -1755,4 +1755,4 @@ export {
|
||||
headAccessory,
|
||||
shield,
|
||||
weapon,
|
||||
};
|
||||
};
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import t from '../../translation';
|
||||
|
||||
let armor = {
|
||||
const armor = {
|
||||
0: {
|
||||
text: t('armorBase0Text'),
|
||||
notes: t('armorBase0Notes'),
|
||||
@@ -8,7 +8,7 @@ let armor = {
|
||||
},
|
||||
};
|
||||
|
||||
let back = {
|
||||
const back = {
|
||||
0: {
|
||||
text: t('backBase0Text'),
|
||||
notes: t('backBase0Notes'),
|
||||
@@ -16,7 +16,7 @@ let back = {
|
||||
},
|
||||
};
|
||||
|
||||
let body = {
|
||||
const body = {
|
||||
0: {
|
||||
text: t('bodyBase0Text'),
|
||||
notes: t('bodyBase0Notes'),
|
||||
@@ -24,7 +24,7 @@ let body = {
|
||||
},
|
||||
};
|
||||
|
||||
let eyewear = {
|
||||
const eyewear = {
|
||||
0: {
|
||||
text: t('eyewearBase0Text'),
|
||||
notes: t('eyewearBase0Notes'),
|
||||
@@ -33,7 +33,7 @@ let eyewear = {
|
||||
},
|
||||
};
|
||||
|
||||
let head = {
|
||||
const head = {
|
||||
0: {
|
||||
text: t('headBase0Text'),
|
||||
notes: t('headBase0Notes'),
|
||||
@@ -41,7 +41,7 @@ let head = {
|
||||
},
|
||||
};
|
||||
|
||||
let headAccessory = {
|
||||
const headAccessory = {
|
||||
0: {
|
||||
text: t('headAccessoryBase0Text'),
|
||||
notes: t('headAccessoryBase0Notes'),
|
||||
@@ -50,7 +50,7 @@ let headAccessory = {
|
||||
},
|
||||
};
|
||||
|
||||
let shield = {
|
||||
const shield = {
|
||||
0: {
|
||||
text: t('shieldBase0Text'),
|
||||
notes: t('shieldBase0Notes'),
|
||||
@@ -58,7 +58,7 @@ let shield = {
|
||||
},
|
||||
};
|
||||
|
||||
let weapon = {
|
||||
const weapon = {
|
||||
0: {
|
||||
text: t('weaponBase0Text'),
|
||||
notes: t('weaponBase0Notes'),
|
||||
@@ -75,4 +75,4 @@ export {
|
||||
headAccessory,
|
||||
shield,
|
||||
weapon,
|
||||
};
|
||||
};
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import t from '../../translation';
|
||||
|
||||
let armor = {
|
||||
const armor = {
|
||||
1: {
|
||||
text: t('armorHealer1Text'),
|
||||
notes: t('armorHealer1Notes', { con: 6 }),
|
||||
@@ -34,7 +34,7 @@ let armor = {
|
||||
},
|
||||
};
|
||||
|
||||
let head = {
|
||||
const head = {
|
||||
1: {
|
||||
text: t('headHealer1Text'),
|
||||
notes: t('headHealer1Notes', { int: 2 }),
|
||||
@@ -68,7 +68,7 @@ let head = {
|
||||
},
|
||||
};
|
||||
|
||||
let shield = {
|
||||
const shield = {
|
||||
1: {
|
||||
text: t('shieldHealer1Text'),
|
||||
notes: t('shieldHealer1Notes', { con: 2 }),
|
||||
@@ -102,7 +102,7 @@ let shield = {
|
||||
},
|
||||
};
|
||||
|
||||
let weapon = {
|
||||
const weapon = {
|
||||
|
||||
0: {
|
||||
text: t('weaponHealer0Text'),
|
||||
@@ -153,4 +153,4 @@ export {
|
||||
head,
|
||||
shield,
|
||||
weapon,
|
||||
};
|
||||
};
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import t from '../../translation';
|
||||
|
||||
let armor = {
|
||||
const armor = {
|
||||
201402: {
|
||||
text: t('armorMystery201402Text'),
|
||||
notes: t('armorMystery201402Notes'),
|
||||
@@ -279,7 +279,7 @@ let armor = {
|
||||
},
|
||||
};
|
||||
|
||||
let back = {
|
||||
const back = {
|
||||
201402: {
|
||||
text: t('backMystery201402Text'),
|
||||
notes: t('backMystery201402Notes'),
|
||||
@@ -390,7 +390,7 @@ let back = {
|
||||
},
|
||||
};
|
||||
|
||||
let body = {
|
||||
const body = {
|
||||
201705: {
|
||||
text: t('bodyMystery201705Text'),
|
||||
notes: t('bodyMystery201705Notes'),
|
||||
@@ -417,7 +417,7 @@ let body = {
|
||||
},
|
||||
};
|
||||
|
||||
let eyewear = {
|
||||
const eyewear = {
|
||||
201503: {
|
||||
text: t('eyewearMystery201503Text'),
|
||||
notes: t('eyewearMystery201503Notes'),
|
||||
@@ -474,7 +474,7 @@ let eyewear = {
|
||||
},
|
||||
};
|
||||
|
||||
let head = {
|
||||
const head = {
|
||||
201402: {
|
||||
text: t('headMystery201402Text'),
|
||||
notes: t('headMystery201402Notes'),
|
||||
@@ -771,7 +771,7 @@ let head = {
|
||||
},
|
||||
};
|
||||
|
||||
let headAccessory = {
|
||||
const headAccessory = {
|
||||
201403: {
|
||||
text: t('headAccessoryMystery201403Text'),
|
||||
notes: t('headAccessoryMystery201403Notes'),
|
||||
@@ -846,7 +846,7 @@ let headAccessory = {
|
||||
},
|
||||
};
|
||||
|
||||
let shield = {
|
||||
const shield = {
|
||||
201601: {
|
||||
text: t('shieldMystery201601Text'),
|
||||
notes: t('shieldMystery201601Notes'),
|
||||
@@ -897,7 +897,7 @@ let shield = {
|
||||
},
|
||||
};
|
||||
|
||||
let weapon = {
|
||||
const weapon = {
|
||||
201411: {
|
||||
text: t('weaponMystery201411Text'),
|
||||
notes: t('weaponMystery201411Notes'),
|
||||
@@ -951,4 +951,4 @@ export {
|
||||
headAccessory,
|
||||
shield,
|
||||
weapon,
|
||||
};
|
||||
};
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import t from '../../translation';
|
||||
|
||||
let armor = {
|
||||
const armor = {
|
||||
1: {
|
||||
text: t('armorRogue1Text'),
|
||||
notes: t('armorRogue1Notes', { per: 6 }),
|
||||
@@ -34,7 +34,7 @@ let armor = {
|
||||
},
|
||||
};
|
||||
|
||||
let head = {
|
||||
const head = {
|
||||
1: {
|
||||
text: t('headRogue1Text'),
|
||||
notes: t('headRogue1Notes', { per: 2 }),
|
||||
@@ -68,7 +68,7 @@ let head = {
|
||||
},
|
||||
};
|
||||
|
||||
let weapon = {
|
||||
const weapon = {
|
||||
0: {
|
||||
text: t('weaponRogue0Text'),
|
||||
notes: t('weaponRogue0Notes'),
|
||||
@@ -114,7 +114,7 @@ let weapon = {
|
||||
},
|
||||
};
|
||||
|
||||
let shield = {
|
||||
const shield = {
|
||||
0: {
|
||||
text: t('weaponRogue0Text'),
|
||||
notes: t('weaponRogue0Notes'),
|
||||
@@ -165,4 +165,4 @@ export {
|
||||
head,
|
||||
shield,
|
||||
weapon,
|
||||
};
|
||||
};
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,16 +1,14 @@
|
||||
import { ownsItem } from '../../gear-helper';
|
||||
import t from '../../../translation';
|
||||
|
||||
let isBackerOfLevel = (tierRequirement, ownedItem) => {
|
||||
return (user) => {
|
||||
let backer = user.backer;
|
||||
let tier = Number(backer && backer.tier);
|
||||
const isBackerOfLevel = (tierRequirement, ownedItem) => user => {
|
||||
const { backer } = user;
|
||||
const tier = Number(backer && backer.tier);
|
||||
|
||||
return tier >= tierRequirement || ownsItem(ownedItem)(user);
|
||||
};
|
||||
return tier >= tierRequirement || ownsItem(ownedItem)(user);
|
||||
};
|
||||
|
||||
let armorSpecial0 = {
|
||||
const armorSpecial0 = {
|
||||
text: t('armorSpecial0Text'),
|
||||
notes: t('armorSpecial0Notes', { con: 20 }),
|
||||
con: 20,
|
||||
@@ -18,7 +16,7 @@ let armorSpecial0 = {
|
||||
canOwn: isBackerOfLevel(45, 'armor_special_0'),
|
||||
};
|
||||
|
||||
let armorSpecial2 = {
|
||||
const armorSpecial2 = {
|
||||
text: t('armorSpecial2Text'),
|
||||
notes: t('armorSpecial2Notes', { attrs: 25 }),
|
||||
int: 25,
|
||||
@@ -27,7 +25,7 @@ let armorSpecial2 = {
|
||||
canOwn: isBackerOfLevel(300, 'armor_special_2'),
|
||||
};
|
||||
|
||||
let headSpecial0 = {
|
||||
const headSpecial0 = {
|
||||
text: t('headSpecial0Text'),
|
||||
notes: t('headSpecial0Notes', { int: 20 }),
|
||||
int: 20,
|
||||
@@ -35,7 +33,7 @@ let headSpecial0 = {
|
||||
canOwn: isBackerOfLevel(45, 'head_special_0'),
|
||||
};
|
||||
|
||||
let headSpecial2 = {
|
||||
const headSpecial2 = {
|
||||
text: t('headSpecial2Text'),
|
||||
notes: t('headSpecial2Notes', { attrs: 25 }),
|
||||
int: 25,
|
||||
@@ -44,7 +42,7 @@ let headSpecial2 = {
|
||||
canOwn: isBackerOfLevel(300, 'head_special_2'),
|
||||
};
|
||||
|
||||
let shieldSpecial0 = {
|
||||
const shieldSpecial0 = {
|
||||
text: t('shieldSpecial0Text'),
|
||||
notes: t('shieldSpecial0Notes', { per: 20 }),
|
||||
per: 20,
|
||||
@@ -52,7 +50,7 @@ let shieldSpecial0 = {
|
||||
canOwn: isBackerOfLevel(45, 'shield_special_0'),
|
||||
};
|
||||
|
||||
let weaponSpecial0 = {
|
||||
const weaponSpecial0 = {
|
||||
text: t('weaponSpecial0Text'),
|
||||
notes: t('weaponSpecial0Notes', { str: 20 }),
|
||||
str: 20,
|
||||
@@ -60,7 +58,7 @@ let weaponSpecial0 = {
|
||||
canOwn: isBackerOfLevel(70, 'weapon_special_0'),
|
||||
};
|
||||
|
||||
let weaponSpecial2 = {
|
||||
const weaponSpecial2 = {
|
||||
text: t('weaponSpecial2Text'),
|
||||
notes: t('weaponSpecial2Notes', { attrs: 25 }),
|
||||
str: 25,
|
||||
@@ -69,7 +67,7 @@ let weaponSpecial2 = {
|
||||
canOwn: isBackerOfLevel(300, 'weapon_special_2'),
|
||||
};
|
||||
|
||||
let weaponSpecial3 = {
|
||||
const weaponSpecial3 = {
|
||||
text: t('weaponSpecial3Text'),
|
||||
notes: t('weaponSpecial3Notes', { attrs: 17 }),
|
||||
str: 17,
|
||||
@@ -88,4 +86,4 @@ export {
|
||||
weaponSpecial0,
|
||||
weaponSpecial2,
|
||||
weaponSpecial3,
|
||||
};
|
||||
};
|
||||
|
||||
@@ -1,16 +1,14 @@
|
||||
import { ownsItem } from '../../gear-helper';
|
||||
import t from '../../../translation';
|
||||
|
||||
let isContributorOfLevel = (tierRequirement, ownedItem) => {
|
||||
return (user) => {
|
||||
let contributor = user.contributor;
|
||||
let tier = contributor && contributor.level;
|
||||
const isContributorOfLevel = (tierRequirement, ownedItem) => user => {
|
||||
const { contributor } = user;
|
||||
const tier = contributor && contributor.level;
|
||||
|
||||
return Number(tier) >= tierRequirement || ownsItem(ownedItem)(user);
|
||||
};
|
||||
return Number(tier) >= tierRequirement || ownsItem(ownedItem)(user);
|
||||
};
|
||||
|
||||
let armorSpecial1 = {
|
||||
const armorSpecial1 = {
|
||||
text: t('armorSpecial1Text'),
|
||||
notes: t('armorSpecial1Notes', { attrs: 6 }),
|
||||
con: 6,
|
||||
@@ -21,7 +19,7 @@ let armorSpecial1 = {
|
||||
canOwn: isContributorOfLevel(2, 'armor_special_1'),
|
||||
};
|
||||
|
||||
let headSpecial1 = {
|
||||
const headSpecial1 = {
|
||||
text: t('headSpecial1Text'),
|
||||
notes: t('headSpecial1Notes', { attrs: 6 }),
|
||||
con: 6,
|
||||
@@ -32,7 +30,7 @@ let headSpecial1 = {
|
||||
canOwn: isContributorOfLevel(3, 'head_special_1'),
|
||||
};
|
||||
|
||||
let shieldSpecial1 = {
|
||||
const shieldSpecial1 = {
|
||||
text: t('shieldSpecial1Text'),
|
||||
notes: t('shieldSpecial1Notes', { attrs: 6 }),
|
||||
con: 6,
|
||||
@@ -43,7 +41,7 @@ let shieldSpecial1 = {
|
||||
canOwn: isContributorOfLevel(5, 'shield_special_1'),
|
||||
};
|
||||
|
||||
let weaponSpecial1 = {
|
||||
const weaponSpecial1 = {
|
||||
text: t('weaponSpecial1Text'),
|
||||
notes: t('weaponSpecial1Notes', { attrs: 6 }),
|
||||
str: 6,
|
||||
@@ -54,15 +52,15 @@ let weaponSpecial1 = {
|
||||
canOwn: isContributorOfLevel(4, 'weapon_special_1'),
|
||||
};
|
||||
|
||||
let weaponSpecialCritical = {
|
||||
const weaponSpecialCritical = {
|
||||
text: t('weaponSpecialCriticalText'),
|
||||
notes: t('weaponSpecialCriticalNotes', { attrs: 40 }),
|
||||
str: 40,
|
||||
per: 40,
|
||||
value: 200,
|
||||
canOwn: (user) => {
|
||||
let hasCriticalFlag = user.contributor && user.contributor.critical;
|
||||
let alreadyHasItem = ownsItem('weapon_special_critical')(user);
|
||||
canOwn: user => {
|
||||
const hasCriticalFlag = user.contributor && user.contributor.critical;
|
||||
const alreadyHasItem = ownsItem('weapon_special_critical')(user);
|
||||
|
||||
return hasCriticalFlag || alreadyHasItem;
|
||||
},
|
||||
@@ -74,4 +72,4 @@ export {
|
||||
shieldSpecial1,
|
||||
weaponSpecial1,
|
||||
weaponSpecialCritical,
|
||||
};
|
||||
};
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import t from '../../../translation';
|
||||
|
||||
let armorSpecialTakeThis = {
|
||||
const armorSpecialTakeThis = {
|
||||
text: t('armorSpecialTakeThisText'),
|
||||
notes: t('armorSpecialTakeThisNotes', {attrs: 5}),
|
||||
notes: t('armorSpecialTakeThisNotes', { attrs: 5 }),
|
||||
value: 0,
|
||||
con: 5,
|
||||
int: 5,
|
||||
@@ -10,9 +10,9 @@ let armorSpecialTakeThis = {
|
||||
str: 5,
|
||||
};
|
||||
|
||||
let backSpecialTakeThis = {
|
||||
const backSpecialTakeThis = {
|
||||
text: t('backSpecialTakeThisText'),
|
||||
notes: t('backSpecialTakeThisNotes', {attrs: 1}),
|
||||
notes: t('backSpecialTakeThisNotes', { attrs: 1 }),
|
||||
value: 0,
|
||||
con: 1,
|
||||
int: 1,
|
||||
@@ -20,9 +20,9 @@ let backSpecialTakeThis = {
|
||||
str: 1,
|
||||
};
|
||||
|
||||
let bodySpecialTakeThis = {
|
||||
const bodySpecialTakeThis = {
|
||||
text: t('bodySpecialTakeThisText'),
|
||||
notes: t('bodySpecialTakeThisNotes', {attrs: 1}),
|
||||
notes: t('bodySpecialTakeThisNotes', { attrs: 1 }),
|
||||
value: 0,
|
||||
con: 1,
|
||||
int: 1,
|
||||
@@ -30,9 +30,9 @@ let bodySpecialTakeThis = {
|
||||
str: 1,
|
||||
};
|
||||
|
||||
let headSpecialTakeThis = {
|
||||
const headSpecialTakeThis = {
|
||||
text: t('headSpecialTakeThisText'),
|
||||
notes: t('headSpecialTakeThisNotes', {attrs: 5}),
|
||||
notes: t('headSpecialTakeThisNotes', { attrs: 5 }),
|
||||
value: 0,
|
||||
con: 5,
|
||||
int: 5,
|
||||
@@ -40,9 +40,9 @@ let headSpecialTakeThis = {
|
||||
str: 5,
|
||||
};
|
||||
|
||||
let shieldSpecialTakeThis = {
|
||||
const shieldSpecialTakeThis = {
|
||||
text: t('shieldSpecialTakeThisText'),
|
||||
notes: t('shieldSpecialTakeThisNotes', {attrs: 5}),
|
||||
notes: t('shieldSpecialTakeThisNotes', { attrs: 5 }),
|
||||
value: 0,
|
||||
con: 5,
|
||||
int: 5,
|
||||
@@ -50,9 +50,9 @@ let shieldSpecialTakeThis = {
|
||||
str: 5,
|
||||
};
|
||||
|
||||
let weaponSpecialTakeThis = {
|
||||
const weaponSpecialTakeThis = {
|
||||
text: t('weaponSpecialTakeThisText'),
|
||||
notes: t('weaponSpecialTakeThisNotes', {attrs: 5}),
|
||||
notes: t('weaponSpecialTakeThisNotes', { attrs: 5 }),
|
||||
value: 0,
|
||||
con: 5,
|
||||
int: 5,
|
||||
@@ -67,4 +67,4 @@ export {
|
||||
headSpecialTakeThis,
|
||||
shieldSpecialTakeThis,
|
||||
weaponSpecialTakeThis,
|
||||
};
|
||||
};
|
||||
|
||||
@@ -1,48 +1,48 @@
|
||||
import t from '../../../translation';
|
||||
|
||||
let backSpecialWonderconRed = {
|
||||
const backSpecialWonderconRed = {
|
||||
text: t('backSpecialWonderconRedText'),
|
||||
notes: t('backSpecialWonderconRedNotes'),
|
||||
value: 0,
|
||||
mystery: 'wondercon',
|
||||
};
|
||||
|
||||
let backSpecialWonderconBlack = {
|
||||
const backSpecialWonderconBlack = {
|
||||
text: t('backSpecialWonderconBlackText'),
|
||||
notes: t('backSpecialWonderconBlackNotes'),
|
||||
value: 0,
|
||||
mystery: 'wondercon',
|
||||
};
|
||||
|
||||
let bodySpecialWonderconRed = {
|
||||
const bodySpecialWonderconRed = {
|
||||
text: t('bodySpecialWonderconRedText'),
|
||||
notes: t('bodySpecialWonderconRedNotes'),
|
||||
value: 0,
|
||||
mystery: 'wondercon',
|
||||
};
|
||||
|
||||
let bodySpecialWonderconGold = {
|
||||
const bodySpecialWonderconGold = {
|
||||
text: t('bodySpecialWonderconGoldText'),
|
||||
notes: t('bodySpecialWonderconGoldNotes'),
|
||||
value: 0,
|
||||
mystery: 'wondercon',
|
||||
};
|
||||
|
||||
let bodySpecialWonderconBlack = {
|
||||
const bodySpecialWonderconBlack = {
|
||||
text: t('bodySpecialWonderconBlackText'),
|
||||
notes: t('bodySpecialWonderconBlackNotes'),
|
||||
value: 0,
|
||||
mystery: 'wondercon',
|
||||
};
|
||||
|
||||
let eyewearSpecialWonderconRed = {
|
||||
const eyewearSpecialWonderconRed = {
|
||||
text: t('eyewearSpecialWonderconRedText'),
|
||||
notes: t('eyewearSpecialWonderconRedNotes'),
|
||||
value: 0,
|
||||
mystery: 'wondercon',
|
||||
};
|
||||
|
||||
let eyewearSpecialWonderconBlack = {
|
||||
const eyewearSpecialWonderconBlack = {
|
||||
text: t('eyewearSpecialWonderconBlackText'),
|
||||
notes: t('eyewearSpecialWonderconBlackNotes'),
|
||||
value: 0,
|
||||
@@ -57,4 +57,4 @@ export {
|
||||
bodySpecialWonderconBlack,
|
||||
eyewearSpecialWonderconRed,
|
||||
eyewearSpecialWonderconBlack,
|
||||
};
|
||||
};
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import t from '../../translation';
|
||||
|
||||
let armor = {
|
||||
const armor = {
|
||||
1: {
|
||||
text: t('armorWarrior1Text'),
|
||||
notes: t('armorWarrior1Notes', { con: 3 }),
|
||||
@@ -34,7 +34,7 @@ let armor = {
|
||||
},
|
||||
};
|
||||
|
||||
let head = {
|
||||
const head = {
|
||||
1: {
|
||||
text: t('headWarrior1Text'),
|
||||
notes: t('headWarrior1Notes', { str: 2 }),
|
||||
@@ -68,7 +68,7 @@ let head = {
|
||||
},
|
||||
};
|
||||
|
||||
let shield = {
|
||||
const shield = {
|
||||
1: {
|
||||
text: t('shieldWarrior1Text'),
|
||||
notes: t('shieldWarrior1Notes', { con: 2 }),
|
||||
@@ -102,10 +102,12 @@ let shield = {
|
||||
},
|
||||
};
|
||||
|
||||
let weapon = {
|
||||
const weapon = {
|
||||
0: {
|
||||
text: t('weaponWarrior0Text'),
|
||||
notes: t('weaponWarrior0Notes'), value: 1 },
|
||||
notes: t('weaponWarrior0Notes'),
|
||||
value: 1,
|
||||
},
|
||||
1: {
|
||||
text: t('weaponWarrior1Text'),
|
||||
notes: t('weaponWarrior1Notes', { str: 3 }),
|
||||
@@ -150,4 +152,4 @@ export {
|
||||
head,
|
||||
shield,
|
||||
weapon,
|
||||
};
|
||||
};
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import t from '../../translation';
|
||||
|
||||
let armor = {
|
||||
const armor = {
|
||||
1: {
|
||||
text: t('armorWizard1Text'),
|
||||
notes: t('armorWizard1Notes', { int: 2 }),
|
||||
@@ -34,7 +34,7 @@ let armor = {
|
||||
},
|
||||
};
|
||||
|
||||
let head = {
|
||||
const head = {
|
||||
1: {
|
||||
text: t('headWizard1Text'),
|
||||
notes: t('headWizard1Notes', { per: 2 }),
|
||||
@@ -68,18 +68,20 @@ let head = {
|
||||
},
|
||||
};
|
||||
|
||||
let shield = {
|
||||
const shield = {
|
||||
// Wizard's weapons are two handed
|
||||
// And thus do not have shields
|
||||
// But the content structure still expects an object
|
||||
};
|
||||
|
||||
let weapon = {
|
||||
const weapon = {
|
||||
|
||||
0: {
|
||||
twoHanded: true,
|
||||
text: t('weaponWizard0Text'),
|
||||
notes: t('weaponWizard0Notes'), value: 0 },
|
||||
notes: t('weaponWizard0Notes'),
|
||||
value: 0,
|
||||
},
|
||||
1: {
|
||||
twoHanded: true,
|
||||
text: t('weaponWizard1Text'),
|
||||
@@ -136,4 +138,4 @@ export {
|
||||
head,
|
||||
shield,
|
||||
weapon,
|
||||
};
|
||||
};
|
||||
|
||||
@@ -1,19 +1,19 @@
|
||||
import cloneDeep from 'lodash/cloneDeep';
|
||||
|
||||
import {shield as baseShield} from './sets/base';
|
||||
import { shield as baseShield } from './sets/base';
|
||||
|
||||
import {shield as healerShield} from './sets/healer';
|
||||
import {weapon as rogueWeapon} from './sets/rogue';
|
||||
import {shield as warriorShield} from './sets/warrior';
|
||||
import {shield as wizardShield} from './sets/wizard';
|
||||
import { shield as healerShield } from './sets/healer';
|
||||
import { weapon as rogueWeapon } from './sets/rogue';
|
||||
import { shield as warriorShield } from './sets/warrior';
|
||||
import { shield as wizardShield } from './sets/wizard';
|
||||
|
||||
import {shield as armoireShield} from './sets/armoire';
|
||||
import {shield as mysteryShield} from './sets/mystery';
|
||||
import {shield as specialShield} from './sets/special';
|
||||
import { shield as armoireShield } from './sets/armoire';
|
||||
import { shield as mysteryShield } from './sets/mystery';
|
||||
import { shield as specialShield } from './sets/special';
|
||||
|
||||
let rogueShield = cloneDeep(rogueWeapon);
|
||||
const rogueShield = cloneDeep(rogueWeapon);
|
||||
|
||||
let shield = {
|
||||
const shield = {
|
||||
base: baseShield,
|
||||
|
||||
warrior: warriorShield,
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
import t from '../translation';
|
||||
|
||||
import {weapon as baseWeapon} from './sets/base';
|
||||
import { weapon as baseWeapon } from './sets/base';
|
||||
|
||||
import {weapon as healerWeapon} from './sets/healer';
|
||||
import {weapon as rogueWeapon} from './sets/rogue';
|
||||
import {weapon as warriorWeapon} from './sets/warrior';
|
||||
import {weapon as wizardWeapon} from './sets/wizard';
|
||||
import { weapon as healerWeapon } from './sets/healer';
|
||||
import { weapon as rogueWeapon } from './sets/rogue';
|
||||
import { weapon as warriorWeapon } from './sets/warrior';
|
||||
import { weapon as wizardWeapon } from './sets/wizard';
|
||||
|
||||
import {weapon as armoireWeapon} from './sets/armoire';
|
||||
import {weapon as mysteryWeapon} from './sets/mystery';
|
||||
import {weapon as specialWeapon} from './sets/special';
|
||||
import { weapon as armoireWeapon } from './sets/armoire';
|
||||
import { weapon as mysteryWeapon } from './sets/mystery';
|
||||
import { weapon as specialWeapon } from './sets/special';
|
||||
|
||||
let weapon = {
|
||||
const weapon = {
|
||||
base: baseWeapon,
|
||||
|
||||
warrior: warriorWeapon,
|
||||
@@ -27,31 +27,31 @@ let weapon = {
|
||||
// Add Two Handed message to all weapons
|
||||
const rtlLanguages = [
|
||||
'ae', /* Avestan */
|
||||
'ar', /* 'العربية', Arabic */
|
||||
'arc', /* Aramaic */
|
||||
'bcc', /* 'بلوچی مکرانی', Southern Balochi */
|
||||
'bqi', /* 'بختياري', Bakthiari */
|
||||
'ckb', /* 'Soranî / کوردی', Sorani */
|
||||
'dv', /* Dhivehi */
|
||||
'fa', /* 'فارسی', Persian */
|
||||
'glk', /* 'گیلکی', Gilaki */
|
||||
'he', /* 'עברית', Hebrew */
|
||||
'ku', /* 'Kurdî / كوردی', Kurdish */
|
||||
'mzn', /* 'مازِرونی', Mazanderani */
|
||||
'nqo', /* N'Ko */
|
||||
'pnb', /* 'پنجابی', Western Punjabi */
|
||||
'ps', /* 'پښتو', Pashto, */
|
||||
'sd', /* 'سنڌي', Sindhi */
|
||||
'ug', /* 'Uyghurche / ئۇيغۇرچە', Uyghur */
|
||||
'ur', /* 'اردو', Urdu */
|
||||
'yi', /* 'ייִדיש', Yiddish */
|
||||
'ar', /* 'العربية', Arabic */
|
||||
'arc', /* Aramaic */
|
||||
'bcc', /* 'بلوچی مکرانی', Southern Balochi */
|
||||
'bqi', /* 'بختياري', Bakthiari */
|
||||
'ckb', /* 'Soranî / کوردی', Sorani */
|
||||
'dv', /* Dhivehi */
|
||||
'fa', /* 'فارسی', Persian */
|
||||
'glk', /* 'گیلکی', Gilaki */
|
||||
'he', /* 'עברית', Hebrew */
|
||||
'ku', /* 'Kurdî / كوردی', Kurdish */
|
||||
'mzn', /* 'مازِرونی', Mazanderani */
|
||||
'nqo', /* N'Ko */
|
||||
'pnb', /* 'پنجابی', Western Punjabi */
|
||||
'ps', /* 'پښتو', Pashto, */
|
||||
'sd', /* 'سنڌي', Sindhi */
|
||||
'ug', /* 'Uyghurche / ئۇيغۇرچە', Uyghur */
|
||||
'ur', /* 'اردو', Urdu */
|
||||
'yi', /* 'ייִדיש', Yiddish */
|
||||
];
|
||||
for (let key in weapon) {
|
||||
for (const key in weapon) {
|
||||
const set = weapon[key];
|
||||
for (let weaponKey in set) {
|
||||
for (const weaponKey in set) {
|
||||
const item = set[weaponKey];
|
||||
const oldnotes = item.notes;
|
||||
item.notes = (lang) => {
|
||||
item.notes = lang => {
|
||||
const twoHandedText = item.twoHanded ? t('twoHandedItem')(lang) : '';
|
||||
|
||||
if (rtlLanguages.indexOf(lang) !== -1) {
|
||||
|
||||
@@ -6,13 +6,11 @@ import t from './translation';
|
||||
const CURRENT_SEASON = 'October';
|
||||
|
||||
function hasQuestAchievementFunction (key) {
|
||||
return (user) => {
|
||||
return user.achievements.quests &&
|
||||
user.achievements.quests[key] > 0;
|
||||
};
|
||||
return user => user.achievements.quests
|
||||
&& user.achievements.quests[key] > 0;
|
||||
}
|
||||
|
||||
let drops = {
|
||||
const drops = {
|
||||
Base: {
|
||||
value: 2,
|
||||
text: t('hatchingPotionBase'),
|
||||
@@ -55,7 +53,7 @@ let drops = {
|
||||
},
|
||||
};
|
||||
|
||||
let premium = {
|
||||
const premium = {
|
||||
RoyalPurple: {
|
||||
value: 2,
|
||||
text: t('hatchingPotionRoyalPurple'),
|
||||
@@ -279,7 +277,7 @@ each(wacky, (pot, key) => {
|
||||
});
|
||||
});
|
||||
|
||||
let all = assign({}, drops, premium, wacky);
|
||||
const all = assign({}, drops, premium, wacky);
|
||||
|
||||
export {
|
||||
drops,
|
||||
|
||||
@@ -2,7 +2,7 @@ import defaults from 'lodash/defaults';
|
||||
import each from 'lodash/each';
|
||||
import moment from 'moment';
|
||||
import t from './translation';
|
||||
import {tasksByCategory} from './tasks';
|
||||
import { tasksByCategory } from './tasks';
|
||||
|
||||
import {
|
||||
CLASSES,
|
||||
@@ -12,8 +12,6 @@ import {
|
||||
ANIMAL_COLOR_ACHIEVEMENTS,
|
||||
} from './constants';
|
||||
|
||||
const api = {};
|
||||
|
||||
import achievements from './achievements';
|
||||
|
||||
import * as eggs from './eggs';
|
||||
@@ -27,7 +25,7 @@ import {
|
||||
} from './quests';
|
||||
|
||||
import appearances from './appearance';
|
||||
import {backgroundsTree, backgroundsFlat} from './appearance/backgrounds';
|
||||
import { backgroundsTree, backgroundsFlat } from './appearance/backgrounds';
|
||||
import spells from './spells';
|
||||
import subscriptionBlocks from './subscriptionBlocks';
|
||||
import faq from './faq';
|
||||
@@ -37,6 +35,8 @@ import loginIncentives from './loginIncentives';
|
||||
|
||||
import officialPinnedItems from './officialPinnedItems';
|
||||
|
||||
const api = {};
|
||||
|
||||
api.achievements = achievements;
|
||||
api.questSeriesAchievements = QUEST_SERIES_ACHIEVEMENTS;
|
||||
api.animalColorAchievements = ANIMAL_COLOR_ACHIEVEMENTS;
|
||||
@@ -810,17 +810,15 @@ api.food = {
|
||||
/* eslint-enable camelcase */
|
||||
};
|
||||
|
||||
each(api.food, (food, key) => {
|
||||
return defaults(food, {
|
||||
value: 1,
|
||||
key,
|
||||
notes: t('foodNotes'),
|
||||
canBuy () {
|
||||
return false;
|
||||
},
|
||||
canDrop: false,
|
||||
});
|
||||
});
|
||||
each(api.food, (food, key) => defaults(food, {
|
||||
value: 1,
|
||||
key,
|
||||
notes: t('foodNotes'),
|
||||
canBuy () {
|
||||
return false;
|
||||
},
|
||||
canDrop: false,
|
||||
}));
|
||||
|
||||
api.appearances = appearances;
|
||||
|
||||
@@ -837,9 +835,9 @@ api.userDefaults = {
|
||||
down: false,
|
||||
attribute: 'per',
|
||||
tags: [
|
||||
t('defaultTag1'), // Work
|
||||
t('defaultTag4'), // School
|
||||
t('defaultTag6'), // Chores
|
||||
t('defaultTag1'), // Work
|
||||
t('defaultTag4'), // School
|
||||
t('defaultTag6'), // Chores
|
||||
],
|
||||
}, {
|
||||
type: 'habit',
|
||||
@@ -849,7 +847,7 @@ api.userDefaults = {
|
||||
down: true,
|
||||
attribute: 'str',
|
||||
tags: [
|
||||
t('defaultTag3'), // Health + Wellness
|
||||
t('defaultTag3'), // Health + Wellness
|
||||
],
|
||||
}, {
|
||||
type: 'habit',
|
||||
@@ -859,8 +857,8 @@ api.userDefaults = {
|
||||
down: true,
|
||||
attribute: 'str',
|
||||
tags: [
|
||||
t('defaultTag2'), // Exercise
|
||||
t('defaultTag3'), // Health + Wellness
|
||||
t('defaultTag2'), // Exercise
|
||||
t('defaultTag3'), // Health + Wellness
|
||||
],
|
||||
},
|
||||
],
|
||||
|
||||
@@ -4,7 +4,7 @@ import { MAX_INCENTIVES } from '../constants';
|
||||
// NOTE do not import this file alone but only access it through common.content
|
||||
// so that it's already compiled
|
||||
export default function getLoginIncentives (api) {
|
||||
let loginIncentives = {
|
||||
const loginIncentives = {
|
||||
1: {
|
||||
rewardKey: ['armor_special_bardRobes'],
|
||||
reward: [api.gear.flat.armor_special_bardRobes],
|
||||
@@ -645,7 +645,7 @@ export default function getLoginIncentives (api) {
|
||||
// We could also, use a list, but then we would be cloning each of the rewards.
|
||||
// Create a new array if we want the loginIncentives to be immutable in the future
|
||||
let nextRewardKey;
|
||||
range(MAX_INCENTIVES + 1).reverse().forEach(function addNextRewardLink (index) {
|
||||
range(MAX_INCENTIVES + 1).reverse().forEach(index => {
|
||||
if (loginIncentives[index] && loginIncentives[index].rewardKey) {
|
||||
loginIncentives[index].nextRewardAt = nextRewardKey;
|
||||
nextRewardKey = index;
|
||||
@@ -659,7 +659,7 @@ export default function getLoginIncentives (api) {
|
||||
});
|
||||
|
||||
let prevRewardKey;
|
||||
range(MAX_INCENTIVES + 1).forEach(function addPrevRewardLink (index) {
|
||||
range(MAX_INCENTIVES + 1).forEach(index => {
|
||||
loginIncentives[index].prevRewardKey = prevRewardKey;
|
||||
if (loginIncentives[index].rewardKey) prevRewardKey = index;
|
||||
});
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import each from 'lodash/each';
|
||||
import t from './translation';
|
||||
|
||||
let mysterySets = {
|
||||
const mysterySets = {
|
||||
201402: {
|
||||
start: '2014-02-22',
|
||||
end: '2014-02-28',
|
||||
|
||||
@@ -6,9 +6,9 @@ import {
|
||||
USER_CAN_OWN_QUEST_CATEGORIES,
|
||||
} from './constants';
|
||||
|
||||
let userCanOwnQuestCategories = USER_CAN_OWN_QUEST_CATEGORIES;
|
||||
const userCanOwnQuestCategories = USER_CAN_OWN_QUEST_CATEGORIES;
|
||||
|
||||
let quests = {
|
||||
const quests = {
|
||||
dilatory: {
|
||||
text: t('questDilatoryText'),
|
||||
notes: t('questDilatoryNotes'),
|
||||
@@ -2261,7 +2261,7 @@ let quests = {
|
||||
unlockCondition: {
|
||||
condition: 'party invite',
|
||||
incentiveThreshold: 7,
|
||||
text: t('loginReward', {count: 7}),
|
||||
text: t('loginReward', { count: 7 }),
|
||||
},
|
||||
collect: {
|
||||
shard: {
|
||||
@@ -2292,7 +2292,7 @@ let quests = {
|
||||
unlockCondition: {
|
||||
condition: 'party invite',
|
||||
incentiveThreshold: 22,
|
||||
text: t('loginReward', {count: 22}),
|
||||
text: t('loginReward', { count: 22 }),
|
||||
},
|
||||
boss: {
|
||||
name: t('questMoon2Boss'),
|
||||
@@ -2322,7 +2322,7 @@ let quests = {
|
||||
unlockCondition: {
|
||||
condition: 'party invite',
|
||||
incentiveThreshold: 40,
|
||||
text: t('loginReward', {count: 40}),
|
||||
text: t('loginReward', { count: 40 }),
|
||||
},
|
||||
boss: {
|
||||
name: t('questMoon3Boss'),
|
||||
@@ -3527,9 +3527,7 @@ each(quests, (v, key) => {
|
||||
}
|
||||
});
|
||||
|
||||
let questsByLevel = sortBy(quests, (quest) => {
|
||||
return quest.lvl || 0;
|
||||
});
|
||||
const questsByLevel = sortBy(quests, quest => quest.lvl || 0);
|
||||
|
||||
export {
|
||||
quests,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import t from './translation';
|
||||
import each from 'lodash/each';
|
||||
import t from './translation';
|
||||
import { NotAuthorized } from '../libs/errors';
|
||||
import statsComputed from '../libs/statsComputed';
|
||||
import crit from '../fns/crit';
|
||||
@@ -35,7 +35,7 @@ function calculateBonus (value, stat, critVal = 1, statScale = 0.5) {
|
||||
return (value < 0 ? 1 : value + 1) + stat * statScale * critVal;
|
||||
}
|
||||
|
||||
let spells = {};
|
||||
const spells = {};
|
||||
|
||||
spells.wizard = {
|
||||
fireball: { // Burst of Flames
|
||||
@@ -60,8 +60,8 @@ spells.wizard = {
|
||||
target: 'party',
|
||||
notes: t('spellWizardMPHealNotes'),
|
||||
cast (user, target) {
|
||||
each(target, (member) => {
|
||||
let bonus = statsComputed(user).int;
|
||||
each(target, member => {
|
||||
const bonus = statsComputed(user).int;
|
||||
if (user._id !== member._id && member.stats.class !== 'wizard') {
|
||||
member.stats.mp += Math.ceil(diminishingReturns(bonus, 25, 125));
|
||||
}
|
||||
@@ -75,8 +75,8 @@ spells.wizard = {
|
||||
target: 'party',
|
||||
notes: t('spellWizardEarthNotes'),
|
||||
cast (user, target) {
|
||||
each(target, (member) => {
|
||||
let bonus = statsComputed(user).int - user.stats.buffs.int;
|
||||
each(target, member => {
|
||||
const bonus = statsComputed(user).int - user.stats.buffs.int;
|
||||
if (!member.stats.buffs.int) member.stats.buffs.int = 0;
|
||||
member.stats.buffs.int += Math.ceil(diminishingReturns(bonus, 30, 200));
|
||||
});
|
||||
@@ -102,7 +102,7 @@ spells.warrior = {
|
||||
target: 'task',
|
||||
notes: t('spellWarriorSmashNotes'),
|
||||
cast (user, target) {
|
||||
let bonus = statsComputed(user).str * crit.crit(user, 'con');
|
||||
const bonus = statsComputed(user).str * crit.crit(user, 'con');
|
||||
target.value += diminishingReturns(bonus, 2.5, 35);
|
||||
if (!user.party.quest.progress.up) user.party.quest.progress.up = 0;
|
||||
user.party.quest.progress.up += diminishingReturns(bonus, 55, 70);
|
||||
@@ -115,7 +115,7 @@ spells.warrior = {
|
||||
target: 'self',
|
||||
notes: t('spellWarriorDefensiveStanceNotes'),
|
||||
cast (user) {
|
||||
let bonus = statsComputed(user).con - user.stats.buffs.con;
|
||||
const bonus = statsComputed(user).con - user.stats.buffs.con;
|
||||
if (!user.stats.buffs.con) user.stats.buffs.con = 0;
|
||||
user.stats.buffs.con += Math.ceil(diminishingReturns(bonus, 40, 200));
|
||||
},
|
||||
@@ -127,8 +127,8 @@ spells.warrior = {
|
||||
target: 'party',
|
||||
notes: t('spellWarriorValorousPresenceNotes'),
|
||||
cast (user, target) {
|
||||
each(target, (member) => {
|
||||
let bonus = statsComputed(user).str - user.stats.buffs.str;
|
||||
each(target, member => {
|
||||
const bonus = statsComputed(user).str - user.stats.buffs.str;
|
||||
if (!member.stats.buffs.str) member.stats.buffs.str = 0;
|
||||
member.stats.buffs.str += Math.ceil(diminishingReturns(bonus, 20, 200));
|
||||
});
|
||||
@@ -141,8 +141,8 @@ spells.warrior = {
|
||||
target: 'party',
|
||||
notes: t('spellWarriorIntimidateNotes'),
|
||||
cast (user, target) {
|
||||
each(target, (member) => {
|
||||
let bonus = statsComputed(user).con - user.stats.buffs.con;
|
||||
each(target, member => {
|
||||
const bonus = statsComputed(user).con - user.stats.buffs.con;
|
||||
if (!member.stats.buffs.con) member.stats.buffs.con = 0;
|
||||
member.stats.buffs.con += Math.ceil(diminishingReturns(bonus, 24, 200));
|
||||
});
|
||||
@@ -158,7 +158,7 @@ spells.rogue = {
|
||||
target: 'task',
|
||||
notes: t('spellRoguePickPocketNotes'),
|
||||
cast (user, target) {
|
||||
let bonus = calculateBonus(target.value, statsComputed(user).per);
|
||||
const bonus = calculateBonus(target.value, statsComputed(user).per);
|
||||
user.stats.gp += diminishingReturns(bonus, 25, 75);
|
||||
},
|
||||
},
|
||||
@@ -169,8 +169,8 @@ spells.rogue = {
|
||||
target: 'task',
|
||||
notes: t('spellRogueBackStabNotes'),
|
||||
cast (user, target, req) {
|
||||
let _crit = crit.crit(user, 'str', 0.3);
|
||||
let bonus = calculateBonus(target.value, statsComputed(user).str, _crit);
|
||||
const _crit = crit.crit(user, 'str', 0.3);
|
||||
const bonus = calculateBonus(target.value, statsComputed(user).str, _crit);
|
||||
user.stats.exp += diminishingReturns(bonus, 75, 50);
|
||||
user.stats.gp += diminishingReturns(bonus, 18, 75);
|
||||
updateStats(user, user.stats, req);
|
||||
@@ -183,8 +183,8 @@ spells.rogue = {
|
||||
target: 'party',
|
||||
notes: t('spellRogueToolsOfTradeNotes'),
|
||||
cast (user, target) {
|
||||
each(target, (member) => {
|
||||
let bonus = statsComputed(user).per - user.stats.buffs.per;
|
||||
each(target, member => {
|
||||
const bonus = statsComputed(user).per - user.stats.buffs.per;
|
||||
if (!member.stats.buffs.per) member.stats.buffs.per = 0;
|
||||
member.stats.buffs.per += Math.ceil(diminishingReturns(bonus, 100, 50));
|
||||
});
|
||||
@@ -223,7 +223,7 @@ spells.healer = {
|
||||
target: 'tasks',
|
||||
notes: t('spellHealerBrightnessNotes'),
|
||||
cast (user, tasks) {
|
||||
each(tasks, (task) => {
|
||||
each(tasks, task => {
|
||||
if (task.type !== 'reward') {
|
||||
task.value += 4 * (statsComputed(user).int / (statsComputed(user).int + 40));
|
||||
}
|
||||
@@ -237,8 +237,8 @@ spells.healer = {
|
||||
target: 'party',
|
||||
notes: t('spellHealerProtectAuraNotes'),
|
||||
cast (user, target) {
|
||||
each(target, (member) => {
|
||||
let bonus = statsComputed(user).con - user.stats.buffs.con;
|
||||
each(target, member => {
|
||||
const bonus = statsComputed(user).con - user.stats.buffs.con;
|
||||
if (!member.stats.buffs.con) member.stats.buffs.con = 0;
|
||||
member.stats.buffs.con += Math.ceil(diminishingReturns(bonus, 200, 200));
|
||||
});
|
||||
@@ -251,7 +251,7 @@ spells.healer = {
|
||||
target: 'party',
|
||||
notes: t('spellHealerHealAllNotes'),
|
||||
cast (user, target) {
|
||||
each(target, (member) => {
|
||||
each(target, member => {
|
||||
member.stats.hp += (statsComputed(user).con + statsComputed(user).int + 5) * 0.04;
|
||||
if (member.stats.hp > 50) member.stats.hp = 50;
|
||||
});
|
||||
@@ -397,7 +397,7 @@ spells.special = {
|
||||
if (!user.achievements.nye) user.achievements.nye = 0;
|
||||
user.achievements.nye++;
|
||||
} else {
|
||||
each([user, target], (u) => {
|
||||
each([user, target], u => {
|
||||
if (!u.achievements.nye) u.achievements.nye = 0;
|
||||
u.achievements.nye++;
|
||||
});
|
||||
@@ -407,13 +407,15 @@ spells.special = {
|
||||
const senderName = user.profile.name;
|
||||
target.items.special.nyeReceived.push(senderName);
|
||||
|
||||
if (target.addNotification) target.addNotification('CARD_RECEIVED', {
|
||||
card: 'nye',
|
||||
from: {
|
||||
id: user._id,
|
||||
name: senderName,
|
||||
},
|
||||
});
|
||||
if (target.addNotification) {
|
||||
target.addNotification('CARD_RECEIVED', {
|
||||
card: 'nye',
|
||||
from: {
|
||||
id: user._id,
|
||||
name: senderName,
|
||||
},
|
||||
});
|
||||
}
|
||||
target.flags.cardReceived = true;
|
||||
|
||||
user.stats.gp -= 10;
|
||||
@@ -432,7 +434,7 @@ spells.special = {
|
||||
if (!user.achievements.valentine) user.achievements.valentine = 0;
|
||||
user.achievements.valentine++;
|
||||
} else {
|
||||
each([user, target], (u) => {
|
||||
each([user, target], u => {
|
||||
if (!u.achievements.valentine) u.achievements.valentine = 0;
|
||||
u.achievements.valentine++;
|
||||
});
|
||||
@@ -442,13 +444,15 @@ spells.special = {
|
||||
const senderName = user.profile.name;
|
||||
target.items.special.valentineReceived.push(senderName);
|
||||
|
||||
if (target.addNotification) target.addNotification('CARD_RECEIVED', {
|
||||
card: 'valentine',
|
||||
from: {
|
||||
id: user._id,
|
||||
name: senderName,
|
||||
},
|
||||
});
|
||||
if (target.addNotification) {
|
||||
target.addNotification('CARD_RECEIVED', {
|
||||
card: 'valentine',
|
||||
from: {
|
||||
id: user._id,
|
||||
name: senderName,
|
||||
},
|
||||
});
|
||||
}
|
||||
target.flags.cardReceived = true;
|
||||
|
||||
user.stats.gp -= 10;
|
||||
@@ -467,7 +471,7 @@ spells.special = {
|
||||
if (!user.achievements.greeting) user.achievements.greeting = 0;
|
||||
user.achievements.greeting++;
|
||||
} else {
|
||||
each([user, target], (u) => {
|
||||
each([user, target], u => {
|
||||
if (!u.achievements.greeting) u.achievements.greeting = 0;
|
||||
u.achievements.greeting++;
|
||||
});
|
||||
@@ -477,13 +481,15 @@ spells.special = {
|
||||
const senderName = user.profile.name;
|
||||
target.items.special.greetingReceived.push(senderName);
|
||||
|
||||
if (target.addNotification) target.addNotification('CARD_RECEIVED', {
|
||||
card: 'greeting',
|
||||
from: {
|
||||
id: user._id,
|
||||
name: senderName,
|
||||
},
|
||||
});
|
||||
if (target.addNotification) {
|
||||
target.addNotification('CARD_RECEIVED', {
|
||||
card: 'greeting',
|
||||
from: {
|
||||
id: user._id,
|
||||
name: senderName,
|
||||
},
|
||||
});
|
||||
}
|
||||
target.flags.cardReceived = true;
|
||||
|
||||
user.stats.gp -= 10;
|
||||
@@ -502,7 +508,7 @@ spells.special = {
|
||||
if (!user.achievements.thankyou) user.achievements.thankyou = 0;
|
||||
user.achievements.thankyou++;
|
||||
} else {
|
||||
each([user, target], (u) => {
|
||||
each([user, target], u => {
|
||||
if (!u.achievements.thankyou) u.achievements.thankyou = 0;
|
||||
u.achievements.thankyou++;
|
||||
});
|
||||
@@ -512,13 +518,15 @@ spells.special = {
|
||||
const senderName = user.profile.name;
|
||||
target.items.special.thankyouReceived.push(senderName);
|
||||
|
||||
if (target.addNotification) target.addNotification('CARD_RECEIVED', {
|
||||
card: 'thankyou',
|
||||
from: {
|
||||
id: user._id,
|
||||
name: senderName,
|
||||
},
|
||||
});
|
||||
if (target.addNotification) {
|
||||
target.addNotification('CARD_RECEIVED', {
|
||||
card: 'thankyou',
|
||||
from: {
|
||||
id: user._id,
|
||||
name: senderName,
|
||||
},
|
||||
});
|
||||
}
|
||||
target.flags.cardReceived = true;
|
||||
|
||||
user.stats.gp -= 10;
|
||||
@@ -537,7 +545,7 @@ spells.special = {
|
||||
if (!user.achievements.birthday) user.achievements.birthday = 0;
|
||||
user.achievements.birthday++;
|
||||
} else {
|
||||
each([user, target], (u) => {
|
||||
each([user, target], u => {
|
||||
if (!u.achievements.birthday) u.achievements.birthday = 0;
|
||||
u.achievements.birthday++;
|
||||
});
|
||||
@@ -547,13 +555,15 @@ spells.special = {
|
||||
const senderName = user.profile.name;
|
||||
target.items.special.birthdayReceived.push(senderName);
|
||||
|
||||
if (target.addNotification) target.addNotification('CARD_RECEIVED', {
|
||||
card: 'birthday',
|
||||
from: {
|
||||
id: user._id,
|
||||
name: senderName,
|
||||
},
|
||||
});
|
||||
if (target.addNotification) {
|
||||
target.addNotification('CARD_RECEIVED', {
|
||||
card: 'birthday',
|
||||
from: {
|
||||
id: user._id,
|
||||
name: senderName,
|
||||
},
|
||||
});
|
||||
}
|
||||
target.flags.cardReceived = true;
|
||||
|
||||
user.stats.gp -= 10;
|
||||
@@ -572,7 +582,7 @@ spells.special = {
|
||||
if (!user.achievements.congrats) user.achievements.congrats = 0;
|
||||
user.achievements.congrats++;
|
||||
} else {
|
||||
each([user, target], (u) => {
|
||||
each([user, target], u => {
|
||||
if (!u.achievements.congrats) u.achievements.congrats = 0;
|
||||
u.achievements.congrats++;
|
||||
});
|
||||
@@ -582,13 +592,15 @@ spells.special = {
|
||||
const senderName = user.profile.name;
|
||||
target.items.special.congratsReceived.push(senderName);
|
||||
|
||||
if (target.addNotification) target.addNotification('CARD_RECEIVED', {
|
||||
card: 'congrats',
|
||||
from: {
|
||||
id: user._id,
|
||||
name: senderName,
|
||||
},
|
||||
});
|
||||
if (target.addNotification) {
|
||||
target.addNotification('CARD_RECEIVED', {
|
||||
card: 'congrats',
|
||||
from: {
|
||||
id: user._id,
|
||||
name: senderName,
|
||||
},
|
||||
});
|
||||
}
|
||||
target.flags.cardReceived = true;
|
||||
|
||||
user.stats.gp -= 10;
|
||||
@@ -607,7 +619,7 @@ spells.special = {
|
||||
if (!user.achievements.getwell) user.achievements.getwell = 0;
|
||||
user.achievements.getwell++;
|
||||
} else {
|
||||
each([user, target], (u) => {
|
||||
each([user, target], u => {
|
||||
if (!u.achievements.getwell) u.achievements.getwell = 0;
|
||||
u.achievements.getwell++;
|
||||
});
|
||||
@@ -617,13 +629,15 @@ spells.special = {
|
||||
const senderName = user.profile.name;
|
||||
target.items.special.getwellReceived.push(senderName);
|
||||
|
||||
if (target.addNotification) target.addNotification('CARD_RECEIVED', {
|
||||
card: 'getwell',
|
||||
from: {
|
||||
id: user._id,
|
||||
name: senderName,
|
||||
},
|
||||
});
|
||||
if (target.addNotification) {
|
||||
target.addNotification('CARD_RECEIVED', {
|
||||
card: 'getwell',
|
||||
from: {
|
||||
id: user._id,
|
||||
name: senderName,
|
||||
},
|
||||
});
|
||||
}
|
||||
target.flags.cardReceived = true;
|
||||
|
||||
user.stats.gp -= 10;
|
||||
@@ -642,7 +656,7 @@ spells.special = {
|
||||
if (!user.achievements.goodluck) user.achievements.goodluck = 0;
|
||||
user.achievements.goodluck++;
|
||||
} else {
|
||||
each([user, target], (u) => {
|
||||
each([user, target], u => {
|
||||
if (!u.achievements.goodluck) u.achievements.goodluck = 0;
|
||||
u.achievements.goodluck++;
|
||||
});
|
||||
@@ -652,13 +666,15 @@ spells.special = {
|
||||
const senderName = user.profile.name;
|
||||
target.items.special.goodluckReceived.push(senderName);
|
||||
|
||||
if (target.addNotification) target.addNotification('CARD_RECEIVED', {
|
||||
card: 'goodluck',
|
||||
from: {
|
||||
id: user._id,
|
||||
name: senderName,
|
||||
},
|
||||
});
|
||||
if (target.addNotification) {
|
||||
target.addNotification('CARD_RECEIVED', {
|
||||
card: 'goodluck',
|
||||
from: {
|
||||
id: user._id,
|
||||
name: senderName,
|
||||
},
|
||||
});
|
||||
}
|
||||
target.flags.cardReceived = true;
|
||||
|
||||
user.stats.gp -= 10;
|
||||
@@ -666,10 +682,10 @@ spells.special = {
|
||||
},
|
||||
};
|
||||
|
||||
each(spells, (spellClass) => {
|
||||
each(spells, spellClass => {
|
||||
each(spellClass, (spell, key) => {
|
||||
spell.key = key;
|
||||
let _cast = spell.cast;
|
||||
const _cast = spell.cast;
|
||||
spell.cast = function castSpell (user, target, req) {
|
||||
_cast(user, target, req);
|
||||
user.stats.mp -= spell.mana;
|
||||
|
||||
@@ -10,16 +10,16 @@ import {
|
||||
} from './hatching-potions';
|
||||
import t from './translation';
|
||||
|
||||
let petInfo = {};
|
||||
let mountInfo = {};
|
||||
const petInfo = {};
|
||||
const mountInfo = {};
|
||||
|
||||
function constructSet (type, eggs, potions) {
|
||||
let pets = {};
|
||||
let mounts = {};
|
||||
const pets = {};
|
||||
const mounts = {};
|
||||
|
||||
each(eggs, (egg) => {
|
||||
each(potions, (potion) => {
|
||||
let key = `${egg.key}-${potion.key}`;
|
||||
each(eggs, egg => {
|
||||
each(potions, potion => {
|
||||
const key = `${egg.key}-${potion.key}`;
|
||||
|
||||
function getAnimalData (text) {
|
||||
return {
|
||||
@@ -49,11 +49,11 @@ function constructSet (type, eggs, potions) {
|
||||
}
|
||||
|
||||
function constructPetOnlySet (type, eggs, potions) {
|
||||
let pets = {};
|
||||
const pets = {};
|
||||
|
||||
each(eggs, (egg) => {
|
||||
each(potions, (potion) => {
|
||||
let key = `${egg.key}-${potion.key}`;
|
||||
each(eggs, egg => {
|
||||
each(potions, potion => {
|
||||
const key = `${egg.key}-${potion.key}`;
|
||||
|
||||
function getAnimalData (text) {
|
||||
return {
|
||||
@@ -76,12 +76,12 @@ function constructPetOnlySet (type, eggs, potions) {
|
||||
return pets;
|
||||
}
|
||||
|
||||
let [dropPets, dropMounts] = constructSet('drop', dropEggs, dropPotions);
|
||||
let [premiumPets, premiumMounts] = constructSet('premium', dropEggs, premiumPotions);
|
||||
let [questPets, questMounts] = constructSet('quest', questEggs, dropPotions);
|
||||
let wackyPets = constructPetOnlySet('wacky', dropEggs, wackyPotions);
|
||||
const [dropPets, dropMounts] = constructSet('drop', dropEggs, dropPotions);
|
||||
const [premiumPets, premiumMounts] = constructSet('premium', dropEggs, premiumPotions);
|
||||
const [questPets, questMounts] = constructSet('quest', questEggs, dropPotions);
|
||||
const wackyPets = constructPetOnlySet('wacky', dropEggs, wackyPotions);
|
||||
|
||||
let specialPets = {
|
||||
const specialPets = {
|
||||
'Wolf-Veteran': 'veteranWolf',
|
||||
'Wolf-Cerberus': 'cerberusPup',
|
||||
'Dragon-Hydra': 'hydra',
|
||||
@@ -106,7 +106,7 @@ let specialPets = {
|
||||
'Gryphon-Gryphatrice': 'gryphatrice',
|
||||
};
|
||||
|
||||
let specialMounts = {
|
||||
const specialMounts = {
|
||||
'BearCub-Polar': 'polarBear',
|
||||
'LionCub-Ethereal': 'etherealLion',
|
||||
'MantisShrimp-Base': 'mantisShrimp',
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/* eslint-disable camelcase */
|
||||
import each from 'lodash/each';
|
||||
|
||||
let subscriptionBlocks = {
|
||||
const subscriptionBlocks = {
|
||||
basic_earned: {
|
||||
target: 'user',
|
||||
canSubscribe: true,
|
||||
@@ -50,8 +50,6 @@ let subscriptionBlocks = {
|
||||
},
|
||||
};
|
||||
|
||||
each(subscriptionBlocks, function createKeys (b, k) {
|
||||
return b.key = k;
|
||||
});
|
||||
each(subscriptionBlocks, (b, k) => b.key = k);
|
||||
|
||||
export default subscriptionBlocks;
|
||||
|
||||
@@ -7,19 +7,17 @@ import reduce from 'lodash/reduce';
|
||||
import mysterySets from './mystery-sets';
|
||||
import gear from './gear';
|
||||
|
||||
let mystery = mysterySets;
|
||||
const mystery = mysterySets;
|
||||
|
||||
each(mystery, (v, k) => {
|
||||
return v.items = filter(gear.flat, {
|
||||
mystery: k,
|
||||
});
|
||||
});
|
||||
each(mystery, (v, k) => v.items = filter(gear.flat, {
|
||||
mystery: k,
|
||||
}));
|
||||
|
||||
let timeTravelerStore = (user) => {
|
||||
const timeTravelerStore = user => {
|
||||
let ownedKeys;
|
||||
let owned = user.items.gear.owned;
|
||||
let mysteryItems = user.purchased.plan.mysteryItems;
|
||||
let unopenedGifts = typeof mysteryItems.toObject === 'function' ? mysteryItems.toObject() : mysteryItems;
|
||||
const { owned } = user.items.gear;
|
||||
const { mysteryItems } = user.purchased.plan;
|
||||
const unopenedGifts = typeof mysteryItems.toObject === 'function' ? mysteryItems.toObject() : mysteryItems;
|
||||
ownedKeys = keys(typeof owned.toObject === 'function' ? owned.toObject() : owned);
|
||||
ownedKeys = union(ownedKeys, unopenedGifts);
|
||||
return reduce(mystery, (m, v, k) => {
|
||||
@@ -34,4 +32,4 @@ let timeTravelerStore = (user) => {
|
||||
export default {
|
||||
timeTravelerStore,
|
||||
mystery,
|
||||
};
|
||||
};
|
||||
|
||||
@@ -9,9 +9,8 @@ const DROP_ANIMALS = keys(content.pets);
|
||||
export function beastMasterProgress (pets = {}) {
|
||||
let count = 0;
|
||||
|
||||
each(DROP_ANIMALS, (animal) => {
|
||||
if (pets[animal] > 0 || pets[animal] === -1)
|
||||
count++;
|
||||
each(DROP_ANIMALS, animal => {
|
||||
if (pets[animal] > 0 || pets[animal] === -1) count++;
|
||||
});
|
||||
|
||||
return count;
|
||||
@@ -20,7 +19,7 @@ export function beastMasterProgress (pets = {}) {
|
||||
export function beastCount (pets = {}) {
|
||||
let count = 0;
|
||||
|
||||
each(DROP_ANIMALS, (animal) => {
|
||||
each(DROP_ANIMALS, animal => {
|
||||
if (pets[animal] > 0) count++;
|
||||
});
|
||||
|
||||
@@ -30,9 +29,8 @@ export function beastCount (pets = {}) {
|
||||
export function dropPetsCurrentlyOwned (pets = {}) {
|
||||
let count = 0;
|
||||
|
||||
each(DROP_ANIMALS, (animal) => {
|
||||
if (pets[animal] > 0)
|
||||
count++;
|
||||
each(DROP_ANIMALS, animal => {
|
||||
if (pets[animal] > 0) count++;
|
||||
});
|
||||
|
||||
return count;
|
||||
@@ -41,36 +39,35 @@ export function dropPetsCurrentlyOwned (pets = {}) {
|
||||
export function mountMasterProgress (mounts = {}) {
|
||||
let count = 0;
|
||||
|
||||
each(DROP_ANIMALS, (animal) => {
|
||||
if (mounts[animal])
|
||||
count++;
|
||||
each(DROP_ANIMALS, animal => {
|
||||
if (mounts[animal]) count++;
|
||||
});
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
export function remainingGearInSet (userGear = {}, set) {
|
||||
let gear = filter(content.gear.flat, (item) => {
|
||||
let setMatches = item.klass === set;
|
||||
let hasItem = userGear[item.key];
|
||||
const gear = filter(content.gear.flat, item => {
|
||||
const setMatches = item.klass === set;
|
||||
const hasItem = userGear[item.key];
|
||||
|
||||
return setMatches && !hasItem;
|
||||
});
|
||||
|
||||
let count = size(gear);
|
||||
const count = size(gear);
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
export function questsOfCategory (userQuests = {}, category) {
|
||||
let quests = filter(content.quests, (quest) => {
|
||||
let categoryMatches = quest.category === category;
|
||||
let hasQuest = userQuests[quest.key];
|
||||
const quests = filter(content.quests, quest => {
|
||||
const categoryMatches = quest.category === category;
|
||||
const hasQuest = userQuests[quest.key];
|
||||
|
||||
return categoryMatches && hasQuest;
|
||||
});
|
||||
|
||||
let count = size(quests);
|
||||
const count = size(quests);
|
||||
|
||||
return count;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,11 +28,11 @@ export const DAY_MAPPING_STRING_TO_NUMBER = invert(DAY_MAPPING);
|
||||
*/
|
||||
|
||||
function sanitizeOptions (o) {
|
||||
let ref = Number(o.dayStart || 0);
|
||||
let dayStart = !Number.isNaN(ref) && ref >= 0 && ref <= 24 ? ref : 0;
|
||||
const ref = Number(o.dayStart || 0);
|
||||
const dayStart = !Number.isNaN(ref) && ref >= 0 && ref <= 24 ? ref : 0;
|
||||
|
||||
let timezoneOffset;
|
||||
let timezoneOffsetDefault = Number(moment().zone());
|
||||
const timezoneOffsetDefault = Number(moment().zone());
|
||||
|
||||
if (isFinite(o.timezoneOffsetOverride)) {
|
||||
timezoneOffset = Number(o.timezoneOffsetOverride);
|
||||
@@ -46,7 +46,7 @@ function sanitizeOptions (o) {
|
||||
timezoneOffset = timezoneOffsetDefault;
|
||||
}
|
||||
|
||||
let now = o.now ? moment(o.now).zone(timezoneOffset) : moment().zone(timezoneOffset);
|
||||
const now = o.now ? moment(o.now).zone(timezoneOffset) : moment().zone(timezoneOffset);
|
||||
// return a new object, we don't want to add "now" to user object
|
||||
return {
|
||||
dayStart,
|
||||
@@ -56,7 +56,7 @@ function sanitizeOptions (o) {
|
||||
}
|
||||
|
||||
export function startOfWeek (options = {}) {
|
||||
let o = sanitizeOptions(options);
|
||||
const o = sanitizeOptions(options);
|
||||
|
||||
return moment(o.now).startOf('week');
|
||||
}
|
||||
@@ -69,8 +69,8 @@ export function startOfWeek (options = {}) {
|
||||
*/
|
||||
|
||||
export function startOfDay (options = {}) {
|
||||
let o = sanitizeOptions(options);
|
||||
let dayStart = moment(o.now).startOf('day').add({ hours: o.dayStart });
|
||||
const o = sanitizeOptions(options);
|
||||
const dayStart = moment(o.now).startOf('day').add({ hours: o.dayStart });
|
||||
|
||||
if (moment(o.now).hour() < o.dayStart) {
|
||||
dayStart.subtract({ days: 1 });
|
||||
@@ -84,9 +84,9 @@ export function startOfDay (options = {}) {
|
||||
*/
|
||||
|
||||
export function daysSince (yesterday, options = {}) {
|
||||
let o = sanitizeOptions(options);
|
||||
let startOfNow = startOfDay(defaults({ now: o.now }, o));
|
||||
let startOfYesterday = startOfDay(defaults({ now: yesterday }, o));
|
||||
const o = sanitizeOptions(options);
|
||||
const startOfNow = startOfDay(defaults({ now: o.now }, o));
|
||||
const startOfYesterday = startOfDay(defaults({ now: yesterday }, o));
|
||||
|
||||
return startOfNow.diff(startOfYesterday, 'days');
|
||||
}
|
||||
@@ -99,22 +99,22 @@ export function shouldDo (day, dailyTask, options = {}) {
|
||||
if (dailyTask.type !== 'daily' || dailyTask.startDate === null || dailyTask.everyX < 1 || dailyTask.everyX > 9999) {
|
||||
return false;
|
||||
}
|
||||
let o = sanitizeOptions(options);
|
||||
let startOfDayWithCDSTime = startOfDay(defaults({ now: day }, o));
|
||||
const o = sanitizeOptions(options);
|
||||
const startOfDayWithCDSTime = startOfDay(defaults({ now: day }, o));
|
||||
|
||||
// The time portion of the Start Date is never visible to or modifiable by the user so we must ignore it.
|
||||
// Therefore, we must also ignore the time portion of the user's day start (startOfDayWithCDSTime), otherwise the date comparison will be wrong for some times.
|
||||
// NB: The user's day start date has already been converted to the PREVIOUS day's date if the time portion was before CDS.
|
||||
|
||||
let startDate = moment(dailyTask.startDate).zone(o.timezoneOffset).startOf('day');
|
||||
const startDate = moment(dailyTask.startDate).zone(o.timezoneOffset).startOf('day');
|
||||
|
||||
if (startDate > startOfDayWithCDSTime.startOf('day') && !options.nextDue) {
|
||||
return false; // Daily starts in the future
|
||||
}
|
||||
|
||||
let daysOfTheWeek = [];
|
||||
const daysOfTheWeek = [];
|
||||
if (dailyTask.repeat) {
|
||||
for (let [repeatDay, active] of Object.entries(dailyTask.repeat)) {
|
||||
for (const [repeatDay, active] of Object.entries(dailyTask.repeat)) {
|
||||
if (!isFinite(DAY_MAPPING_STRING_TO_NUMBER[repeatDay])) continue; // eslint-disable-line no-continue
|
||||
if (active) daysOfTheWeek.push(parseInt(DAY_MAPPING_STRING_TO_NUMBER[repeatDay], 10));
|
||||
}
|
||||
@@ -122,36 +122,36 @@ export function shouldDo (day, dailyTask, options = {}) {
|
||||
|
||||
if (dailyTask.frequency === 'daily') {
|
||||
if (!dailyTask.everyX) return false; // error condition
|
||||
let schedule = moment(startDate).recur()
|
||||
const schedule = moment(startDate).recur()
|
||||
.every(dailyTask.everyX).days();
|
||||
|
||||
if (options.nextDue) {
|
||||
let filteredDates = [];
|
||||
const filteredDates = [];
|
||||
for (let i = 1; filteredDates.length < 6; i++) {
|
||||
let calcDate = moment(startDate).add(dailyTask.everyX * i, 'days');
|
||||
const calcDate = moment(startDate).add(dailyTask.everyX * i, 'days');
|
||||
if (calcDate > startOfDayWithCDSTime) filteredDates.push(calcDate);
|
||||
}
|
||||
return filteredDates;
|
||||
}
|
||||
|
||||
return schedule.matches(startOfDayWithCDSTime);
|
||||
} else if (dailyTask.frequency === 'weekly') {
|
||||
} if (dailyTask.frequency === 'weekly') {
|
||||
let schedule = moment(startDate).recur();
|
||||
|
||||
let differenceInWeeks = moment(startOfDayWithCDSTime).diff(moment(startDate), 'week');
|
||||
let matchEveryX = differenceInWeeks % dailyTask.everyX === 0;
|
||||
const differenceInWeeks = moment(startOfDayWithCDSTime).diff(moment(startDate), 'week');
|
||||
const matchEveryX = differenceInWeeks % dailyTask.everyX === 0;
|
||||
|
||||
if (daysOfTheWeek.length === 0) return false;
|
||||
schedule = schedule.every(daysOfTheWeek).daysOfWeek();
|
||||
if (options.nextDue) {
|
||||
let filteredDates = [];
|
||||
const filteredDates = [];
|
||||
for (let i = 0; filteredDates.length < 6; i++) {
|
||||
for (let j = 0; j < daysOfTheWeek.length && filteredDates.length < 6; j++) {
|
||||
let calcDate = moment(startDate).day(daysOfTheWeek[j]).add(dailyTask.everyX * i, 'weeks');
|
||||
const calcDate = moment(startDate).day(daysOfTheWeek[j]).add(dailyTask.everyX * i, 'weeks');
|
||||
if (calcDate > startOfDayWithCDSTime) filteredDates.push(calcDate);
|
||||
}
|
||||
}
|
||||
let sortedDates = filteredDates.sort((date1, date2) => {
|
||||
const sortedDates = filteredDates.sort((date1, date2) => {
|
||||
if (date1.toDate() > date2.toDate()) return 1;
|
||||
if (date2.toDate() > date1.toDate()) return -1;
|
||||
return 0;
|
||||
@@ -160,15 +160,15 @@ export function shouldDo (day, dailyTask, options = {}) {
|
||||
}
|
||||
|
||||
return schedule.matches(startOfDayWithCDSTime) && matchEveryX;
|
||||
} else if (dailyTask.frequency === 'monthly') {
|
||||
} if (dailyTask.frequency === 'monthly') {
|
||||
let schedule = moment(startDate).recur();
|
||||
|
||||
// Use startOf to ensure that we are always comparing month
|
||||
// to the next rather than a month from the day
|
||||
let differenceInMonths = moment(startOfDayWithCDSTime).startOf('month')
|
||||
const differenceInMonths = moment(startOfDayWithCDSTime).startOf('month')
|
||||
.diff(moment(startDate).startOf('month'), 'month', true);
|
||||
|
||||
let matchEveryX = differenceInMonths % dailyTask.everyX === 0;
|
||||
const matchEveryX = differenceInMonths % dailyTask.everyX === 0;
|
||||
|
||||
if (dailyTask.weeksOfMonth && dailyTask.weeksOfMonth.length > 0) {
|
||||
if (daysOfTheWeek.length === 0) return false;
|
||||
@@ -176,13 +176,13 @@ export function shouldDo (day, dailyTask, options = {}) {
|
||||
.every(dailyTask.weeksOfMonth).weeksOfMonthByDay();
|
||||
|
||||
if (options.nextDue) {
|
||||
let filteredDates = [];
|
||||
const filteredDates = [];
|
||||
for (let i = 1; filteredDates.length < 6; i++) {
|
||||
let recurDate = moment(startDate).add(dailyTask.everyX * i, 'months');
|
||||
let calcDate = recurDate.clone();
|
||||
const recurDate = moment(startDate).add(dailyTask.everyX * i, 'months');
|
||||
const calcDate = recurDate.clone();
|
||||
calcDate.day(daysOfTheWeek[0]);
|
||||
|
||||
let startDateWeek = Math.ceil(moment(startDate).date() / 7);
|
||||
const startDateWeek = Math.ceil(moment(startDate).date() / 7);
|
||||
let calcDateWeek = Math.ceil(calcDate.date() / 7);
|
||||
|
||||
// adjust week since weeks will rollover to other months
|
||||
@@ -193,19 +193,19 @@ export function shouldDo (day, dailyTask, options = {}) {
|
||||
|
||||
calcDateWeek = Math.ceil(calcDate.date() / 7);
|
||||
|
||||
if (calcDate >= startOfDayWithCDSTime &&
|
||||
calcDateWeek === startDateWeek && calcDate.month() === recurDate.month()) filteredDates.push(calcDate);
|
||||
if (calcDate >= startOfDayWithCDSTime
|
||||
&& calcDateWeek === startDateWeek && calcDate.month() === recurDate.month()) filteredDates.push(calcDate);
|
||||
}
|
||||
return filteredDates;
|
||||
}
|
||||
|
||||
return schedule.matches(startOfDayWithCDSTime) && matchEveryX;
|
||||
} else if (dailyTask.daysOfMonth && dailyTask.daysOfMonth.length > 0) {
|
||||
} if (dailyTask.daysOfMonth && dailyTask.daysOfMonth.length > 0) {
|
||||
schedule = schedule.every(dailyTask.daysOfMonth).daysOfMonth();
|
||||
if (options.nextDue) {
|
||||
let filteredDates = [];
|
||||
const filteredDates = [];
|
||||
for (let i = 1; filteredDates.length < 6; i++) {
|
||||
let calcDate = moment(startDate).add(dailyTask.everyX * i, 'months');
|
||||
const calcDate = moment(startDate).add(dailyTask.everyX * i, 'months');
|
||||
if (calcDate >= startOfDayWithCDSTime) filteredDates.push(calcDate);
|
||||
}
|
||||
return filteredDates;
|
||||
@@ -213,15 +213,15 @@ export function shouldDo (day, dailyTask, options = {}) {
|
||||
}
|
||||
|
||||
return schedule.matches(startOfDayWithCDSTime) && matchEveryX;
|
||||
} else if (dailyTask.frequency === 'yearly') {
|
||||
} if (dailyTask.frequency === 'yearly') {
|
||||
let schedule = moment(startDate).recur();
|
||||
|
||||
schedule = schedule.every(dailyTask.everyX).years();
|
||||
|
||||
if (options.nextDue) {
|
||||
let filteredDates = [];
|
||||
const filteredDates = [];
|
||||
for (let i = 1; filteredDates.length < 6; i++) {
|
||||
let calcDate = moment(startDate).add(dailyTask.everyX * i, 'years');
|
||||
const calcDate = moment(startDate).add(dailyTask.everyX * i, 'years');
|
||||
if (calcDate > startOfDayWithCDSTime) filteredDates.push(calcDate);
|
||||
}
|
||||
return filteredDates;
|
||||
|
||||
@@ -16,17 +16,17 @@ import splitWhitespace from '../libs/splitWhitespace';
|
||||
function getStatToAllocate (user) {
|
||||
let suggested;
|
||||
|
||||
let statsObj = user.stats.toObject ? user.stats.toObject() : user.stats;
|
||||
const statsObj = user.stats.toObject ? user.stats.toObject() : user.stats;
|
||||
|
||||
switch (user.preferences.allocationMode) {
|
||||
case 'flat': {
|
||||
let stats = pick(statsObj, splitWhitespace('con str per int'));
|
||||
const stats = pick(statsObj, splitWhitespace('con str per int'));
|
||||
return invert(stats)[min(values(stats))];
|
||||
}
|
||||
case 'classbased': {
|
||||
let preference;
|
||||
let lvlDiv7 = statsObj.lvl / 7;
|
||||
let ideal = [lvlDiv7 * 3, lvlDiv7 * 2, lvlDiv7, lvlDiv7];
|
||||
const lvlDiv7 = statsObj.lvl / 7;
|
||||
const ideal = [lvlDiv7 * 3, lvlDiv7 * 2, lvlDiv7, lvlDiv7];
|
||||
|
||||
switch (statsObj.class) {
|
||||
case 'wizard': {
|
||||
@@ -46,14 +46,14 @@ function getStatToAllocate (user) {
|
||||
}
|
||||
}
|
||||
|
||||
let diff = [
|
||||
const diff = [
|
||||
statsObj[preference[0]] - ideal[0],
|
||||
statsObj[preference[1]] - ideal[1],
|
||||
statsObj[preference[2]] - ideal[2],
|
||||
statsObj[preference[3]] - ideal[3],
|
||||
];
|
||||
|
||||
suggested = findIndex(diff, (val) => {
|
||||
suggested = findIndex(diff, val => {
|
||||
if (val === min(diff)) return true;
|
||||
});
|
||||
|
||||
@@ -76,7 +76,7 @@ function getStatToAllocate (user) {
|
||||
}
|
||||
|
||||
export default function autoAllocate (user) {
|
||||
let statToIncrease = getStatToAllocate(user);
|
||||
const statToIncrease = getStatToAllocate(user);
|
||||
|
||||
return user.stats[statToIncrease]++;
|
||||
}
|
||||
|
||||
@@ -2,12 +2,11 @@ import predictableRandom from './predictableRandom';
|
||||
import statsComputed from '../libs/statsComputed';
|
||||
|
||||
function crit (user, stat = 'str', chance = 0.03) {
|
||||
let s = statsComputed(user)[stat];
|
||||
const s = statsComputed(user)[stat];
|
||||
if (predictableRandom(user) <= chance * (1 + s / 100)) {
|
||||
return 1.5 + 4 * s / (s + 200);
|
||||
} else {
|
||||
return 1;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
export default { crit };
|
||||
|
||||
@@ -2,8 +2,8 @@ import content from '../content/index';
|
||||
import i18n from '../i18n';
|
||||
|
||||
export default function handleTwoHanded (user, item, type = 'equipped', req = {}) {
|
||||
let currentShield = content.gear.flat[user.items.gear[type].shield];
|
||||
let currentWeapon = content.gear.flat[user.items.gear[type].weapon];
|
||||
const currentShield = content.gear.flat[user.items.gear[type].shield];
|
||||
const currentWeapon = content.gear.flat[user.items.gear[type].weapon];
|
||||
|
||||
let message;
|
||||
|
||||
|
||||
@@ -15,12 +15,11 @@ export default function predictableRandom (user, seed) {
|
||||
seed = reduce(stats, (accumulator, val) => {
|
||||
if (isNumber(val)) {
|
||||
return accumulator + val;
|
||||
} else {
|
||||
return accumulator;
|
||||
}
|
||||
return accumulator;
|
||||
}, 0);
|
||||
}
|
||||
|
||||
let x = Math.sin(seed++) * 10000;
|
||||
const x = Math.sin(seed++) * 10000;
|
||||
return x - Math.floor(x);
|
||||
}
|
||||
|
||||
@@ -16,9 +16,8 @@ import statsComputed from '../libs/statsComputed';
|
||||
|
||||
// Clone a drop object maintaining its functions so that we can change it without affecting the original item
|
||||
function cloneDropItem (drop) {
|
||||
return cloneDeepWith(drop, (val) => {
|
||||
return isFunction(val) ? val : undefined; // undefined will be handled by lodash
|
||||
});
|
||||
return cloneDeepWith(drop, val => (isFunction(val) ? val : undefined), // undefined will be handled by lodash
|
||||
);
|
||||
}
|
||||
|
||||
function trueRandom () {
|
||||
@@ -31,19 +30,19 @@ export default function randomDrop (user, options, req = {}, analytics) {
|
||||
let dropMultiplier;
|
||||
let rarity;
|
||||
|
||||
let predictableRandom = options.predictableRandom || trueRandom;
|
||||
let task = options.task;
|
||||
const predictableRandom = options.predictableRandom || trueRandom;
|
||||
const { task } = options;
|
||||
|
||||
let chance = min([Math.abs(task.value - 21.27), 37.5]) / 150 + 0.02;
|
||||
chance *= task.priority * // Task priority: +50% for Medium, +100% for Hard
|
||||
(1 + (task.streak / 100 || 0)) * // Streak bonus: +1% per streak
|
||||
(1 + statsComputed(user).per / 100) * // PERception: +1% per point
|
||||
(1 + (user.contributor.level / 40 || 0)) * // Contrib levels: +2.5% per level
|
||||
(1 + (user.achievements.rebirths / 20 || 0)) * // Rebirths: +5% per achievement
|
||||
(1 + (user.achievements.streak / 200 || 0)) * // Streak achievements: +0.5% per achievement
|
||||
(user._tmp.crit || 1) * (1 + 0.5 * (reduce(task.checklist, (m, i) => { // +50% per checklist item complete. TODO: make this into X individual drop chances instead
|
||||
return m + (i.completed ? 1 : 0); // eslint-disable-line indent
|
||||
}, 0) || 0)); // eslint-disable-line indent
|
||||
chance *= task.priority // Task priority: +50% for Medium, +100% for Hard
|
||||
* (1 + (task.streak / 100 || 0)) // Streak bonus: +1% per streak
|
||||
* (1 + statsComputed(user).per / 100) // PERception: +1% per point
|
||||
* (1 + (user.contributor.level / 40 || 0)) // Contrib levels: +2.5% per level
|
||||
* (1 + (user.achievements.rebirths / 20 || 0)) // Rebirths: +5% per achievement
|
||||
* (1 + (user.achievements.streak / 200 || 0)) // Streak achievements: +0.5% per achievement
|
||||
* (user._tmp.crit || 1) * (1 + 0.5 * (reduce(task.checklist, (m, i) => // +50% per checklist item complete. TODO: make this into X individual drop chances instead
|
||||
m + (i.completed ? 1 : 0), // eslint-disable-line indent
|
||||
0) || 0)); // eslint-disable-line indent
|
||||
chance = diminishingReturns(chance, 0.75);
|
||||
|
||||
if (predictableRandom() < chance) {
|
||||
@@ -60,8 +59,8 @@ export default function randomDrop (user, options, req = {}, analytics) {
|
||||
dropMultiplier = 1;
|
||||
}
|
||||
|
||||
if (daysSince(user.items.lastDrop.date, user.preferences) === 0 &&
|
||||
user.items.lastDrop.count >= dropMultiplier * (5 + Math.floor(statsComputed(user).per / 25) + (user.contributor.level || 0))) {
|
||||
if (daysSince(user.items.lastDrop.date, user.preferences) === 0
|
||||
&& user.items.lastDrop.count >= dropMultiplier * (5 + Math.floor(statsComputed(user).per / 25) + (user.contributor.level || 0))) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -104,9 +103,7 @@ export default function randomDrop (user, options, req = {}, analytics) {
|
||||
} else { // common, 40% of 30%
|
||||
acceptableDrops = ['Base', 'White', 'Desert'];
|
||||
}
|
||||
drop = cloneDropItem(randomVal(pickBy(content.hatchingPotions, (v, k) => {
|
||||
return acceptableDrops.indexOf(k) >= 0;
|
||||
})));
|
||||
drop = cloneDropItem(randomVal(pickBy(content.hatchingPotions, (v, k) => acceptableDrops.indexOf(k) >= 0)));
|
||||
|
||||
user.items.hatchingPotions[drop.key] = user.items.hatchingPotions[drop.key] || 0;
|
||||
user.items.hatchingPotions[drop.key]++;
|
||||
|
||||
@@ -2,9 +2,9 @@ import each from 'lodash/each';
|
||||
import content from '../content/index';
|
||||
|
||||
export default function resetGear (user) {
|
||||
let gear = user.items.gear;
|
||||
const { gear } = user.items;
|
||||
|
||||
each(['equipped', 'costume'], function resetUserGear (type) {
|
||||
each(['equipped', 'costume'], type => {
|
||||
gear[type] = {};
|
||||
gear[type].armor = 'armor_base_0';
|
||||
gear[type].weapon = 'weapon_warrior_0';
|
||||
@@ -14,7 +14,7 @@ export default function resetGear (user) {
|
||||
|
||||
// Gear.owned is (was) a Mongo object so the _.each function iterates over hidden properties.
|
||||
// The content.gear.flat[k] check should prevent this causing an error
|
||||
each(gear.owned, function resetOwnedGear (v, k) {
|
||||
each(gear.owned, (v, k) => {
|
||||
if (gear.owned[k] && content.gear.flat[k] && content.gear.flat[k].value) {
|
||||
gear.owned[k] = false;
|
||||
}
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
import content from '../content/index';
|
||||
import lodashFind from 'lodash/find';
|
||||
import reduce from 'lodash/reduce';
|
||||
import includes from 'lodash/includes';
|
||||
import content from '../content/index';
|
||||
|
||||
export default function ultimateGear (user) {
|
||||
let owned = user.items.gear.owned.toObject ? user.items.gear.owned.toObject() : user.items.gear.owned;
|
||||
const owned = user.items.gear.owned.toObject ? user.items.gear.owned.toObject() : user.items.gear.owned;
|
||||
|
||||
content.classes.forEach((klass) => {
|
||||
content.classes.forEach(klass => {
|
||||
if (user.achievements.ultimateGearSets[klass] !== true) {
|
||||
user.achievements.ultimateGearSets[klass] = reduce(['armor', 'shield', 'head', 'weapon'], (soFarGood, type) => {
|
||||
let found = lodashFind(content.gear.tree[type][klass], {
|
||||
const found = lodashFind(content.gear.tree[type][klass], {
|
||||
last: true,
|
||||
});
|
||||
return soFarGood && (!found || owned[found.key] === true);
|
||||
@@ -28,11 +28,9 @@ export default function ultimateGear (user) {
|
||||
ultimateGearSetValues = Object.values(user.achievements.ultimateGearSets);
|
||||
}
|
||||
|
||||
let hasFullSet = includes(ultimateGearSetValues, true);
|
||||
const hasFullSet = includes(ultimateGearSetValues, true);
|
||||
|
||||
if (hasFullSet && user.flags.armoireEnabled !== true) {
|
||||
user.flags.armoireEnabled = true;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ function t (stringName) {
|
||||
locale = arguments[2];
|
||||
}
|
||||
|
||||
let i18nNotSetup = !i18n.strings && !i18n.translations[locale];
|
||||
const i18nNotSetup = !i18n.strings && !i18n.translations[locale];
|
||||
|
||||
if (!locale || i18nNotSetup) {
|
||||
locale = 'en';
|
||||
@@ -33,7 +33,7 @@ function t (stringName) {
|
||||
string = i18n.translations[locale] && i18n.translations[locale][stringName];
|
||||
}
|
||||
|
||||
let clonedVars = clone(vars) || {};
|
||||
const clonedVars = clone(vars) || {};
|
||||
|
||||
clonedVars.locale = locale;
|
||||
|
||||
|
||||
@@ -1,20 +1,12 @@
|
||||
// When using a common module from the website or the server NEVER import the module directly
|
||||
// but access it through `api` (the main common) module, otherwise you would require the non transpiled version of the file in production.
|
||||
const api = {};
|
||||
|
||||
import content from './content/index';
|
||||
api.content = content;
|
||||
|
||||
import * as errors from './libs/errors';
|
||||
api.errors = errors;
|
||||
import i18n from './i18n';
|
||||
api.i18n = i18n;
|
||||
|
||||
// TODO under api.libs.cron?
|
||||
import { shouldDo, daysSince, DAY_MAPPING } from './cron';
|
||||
api.shouldDo = shouldDo;
|
||||
api.daysSince = daysSince;
|
||||
api.DAY_MAPPING = DAY_MAPPING;
|
||||
|
||||
import {
|
||||
MAX_HEALTH,
|
||||
@@ -34,90 +26,48 @@ import {
|
||||
CHAT_FLAG_FROM_SHADOW_MUTE,
|
||||
} from './constants';
|
||||
|
||||
api.constants = {
|
||||
MAX_INCENTIVES,
|
||||
LARGE_GROUP_COUNT_MESSAGE_CUTOFF,
|
||||
MAX_SUMMARY_SIZE_FOR_GUILDS,
|
||||
MAX_SUMMARY_SIZE_FOR_CHALLENGES,
|
||||
MIN_SHORTNAME_SIZE_FOR_CHALLENGES,
|
||||
SUPPORTED_SOCIAL_NETWORKS,
|
||||
GUILDS_PER_PAGE,
|
||||
PARTY_LIMIT_MEMBERS,
|
||||
CHAT_FLAG_LIMIT_FOR_HIDING,
|
||||
CHAT_FLAG_FROM_MOD,
|
||||
CHAT_FLAG_FROM_SHADOW_MUTE,
|
||||
};
|
||||
// TODO Move these under api.constants
|
||||
api.maxLevel = MAX_LEVEL;
|
||||
api.maxHealth = MAX_HEALTH;
|
||||
api.maxStatPoints = MAX_STAT_POINTS;
|
||||
api.TAVERN_ID = TAVERN_ID;
|
||||
|
||||
// TODO under api.libs.statHelpers?
|
||||
import * as statHelpers from './statHelpers';
|
||||
api.capByLevel = statHelpers.capByLevel;
|
||||
api.tnl = statHelpers.toNextLevel;
|
||||
api.diminishingReturns = statHelpers.diminishingReturns;
|
||||
|
||||
import splitWhitespace from './libs/splitWhitespace';
|
||||
api.$w = splitWhitespace;
|
||||
|
||||
import refPush from './libs/refPush';
|
||||
api.refPush = refPush;
|
||||
|
||||
import planGemLimits from './libs/planGemLimits';
|
||||
api.planGemLimits = planGemLimits;
|
||||
|
||||
import preenTodos from './libs/preenTodos';
|
||||
api.preenTodos = preenTodos;
|
||||
|
||||
import updateStore from './libs/updateStore';
|
||||
api.updateStore = updateStore;
|
||||
|
||||
import inAppRewards from './libs/inAppRewards';
|
||||
api.inAppRewards = inAppRewards;
|
||||
|
||||
import uuid from './libs/uuid';
|
||||
api.uuid = uuid;
|
||||
|
||||
import taskDefaults from './libs/taskDefaults';
|
||||
api.taskDefaults = taskDefaults;
|
||||
|
||||
import percent from './libs/percent';
|
||||
api.percent = percent;
|
||||
|
||||
import gold from './libs/gold';
|
||||
api.gold = gold;
|
||||
|
||||
import silver from './libs/silver';
|
||||
api.silver = silver;
|
||||
|
||||
import noTags from './libs/noTags';
|
||||
api.noTags = noTags;
|
||||
|
||||
import appliedTags from './libs/appliedTags';
|
||||
api.appliedTags = appliedTags;
|
||||
|
||||
import pickDeep from './libs/pickDeep';
|
||||
api.pickDeep = pickDeep;
|
||||
|
||||
import * as count from './count';
|
||||
api.count = count;
|
||||
|
||||
import statsComputed from './libs/statsComputed';
|
||||
api.statsComputed = statsComputed;
|
||||
|
||||
import shops from './libs/shops';
|
||||
api.shops = shops;
|
||||
|
||||
import achievements from './libs/achievements';
|
||||
api.achievements = achievements;
|
||||
|
||||
import randomVal from './libs/randomVal';
|
||||
api.randomVal = randomVal;
|
||||
|
||||
import hasClass from './libs/hasClass';
|
||||
api.hasClass = hasClass;
|
||||
|
||||
import autoAllocate from './fns/autoAllocate';
|
||||
import crit from './fns/crit';
|
||||
@@ -128,17 +78,6 @@ import resetGear from './fns/resetGear';
|
||||
import ultimateGear from './fns/ultimateGear';
|
||||
import updateStats from './fns/updateStats';
|
||||
|
||||
api.fns = {
|
||||
autoAllocate,
|
||||
crit,
|
||||
handleTwoHanded,
|
||||
predictableRandom,
|
||||
randomDrop,
|
||||
resetGear,
|
||||
ultimateGear,
|
||||
updateStats,
|
||||
};
|
||||
|
||||
import scoreTask from './ops/scoreTask';
|
||||
import sleep from './ops/sleep';
|
||||
import allocateNow from './ops/stats/allocateNow';
|
||||
@@ -166,6 +105,67 @@ import reset from './ops/reset';
|
||||
import markPmsRead from './ops/markPMSRead';
|
||||
import * as pinnedGearUtils from './ops/pinnedGearUtils';
|
||||
|
||||
const api = {};
|
||||
api.content = content;
|
||||
api.errors = errors;
|
||||
api.i18n = i18n;
|
||||
api.shouldDo = shouldDo;
|
||||
api.daysSince = daysSince;
|
||||
api.DAY_MAPPING = DAY_MAPPING;
|
||||
|
||||
api.constants = {
|
||||
MAX_INCENTIVES,
|
||||
LARGE_GROUP_COUNT_MESSAGE_CUTOFF,
|
||||
MAX_SUMMARY_SIZE_FOR_GUILDS,
|
||||
MAX_SUMMARY_SIZE_FOR_CHALLENGES,
|
||||
MIN_SHORTNAME_SIZE_FOR_CHALLENGES,
|
||||
SUPPORTED_SOCIAL_NETWORKS,
|
||||
GUILDS_PER_PAGE,
|
||||
PARTY_LIMIT_MEMBERS,
|
||||
CHAT_FLAG_LIMIT_FOR_HIDING,
|
||||
CHAT_FLAG_FROM_MOD,
|
||||
CHAT_FLAG_FROM_SHADOW_MUTE,
|
||||
};
|
||||
// TODO Move these under api.constants
|
||||
api.maxLevel = MAX_LEVEL;
|
||||
api.maxHealth = MAX_HEALTH;
|
||||
api.maxStatPoints = MAX_STAT_POINTS;
|
||||
api.TAVERN_ID = TAVERN_ID;
|
||||
api.capByLevel = statHelpers.capByLevel;
|
||||
api.tnl = statHelpers.toNextLevel;
|
||||
api.diminishingReturns = statHelpers.diminishingReturns;
|
||||
api.$w = splitWhitespace;
|
||||
api.refPush = refPush;
|
||||
api.planGemLimits = planGemLimits;
|
||||
api.preenTodos = preenTodos;
|
||||
api.updateStore = updateStore;
|
||||
api.inAppRewards = inAppRewards;
|
||||
api.uuid = uuid;
|
||||
api.taskDefaults = taskDefaults;
|
||||
api.percent = percent;
|
||||
api.gold = gold;
|
||||
api.silver = silver;
|
||||
api.noTags = noTags;
|
||||
api.appliedTags = appliedTags;
|
||||
api.pickDeep = pickDeep;
|
||||
api.count = count;
|
||||
api.statsComputed = statsComputed;
|
||||
api.shops = shops;
|
||||
api.achievements = achievements;
|
||||
api.randomVal = randomVal;
|
||||
api.hasClass = hasClass;
|
||||
|
||||
api.fns = {
|
||||
autoAllocate,
|
||||
crit,
|
||||
handleTwoHanded,
|
||||
predictableRandom,
|
||||
randomDrop,
|
||||
resetGear,
|
||||
ultimateGear,
|
||||
updateStats,
|
||||
};
|
||||
|
||||
api.ops = {
|
||||
scoreTask,
|
||||
sleep,
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
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 (backer && backer.npc) return backer.npc;
|
||||
let lvl = contrib && contrib.level;
|
||||
const lvl = contrib && contrib.level;
|
||||
if (lvl && lvl > 0) {
|
||||
let contribTitle = '';
|
||||
|
||||
@@ -44,11 +44,11 @@ function _add (result, data) {
|
||||
}
|
||||
|
||||
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 +64,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 +80,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 +102,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 +119,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 +137,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 +152,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 +172,44 @@ 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 });
|
||||
|
||||
_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 +217,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 +235,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 +285,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 +309,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),
|
||||
|
||||
@@ -5,10 +5,6 @@ Are there tags applied?
|
||||
// TODO move to client
|
||||
|
||||
export default function appliedTags (userTags, taskTags = []) {
|
||||
let arr = userTags.filter(tag => {
|
||||
return taskTags.indexOf(tag.id) !== -1;
|
||||
}).map(tag => {
|
||||
return tag.name;
|
||||
});
|
||||
const arr = userTags.filter(tag => taskTags.indexOf(tag.id) !== -1).map(tag => tag.name);
|
||||
return arr.join(', ');
|
||||
}
|
||||
|
||||
@@ -6,10 +6,10 @@ import _template from 'lodash/template';
|
||||
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,11 +1,11 @@
|
||||
import content from '../content/index';
|
||||
import get from 'lodash/get';
|
||||
import content from '../content/index';
|
||||
|
||||
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,
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import _mapValues from 'lodash/mapValues';
|
||||
import i18n from '../i18n';
|
||||
import content from '../content/index';
|
||||
import { BadRequest } from './errors';
|
||||
@@ -7,7 +8,6 @@ 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,9 +20,7 @@ function lockQuest (quest, user) {
|
||||
}
|
||||
|
||||
function isItemSuggested (officialPinnedItems, itemInfo) {
|
||||
return officialPinnedItems.findIndex(officialItem => {
|
||||
return officialItem.type === itemInfo.pinType && officialItem.path === itemInfo.path;
|
||||
}) > -1;
|
||||
return officialPinnedItems.findIndex(officialItem => officialItem.type === itemInfo.pinType && officialItem.path === itemInfo.path) > -1;
|
||||
}
|
||||
|
||||
function getDefaultGearProps (item, language) {
|
||||
@@ -57,7 +55,7 @@ export default function getItemInfo (user, type, item, officialPinnedItems, lang
|
||||
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 +69,7 @@ export default function getItemInfo (user, type, item, officialPinnedItems, lang
|
||||
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 +83,7 @@ export default function getItemInfo (user, type, item, officialPinnedItems, lang
|
||||
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,
|
||||
@@ -137,12 +135,10 @@ export default function getItemInfo (user, type, item, officialPinnedItems, lang
|
||||
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',
|
||||
@@ -264,7 +260,7 @@ export default function getItemInfo (user, type, item, officialPinnedItems, lang
|
||||
};
|
||||
break;
|
||||
case 'card': {
|
||||
let spellInfo = content.spells.special[item.key];
|
||||
const spellInfo = content.spells.special[item.key];
|
||||
|
||||
itemInfo = {
|
||||
key: item.key,
|
||||
@@ -347,7 +343,7 @@ export default function getItemInfo (user, type, item, officialPinnedItems, lang
|
||||
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,22 +1,20 @@
|
||||
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);
|
||||
|
||||
export default function getOfficialPinnedItems (user) {
|
||||
let officialItemsArray = [...officialPinnedItems];
|
||||
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) => {
|
||||
flatGearArray.filter(gear => user.items.gear.owned[gear.key] === undefined && gear.set === setToAdd).map(gear => {
|
||||
officialItemsArray.push({
|
||||
type: 'marketGear',
|
||||
path: `gear.flat.${gear.key}`,
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
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
|
||||
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 {
|
||||
@@ -35,7 +35,7 @@ function sortInAppRewards (user, items) {
|
||||
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;
|
||||
@@ -44,15 +44,15 @@ export default function getPinnedItems (user) {
|
||||
|
||||
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,13 +1,11 @@
|
||||
export default function isPinned (user, item, checkOfficialPinnedItems /* getOfficialPinnedItems */) {
|
||||
if (user === null)
|
||||
return false;
|
||||
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;
|
||||
|
||||
if (isPinnedOfficial && !isItemUnpinned)
|
||||
return true;
|
||||
if (isPinnedOfficial && !isItemUnpinned) return true;
|
||||
|
||||
return isItemPinned;
|
||||
}
|
||||
|
||||
@@ -8,7 +8,5 @@ are any tags active?
|
||||
// TODO move to client
|
||||
|
||||
export default function noTags (tags) {
|
||||
return isEmpty(tags) || isEmpty(filter(tags, (t) => {
|
||||
return t;
|
||||
}));
|
||||
return isEmpty(tags) || isEmpty(filter(tags, t => t));
|
||||
}
|
||||
|
||||
@@ -8,8 +8,8 @@ import get from 'lodash/get';
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -4,9 +4,7 @@ import filter from 'lodash/filter';
|
||||
// TODO used only in v2
|
||||
|
||||
export default function preenTodos (tasks) {
|
||||
return filter(tasks, (t) => {
|
||||
return !t.completed || t.challenge && t.challenge.id || moment(t.dateCompleted).isAfter(moment().subtract({
|
||||
days: 3,
|
||||
}));
|
||||
});
|
||||
return filter(tasks, t => !t.completed || t.challenge && t.challenge.id || moment(t.dateCompleted).isAfter(moment().subtract({
|
||||
days: 3,
|
||||
})));
|
||||
}
|
||||
|
||||
@@ -8,12 +8,12 @@ export function trueRandom () {
|
||||
// Get a random property from an object
|
||||
// returns random property (the value)
|
||||
export default function randomVal (obj, options = {}) {
|
||||
let array = options.key ? keys(obj) : values(obj);
|
||||
let random = options.predictableRandom || trueRandom();
|
||||
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];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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,18 +134,18 @@ 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,
|
||||
@@ -165,17 +154,13 @@ shops.getMarketGearCategories = function getMarketGear (user, language) {
|
||||
if (gearItem.specialClass === classType && user.items.gear.owned[gearItem.key] !== false) return gearItem.canOwn(classShift);
|
||||
});
|
||||
|
||||
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 +168,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 +196,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 +259,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 +291,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,36 +304,36 @@ 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) {
|
||||
for (const type in stable) {
|
||||
if (stable.hasOwnProperty(type)) {
|
||||
let category = {
|
||||
const category = {
|
||||
identifier: type,
|
||||
text: i18n.t(type, language),
|
||||
items: [],
|
||||
};
|
||||
|
||||
for (let key in content.timeTravelStable[type]) {
|
||||
for (const key in content.timeTravelStable[type]) {
|
||||
if (content.timeTravelStable[type].hasOwnProperty(key)) {
|
||||
if (!user.items[type][key]) {
|
||||
let item = getItemInfo(user, 'timeTravelersStable', {
|
||||
const item = getItemInfo(user, 'timeTravelersStable', {
|
||||
key,
|
||||
type,
|
||||
}, officialPinnedItems, language);
|
||||
@@ -372,11 +347,11 @@ shops.getTimeTravelersCategories = function getTimeTravelersCategories (user, la
|
||||
}
|
||||
}
|
||||
|
||||
let sets = content.timeTravelerStore(user);
|
||||
for (let setKey in sets) {
|
||||
const sets = content.timeTravelerStore(user);
|
||||
for (const setKey in sets) {
|
||||
if (sets.hasOwnProperty(setKey)) {
|
||||
let set = sets[setKey];
|
||||
let category = {
|
||||
const set = sets[setKey];
|
||||
const category = {
|
||||
identifier: set.key,
|
||||
text: set.text(language),
|
||||
path: `mystery.${set.key}`,
|
||||
@@ -384,20 +359,18 @@ shops.getTimeTravelersCategories = function getTimeTravelersCategories (user, la
|
||||
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}`,
|
||||
};
|
||||
});
|
||||
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 +383,18 @@ 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;
|
||||
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 +402,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`),
|
||||
@@ -453,7 +425,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 +435,36 @@ 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 +472,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 +484,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);
|
||||
});
|
||||
|
||||
@@ -6,9 +6,8 @@ Silver amount from their money
|
||||
|
||||
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';
|
||||
}
|
||||
|
||||
@@ -5,23 +5,23 @@ import content from '../content/index';
|
||||
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;
|
||||
}
|
||||
@@ -34,17 +34,17 @@ function equipmentStatBonusComputed (stat, user) {
|
||||
}
|
||||
|
||||
export default function statsComputed (user) {
|
||||
let statBreakdown = {
|
||||
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);
|
||||
|
||||
@@ -14,8 +14,8 @@ export default function taskDefaults (task, user) {
|
||||
task.type = 'habit';
|
||||
}
|
||||
|
||||
let defaultId = uuid();
|
||||
let defaultTaskObj = {
|
||||
const defaultId = uuid();
|
||||
const defaultTaskObj = {
|
||||
_id: defaultId,
|
||||
text: task._id || defaultId,
|
||||
notes: '',
|
||||
@@ -65,9 +65,9 @@ export default 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 +85,9 @@ export default 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: [],
|
||||
|
||||
@@ -8,7 +8,7 @@ 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;
|
||||
}, {});
|
||||
@@ -16,21 +16,18 @@ let sortOrder = reduce(content.gearTypes, (accumulator, val, key) => {
|
||||
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,5 +1,5 @@
|
||||
import uuid from '../libs/uuid';
|
||||
import get from 'lodash/get';
|
||||
import uuid from '../libs/uuid';
|
||||
|
||||
// TODO used only in client, move there?
|
||||
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import taskDefaults from '../libs/taskDefaults';
|
||||
import clone from 'lodash/clone';
|
||||
import taskDefaults from '../libs/taskDefaults';
|
||||
|
||||
// TODO move to client since it's only used there?
|
||||
|
||||
export default function addTask (user, req = {body: {}}) {
|
||||
let task = taskDefaults(req.body, user);
|
||||
export default function addTask (user, req = { body: {} }) {
|
||||
const task = taskDefaults(req.body, user);
|
||||
user.tasksOrder[`${task.type}s`].unshift(task._id);
|
||||
user[`${task.type}s`].unshift(task);
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ export default function blockUser (user, req = {}) {
|
||||
if (!validator.isUUID(req.params.uuid)) throw new BadRequest(i18n.t('invalidUUID', req.language));
|
||||
if (req.params.uuid === user._id) throw new BadRequest(i18n.t('blockYourself', req.language));
|
||||
|
||||
let i = user.inbox.blocks.indexOf(req.params.uuid);
|
||||
const i = user.inbox.blocks.indexOf(req.params.uuid);
|
||||
if (i === -1) {
|
||||
user.inbox.blocks.push(req.params.uuid);
|
||||
} else {
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import _merge from 'lodash/merge';
|
||||
import _get from 'lodash/get';
|
||||
import i18n from '../../i18n';
|
||||
import {
|
||||
NotAuthorized,
|
||||
NotImplementedError,
|
||||
BadRequest,
|
||||
} from '../../libs/errors';
|
||||
import _merge from 'lodash/merge';
|
||||
import _get from 'lodash/get';
|
||||
|
||||
export class AbstractBuyOperation {
|
||||
/**
|
||||
@@ -18,7 +18,7 @@ export class AbstractBuyOperation {
|
||||
this.req = req || {};
|
||||
this.analytics = analytics;
|
||||
|
||||
let quantity = _get(req, 'quantity');
|
||||
const quantity = _get(req, 'quantity');
|
||||
|
||||
this.quantity = quantity ? Number(quantity) : 1;
|
||||
if (this.quantity < 1 || !Number.isInteger(this.quantity)) throw new BadRequest(this.i18n('invalidQuantity'));
|
||||
@@ -48,8 +48,7 @@ export class AbstractBuyOperation {
|
||||
* @returns {String}
|
||||
*/
|
||||
getItemType (item) {
|
||||
if (!item.type)
|
||||
throw new NotImplementedError('item doesn\'t have a type property');
|
||||
if (!item.type) throw new NotImplementedError('item doesn\'t have a type property');
|
||||
|
||||
return item.type;
|
||||
}
|
||||
@@ -95,7 +94,7 @@ export class AbstractBuyOperation {
|
||||
|
||||
this.extractAndValidateParams(this.user, this.req);
|
||||
|
||||
let resultObj = this.executeChanges(this.user, this.item, this.req);
|
||||
const resultObj = this.executeChanges(this.user, this.item, this.req);
|
||||
|
||||
if (this.analytics) {
|
||||
this.sendToAnalytics(this.analyticsData());
|
||||
@@ -110,7 +109,7 @@ export class AbstractBuyOperation {
|
||||
|
||||
sendToAnalytics (additionalData = {}) {
|
||||
// spread-operator produces an "unexpected token" error
|
||||
let analyticsData = _merge(additionalData, {
|
||||
const analyticsData = _merge(additionalData, {
|
||||
// ...additionalData,
|
||||
uuid: this.user._id,
|
||||
category: 'behavior',
|
||||
@@ -132,9 +131,9 @@ export class AbstractGoldItemOperation extends AbstractBuyOperation {
|
||||
|
||||
canUserPurchase (user, item) {
|
||||
this.item = item;
|
||||
let itemValue = this.getItemValue(item);
|
||||
const itemValue = this.getItemValue(item);
|
||||
|
||||
let userGold = user.stats.gp;
|
||||
const userGold = user.stats.gp;
|
||||
|
||||
if (userGold < itemValue * this.quantity) {
|
||||
throw new NotAuthorized(this.i18n('messageNotEnoughGold'));
|
||||
@@ -146,7 +145,7 @@ export class AbstractGoldItemOperation extends AbstractBuyOperation {
|
||||
}
|
||||
|
||||
subtractCurrency (user, item) {
|
||||
let itemValue = this.getItemValue(item);
|
||||
const itemValue = this.getItemValue(item);
|
||||
|
||||
user.stats.gp -= itemValue * this.quantity;
|
||||
}
|
||||
@@ -168,7 +167,7 @@ export class AbstractGemItemOperation extends AbstractBuyOperation {
|
||||
|
||||
canUserPurchase (user, item) {
|
||||
this.item = item;
|
||||
let itemValue = this.getItemValue(item);
|
||||
const itemValue = this.getItemValue(item);
|
||||
|
||||
if (!item.canBuy(user)) {
|
||||
throw new NotAuthorized(this.i18n('messageNotAvailable'));
|
||||
@@ -180,7 +179,7 @@ export class AbstractGemItemOperation extends AbstractBuyOperation {
|
||||
}
|
||||
|
||||
subtractCurrency (user, item) {
|
||||
let itemValue = this.getItemValue(item);
|
||||
const itemValue = this.getItemValue(item);
|
||||
|
||||
user.balance -= itemValue * this.quantity;
|
||||
}
|
||||
|
||||
@@ -2,28 +2,28 @@ import get from 'lodash/get';
|
||||
import {
|
||||
BadRequest,
|
||||
} from '../../libs/errors';
|
||||
import {BuyArmoireOperation} from './buyArmoire';
|
||||
import {BuyHealthPotionOperation} from './buyHealthPotion';
|
||||
import {BuyMarketGearOperation} from './buyMarketGear';
|
||||
import { BuyArmoireOperation } from './buyArmoire';
|
||||
import { BuyHealthPotionOperation } from './buyHealthPotion';
|
||||
import { BuyMarketGearOperation } from './buyMarketGear';
|
||||
import buyMysterySet from './buyMysterySet';
|
||||
import {BuyQuestWithGoldOperation} from './buyQuestGold';
|
||||
import {BuySpellOperation} from './buySpell';
|
||||
import { BuyQuestWithGoldOperation } from './buyQuestGold';
|
||||
import { BuySpellOperation } from './buySpell';
|
||||
import purchaseOp from './purchase';
|
||||
import hourglassPurchase from './hourglassPurchase';
|
||||
import errorMessage from '../../libs/errorMessage';
|
||||
import {BuyGemOperation} from './buyGem';
|
||||
import {BuyQuestWithGemOperation} from './buyQuestGem';
|
||||
import {BuyHourglassMountOperation} from './buyMount';
|
||||
import { BuyGemOperation } from './buyGem';
|
||||
import { BuyQuestWithGemOperation } from './buyQuestGem';
|
||||
import { BuyHourglassMountOperation } from './buyMount';
|
||||
|
||||
// @TODO: remove the req option style. Dependency on express structure is an anti-pattern
|
||||
// We should either have more params or a set structure validated by a Type checker
|
||||
|
||||
// @TODO: when we are sure buy is the only function used, let's move the buy files to a folder
|
||||
|
||||
export default function buy (user, req = {}, analytics, options = {quantity: 1, hourglass: false}) {
|
||||
let key = get(req, 'params.key');
|
||||
const hourglass = options.hourglass;
|
||||
const quantity = options.quantity;
|
||||
export default function buy (user, req = {}, analytics, options = { quantity: 1, hourglass: false }) {
|
||||
const key = get(req, 'params.key');
|
||||
const { hourglass } = options;
|
||||
const { quantity } = options;
|
||||
if (!key) throw new BadRequest(errorMessage('missingKeyParam'));
|
||||
|
||||
// @TODO: Slowly remove the need for key and use type instead
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
import content from '../../content/index';
|
||||
import filter from 'lodash/filter';
|
||||
import isEmpty from 'lodash/isEmpty';
|
||||
import pick from 'lodash/pick';
|
||||
import content from '../../content/index';
|
||||
import * as count from '../../count';
|
||||
import splitWhitespace from '../../libs/splitWhitespace';
|
||||
import {
|
||||
NotAuthorized,
|
||||
} from '../../libs/errors';
|
||||
import randomVal, * as randomValFns from '../../libs/randomVal';
|
||||
import {removeItemByPath} from '../pinnedGearUtils';
|
||||
import {AbstractGoldItemOperation} from './abstractBuyOperation';
|
||||
import { removeItemByPath } from '../pinnedGearUtils';
|
||||
import { AbstractGoldItemOperation } from './abstractBuyOperation';
|
||||
|
||||
// TODO this is only used on the server
|
||||
// move out of common?
|
||||
@@ -27,7 +27,7 @@ export class BuyArmoireOperation extends AbstractGoldItemOperation {
|
||||
}
|
||||
|
||||
extractAndValidateParams (user) {
|
||||
let item = content.armoire;
|
||||
const item = content.armoire;
|
||||
|
||||
this.canUserPurchase(user, item);
|
||||
}
|
||||
@@ -35,11 +35,9 @@ export class BuyArmoireOperation extends AbstractGoldItemOperation {
|
||||
executeChanges (user, item) {
|
||||
let result = {};
|
||||
|
||||
let armoireResult = randomValFns.trueRandom();
|
||||
let eligibleEquipment = filter(content.gear.flat, (eligible) => {
|
||||
return eligible.klass === 'armoire' && !user.items.gear.owned[eligible.key];
|
||||
});
|
||||
let armoireHasEquipment = !isEmpty(eligibleEquipment);
|
||||
const armoireResult = randomValFns.trueRandom();
|
||||
const eligibleEquipment = filter(content.gear.flat, eligible => eligible.klass === 'armoire' && !user.items.gear.owned[eligible.key]);
|
||||
const armoireHasEquipment = !isEmpty(eligibleEquipment);
|
||||
|
||||
if (armoireHasEquipment && (armoireResult < YIELD_EQUIPMENT_THRESHOLD || !user.flags.armoireOpened)) {
|
||||
result = this._gearResult(user, eligibleEquipment);
|
||||
@@ -51,7 +49,7 @@ export class BuyArmoireOperation extends AbstractGoldItemOperation {
|
||||
|
||||
this.subtractCurrency(user, item);
|
||||
|
||||
let {message, armoireResp} = result;
|
||||
let { message, armoireResp } = result;
|
||||
|
||||
if (!message) {
|
||||
message = this.i18n('messageBought', {
|
||||
@@ -59,7 +57,7 @@ export class BuyArmoireOperation extends AbstractGoldItemOperation {
|
||||
});
|
||||
}
|
||||
|
||||
let resData = pick(user, splitWhitespace('items flags'));
|
||||
const resData = pick(user, splitWhitespace('items flags'));
|
||||
if (armoireResp) resData.armoire = armoireResp;
|
||||
|
||||
return [
|
||||
@@ -83,7 +81,7 @@ export class BuyArmoireOperation extends AbstractGoldItemOperation {
|
||||
|
||||
_gearResult (user, eligibleEquipment) {
|
||||
eligibleEquipment.sort();
|
||||
let drop = randomVal(eligibleEquipment);
|
||||
const drop = randomVal(eligibleEquipment);
|
||||
|
||||
if (user.items.gear.owned[drop.key]) {
|
||||
throw new NotAuthorized(this.i18n('equipmentAlreadyOwned'));
|
||||
@@ -93,7 +91,7 @@ export class BuyArmoireOperation extends AbstractGoldItemOperation {
|
||||
if (user.markModified) user.markModified('items.gear.owned');
|
||||
|
||||
user.flags.armoireOpened = true;
|
||||
let message = this.i18n('armoireEquipment', {
|
||||
const message = this.i18n('armoireEquipment', {
|
||||
image: `<span class="shop_${drop.key} pull-left"></span>`,
|
||||
dropText: drop.text(this.req.language),
|
||||
});
|
||||
@@ -108,7 +106,7 @@ export class BuyArmoireOperation extends AbstractGoldItemOperation {
|
||||
this._trackDropAnalytics(user._id, drop.key);
|
||||
}
|
||||
|
||||
let armoireResp = {
|
||||
const armoireResp = {
|
||||
type: 'gear',
|
||||
dropKey: drop.key,
|
||||
dropText: drop.text(this.req.language),
|
||||
@@ -121,7 +119,7 @@ export class BuyArmoireOperation extends AbstractGoldItemOperation {
|
||||
}
|
||||
|
||||
_foodResult (user) {
|
||||
let drop = randomVal(filter(content.food, {
|
||||
const drop = randomVal(filter(content.food, {
|
||||
canDrop: true,
|
||||
}));
|
||||
|
||||
@@ -147,7 +145,7 @@ export class BuyArmoireOperation extends AbstractGoldItemOperation {
|
||||
}
|
||||
|
||||
_experienceResult (user) {
|
||||
let armoireExp = Math.floor(randomValFns.trueRandom() * 40 + 10);
|
||||
const armoireExp = Math.floor(randomValFns.trueRandom() * 40 + 10);
|
||||
user.stats.exp += armoireExp;
|
||||
|
||||
return {
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import pick from 'lodash/pick';
|
||||
import get from 'lodash/get';
|
||||
import splitWhitespace from '../../libs/splitWhitespace';
|
||||
import {
|
||||
BadRequest,
|
||||
NotAuthorized,
|
||||
} from '../../libs/errors';
|
||||
import {AbstractGoldItemOperation} from './abstractBuyOperation';
|
||||
import get from 'lodash/get';
|
||||
import { AbstractGoldItemOperation } from './abstractBuyOperation';
|
||||
import planGemLimits from '../../libs/planGemLimits';
|
||||
|
||||
export class BuyGemOperation extends AbstractGoldItemOperation {
|
||||
@@ -30,10 +30,10 @@ export class BuyGemOperation extends AbstractGoldItemOperation {
|
||||
}
|
||||
|
||||
extractAndValidateParams (user, req) {
|
||||
let key = this.key = get(req, 'params.key');
|
||||
const key = this.key = get(req, 'params.key');
|
||||
if (!key) throw new BadRequest(this.i18n('missingKeyParam'));
|
||||
|
||||
let convCap = planGemLimits.convCap;
|
||||
let { convCap } = planGemLimits;
|
||||
convCap += user.purchased.plan.consecutive.gemCapExtra;
|
||||
|
||||
// todo better name?
|
||||
@@ -50,7 +50,7 @@ export class BuyGemOperation extends AbstractGoldItemOperation {
|
||||
super.canUserPurchase(user, item);
|
||||
|
||||
if (user.purchased.plan.gemsBought >= this.convCap) {
|
||||
throw new NotAuthorized(this.i18n('reachedGoldToGemCap', {convCap: this.convCap}));
|
||||
throw new NotAuthorized(this.i18n('reachedGoldToGemCap', { convCap: this.convCap }));
|
||||
}
|
||||
|
||||
if (user.purchased.plan.gemsBought + this.quantity > this.convCap) {
|
||||
@@ -69,7 +69,7 @@ export class BuyGemOperation extends AbstractGoldItemOperation {
|
||||
|
||||
return [
|
||||
pick(user, splitWhitespace('stats balance')),
|
||||
this.i18n('plusGem', {count: this.quantity}),
|
||||
this.i18n('plusGem', { count: this.quantity }),
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ import {
|
||||
NotAuthorized,
|
||||
} from '../../libs/errors';
|
||||
|
||||
import { AbstractGoldItemOperation} from './abstractBuyOperation';
|
||||
import { AbstractGoldItemOperation } from './abstractBuyOperation';
|
||||
|
||||
export class BuyHealthPotionOperation extends AbstractGoldItemOperation {
|
||||
constructor (user, req, analytics) {
|
||||
@@ -15,8 +15,8 @@ export class BuyHealthPotionOperation extends AbstractGoldItemOperation {
|
||||
}
|
||||
|
||||
extractAndValidateParams (user) {
|
||||
let item = content.potion;
|
||||
let userHp = user.stats.hp;
|
||||
const item = content.potion;
|
||||
const userHp = user.stats.hp;
|
||||
|
||||
super.canUserPurchase(user, item);
|
||||
|
||||
@@ -37,7 +37,7 @@ export class BuyHealthPotionOperation extends AbstractGoldItemOperation {
|
||||
|
||||
this.subtractCurrency(user, item, this.quantity);
|
||||
|
||||
let message = this.i18n('messageBought', {
|
||||
const message = this.i18n('messageBought', {
|
||||
itemText: this.item.text(this.req.language),
|
||||
});
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import content from '../../content/index';
|
||||
import get from 'lodash/get';
|
||||
import pick from 'lodash/pick';
|
||||
import content from '../../content/index';
|
||||
import splitWhitespace from '../../libs/splitWhitespace';
|
||||
import {
|
||||
BadRequest,
|
||||
@@ -10,7 +10,7 @@ import {
|
||||
import handleTwoHanded from '../../fns/handleTwoHanded';
|
||||
import ultimateGear from '../../fns/ultimateGear';
|
||||
|
||||
import {removePinnedGearAddPossibleNewOnes} from '../pinnedGearUtils';
|
||||
import { removePinnedGearAddPossibleNewOnes } from '../pinnedGearUtils';
|
||||
|
||||
import { AbstractGoldItemOperation } from './abstractBuyOperation';
|
||||
import errorMessage from '../../libs/errorMessage';
|
||||
@@ -24,7 +24,7 @@ export class BuyMarketGearOperation extends AbstractGoldItemOperation {
|
||||
return false;
|
||||
}
|
||||
|
||||
canUserPurchase (user, item) {
|
||||
canUserPurchase (user, item) {
|
||||
super.canUserPurchase(user, item);
|
||||
|
||||
const checkKlass = item.klass && !['special', 'armoire', user.stats.class].includes(item.klass);
|
||||
@@ -37,11 +37,11 @@ export class BuyMarketGearOperation extends AbstractGoldItemOperation {
|
||||
}
|
||||
|
||||
extractAndValidateParams (user, req) {
|
||||
let key = this.key = get(req, 'params.key');
|
||||
const key = this.key = get(req, 'params.key');
|
||||
if (!key) throw new BadRequest(errorMessage('missingKeyParam'));
|
||||
|
||||
let item = content.gear.flat[key];
|
||||
if (!item) throw new NotFound(errorMessage('itemNotFound', {key}));
|
||||
const item = content.gear.flat[key];
|
||||
if (!item) throw new NotFound(errorMessage('itemNotFound', { key }));
|
||||
|
||||
this.canUserPurchase(user, item);
|
||||
|
||||
@@ -49,12 +49,12 @@ export class BuyMarketGearOperation extends AbstractGoldItemOperation {
|
||||
throw new NotAuthorized(this.i18n('equipmentAlreadyOwned'));
|
||||
}
|
||||
|
||||
let itemIndex = Number(item.index);
|
||||
const itemIndex = Number(item.index);
|
||||
|
||||
if (Number.isInteger(itemIndex) && content.classes.includes(item.klass)) {
|
||||
let previousLevelGear = key.replace(/[0-9]/, itemIndex - 1);
|
||||
let hasPreviousLevelGear = user.items.gear.owned[previousLevelGear];
|
||||
let checkIndexToType = itemIndex > (item.type === 'weapon' || item.type === 'shield' && item.klass === 'rogue' ? 0 : 1);
|
||||
const previousLevelGear = key.replace(/[0-9]/, itemIndex - 1);
|
||||
const hasPreviousLevelGear = user.items.gear.owned[previousLevelGear];
|
||||
const checkIndexToType = itemIndex > (item.type === 'weapon' || item.type === 'shield' && item.klass === 'rogue' ? 0 : 1);
|
||||
|
||||
if (checkIndexToType && !hasPreviousLevelGear) {
|
||||
throw new NotAuthorized(this.i18n('previousGearNotOwned'));
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
import get from 'lodash/get';
|
||||
import includes from 'lodash/includes';
|
||||
import keys from 'lodash/keys';
|
||||
import content from '../../content/index';
|
||||
import {
|
||||
BadRequest,
|
||||
NotAuthorized,
|
||||
} from '../../libs/errors';
|
||||
|
||||
import {AbstractHourglassItemOperation} from './abstractBuyOperation';
|
||||
import get from 'lodash/get';
|
||||
import includes from 'lodash/includes';
|
||||
import keys from 'lodash/keys';
|
||||
import { AbstractHourglassItemOperation } from './abstractBuyOperation';
|
||||
|
||||
export class BuyHourglassMountOperation extends AbstractHourglassItemOperation {
|
||||
constructor (user, req, analytics) {
|
||||
@@ -19,7 +19,7 @@ export class BuyHourglassMountOperation extends AbstractHourglassItemOperation {
|
||||
}
|
||||
|
||||
extractAndValidateParams (user, req) {
|
||||
let key = this.key = get(req, 'params.key');
|
||||
const key = this.key = get(req, 'params.key');
|
||||
if (!key) throw new BadRequest(this.i18n('missingKeyParam'));
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@ export class BuyHourglassMountOperation extends AbstractHourglassItemOperation {
|
||||
|
||||
this.subtractCurrency(user);
|
||||
|
||||
let message = this.i18n('hourglassPurchase');
|
||||
const message = this.i18n('hourglassPurchase');
|
||||
|
||||
return [
|
||||
{ items: user.items, purchasedPlanConsecutive: user.purchased.plan.consecutive },
|
||||
@@ -52,7 +52,7 @@ export class BuyHourglassMountOperation extends AbstractHourglassItemOperation {
|
||||
}
|
||||
|
||||
analyticsData () {
|
||||
let data = super.analyticsData();
|
||||
const data = super.analyticsData();
|
||||
data.itemType = 'mounts';
|
||||
return data;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import i18n from '../../i18n';
|
||||
import content from '../../content/index';
|
||||
import get from 'lodash/get';
|
||||
import each from 'lodash/each';
|
||||
import i18n from '../../i18n';
|
||||
import content from '../../content/index';
|
||||
import {
|
||||
BadRequest,
|
||||
NotAuthorized,
|
||||
@@ -10,15 +10,15 @@ import {
|
||||
import errorMessage from '../../libs/errorMessage';
|
||||
|
||||
export default function buyMysterySet (user, req = {}, analytics) {
|
||||
let key = get(req, 'params.key');
|
||||
const key = get(req, 'params.key');
|
||||
if (!key) throw new BadRequest(errorMessage('missingKeyParam'));
|
||||
|
||||
if (!(user.purchased.plan.consecutive.trinkets > 0)) {
|
||||
throw new NotAuthorized(i18n.t('notEnoughHourglasses', req.language));
|
||||
}
|
||||
|
||||
let ref = content.timeTravelerStore(user);
|
||||
let mysterySet = ref ? ref[key] : undefined;
|
||||
const ref = content.timeTravelerStore(user);
|
||||
const mysterySet = ref ? ref[key] : undefined;
|
||||
|
||||
if (!mysterySet) {
|
||||
throw new NotFound(i18n.t('mysterySetNotFound', req.language));
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
import get from 'lodash/get';
|
||||
import {
|
||||
BadRequest,
|
||||
NotAuthorized,
|
||||
NotFound,
|
||||
} from '../../libs/errors';
|
||||
import content from '../../content/index';
|
||||
import get from 'lodash/get';
|
||||
|
||||
import errorMessage from '../../libs/errorMessage';
|
||||
import {AbstractGemItemOperation} from './abstractBuyOperation';
|
||||
import { AbstractGemItemOperation } from './abstractBuyOperation';
|
||||
|
||||
export class BuyQuestWithGemOperation extends AbstractGemItemOperation {
|
||||
constructor (user, req, analytics) {
|
||||
@@ -31,15 +31,15 @@ export class BuyQuestWithGemOperation extends AbstractGemItemOperation {
|
||||
}
|
||||
|
||||
extractAndValidateParams (user, req) {
|
||||
let key = this.key = get(req, 'params.key');
|
||||
const key = this.key = get(req, 'params.key');
|
||||
if (!key) throw new BadRequest(errorMessage('missingKeyParam'));
|
||||
|
||||
let item = content.quests[key];
|
||||
const item = content.quests[key];
|
||||
|
||||
if (!item) throw new NotFound(errorMessage('questNotFound', {key}));
|
||||
if (!item) throw new NotFound(errorMessage('questNotFound', { key }));
|
||||
|
||||
if (item.category === 'gold') {
|
||||
throw new NotAuthorized(this.i18n('questNotGemPurchasable', {key}));
|
||||
throw new NotAuthorized(this.i18n('questNotGemPurchasable', { key }));
|
||||
}
|
||||
|
||||
this.canUserPurchase(user, item);
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import get from 'lodash/get';
|
||||
import {
|
||||
BadRequest,
|
||||
NotAuthorized,
|
||||
NotFound,
|
||||
} from '../../libs/errors';
|
||||
import content from '../../content/index';
|
||||
import get from 'lodash/get';
|
||||
|
||||
import {AbstractGoldItemOperation} from './abstractBuyOperation';
|
||||
import { AbstractGoldItemOperation } from './abstractBuyOperation';
|
||||
import errorMessage from '../../libs/errorMessage';
|
||||
|
||||
export class BuyQuestWithGoldOperation extends AbstractGoldItemOperation {
|
||||
@@ -19,10 +19,10 @@ export class BuyQuestWithGoldOperation extends AbstractGoldItemOperation {
|
||||
}
|
||||
|
||||
userAbleToStartMasterClasser (user) {
|
||||
return user.achievements.quests.dilatoryDistress3 &&
|
||||
user.achievements.quests.mayhemMistiflying3 &&
|
||||
user.achievements.quests.stoikalmCalamity3 &&
|
||||
user.achievements.quests.taskwoodsTerror3;
|
||||
return user.achievements.quests.dilatoryDistress3
|
||||
&& user.achievements.quests.mayhemMistiflying3
|
||||
&& user.achievements.quests.stoikalmCalamity3
|
||||
&& user.achievements.quests.taskwoodsTerror3;
|
||||
}
|
||||
|
||||
getItemKey () {
|
||||
@@ -38,15 +38,15 @@ export class BuyQuestWithGoldOperation extends AbstractGoldItemOperation {
|
||||
}
|
||||
|
||||
extractAndValidateParams (user, req) {
|
||||
let key = this.key = get(req, 'params.key');
|
||||
const key = this.key = get(req, 'params.key');
|
||||
if (!key) throw new BadRequest(errorMessage('missingKeyParam'));
|
||||
|
||||
let item = content.quests[key];
|
||||
const item = content.quests[key];
|
||||
|
||||
if (!item) throw new NotFound(errorMessage('questNotFound', {key}));
|
||||
if (!item) throw new NotFound(errorMessage('questNotFound', { key }));
|
||||
|
||||
if (!(item.category === 'gold' && item.goldValue)) {
|
||||
throw new NotAuthorized(this.i18n('questNotGoldPurchasable', {key}));
|
||||
throw new NotAuthorized(this.i18n('questNotGoldPurchasable', { key }));
|
||||
}
|
||||
|
||||
this.checkPrerequisites(user, key);
|
||||
@@ -61,7 +61,7 @@ export class BuyQuestWithGoldOperation extends AbstractGoldItemOperation {
|
||||
}
|
||||
|
||||
if (item && item.previous && !user.achievements.quests[item.previous]) {
|
||||
throw new NotAuthorized(this.i18n('mustComplete', {quest: item.previous}));
|
||||
throw new NotAuthorized(this.i18n('mustComplete', { quest: item.previous }));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import content from '../../content/index';
|
||||
import get from 'lodash/get';
|
||||
import pick from 'lodash/pick';
|
||||
import content from '../../content/index';
|
||||
import splitWhitespace from '../../libs/splitWhitespace';
|
||||
import {
|
||||
BadRequest,
|
||||
NotFound,
|
||||
} from '../../libs/errors';
|
||||
import {AbstractGoldItemOperation} from './abstractBuyOperation';
|
||||
import { AbstractGoldItemOperation } from './abstractBuyOperation';
|
||||
import errorMessage from '../../libs/errorMessage';
|
||||
|
||||
export class BuySpellOperation extends AbstractGoldItemOperation {
|
||||
@@ -27,11 +27,11 @@ export class BuySpellOperation extends AbstractGoldItemOperation {
|
||||
}
|
||||
|
||||
extractAndValidateParams (user, req) {
|
||||
let key = this.key = get(req, 'params.key');
|
||||
const key = this.key = get(req, 'params.key');
|
||||
if (!key) throw new BadRequest(errorMessage('missingKeyParam'));
|
||||
|
||||
let item = content.special[key];
|
||||
if (!item) throw new NotFound(errorMessage('spellNotFound', {spellId: key}));
|
||||
const item = content.special[key];
|
||||
if (!item) throw new NotFound(errorMessage('spellNotFound', { spellId: key }));
|
||||
|
||||
this.canUserPurchase(user, item);
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import content from '../../content/index';
|
||||
import i18n from '../../i18n';
|
||||
import get from 'lodash/get';
|
||||
import includes from 'lodash/includes';
|
||||
import keys from 'lodash/keys';
|
||||
import i18n from '../../i18n';
|
||||
import content from '../../content/index';
|
||||
import {
|
||||
BadRequest,
|
||||
NotAuthorized,
|
||||
@@ -10,10 +10,10 @@ import {
|
||||
import errorMessage from '../../libs/errorMessage';
|
||||
|
||||
export default function purchaseHourglass (user, req = {}, analytics, quantity = 1) {
|
||||
let key = get(req, 'params.key');
|
||||
const key = get(req, 'params.key');
|
||||
if (!key) throw new BadRequest(errorMessage('missingKeyParam'));
|
||||
|
||||
let type = get(req, 'params.type');
|
||||
const type = get(req, 'params.type');
|
||||
if (!type) throw new BadRequest(errorMessage('missingTypeParam'));
|
||||
|
||||
if (type === 'quests') {
|
||||
@@ -29,7 +29,7 @@ export default function purchaseHourglass (user, req = {}, analytics, quantity =
|
||||
if (user.markModified) user.markModified('items.quests');
|
||||
} else {
|
||||
if (!content.timeTravelStable[type]) {
|
||||
throw new NotAuthorized(i18n.t('typeNotAllowedHourglass', {allowedTypes: keys(content.timeTravelStable).toString()}, req.language));
|
||||
throw new NotAuthorized(i18n.t('typeNotAllowedHourglass', { allowedTypes: keys(content.timeTravelStable).toString() }, req.language));
|
||||
}
|
||||
|
||||
if (!includes(keys(content.timeTravelStable[type]), key)) {
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import content from '../../content/index';
|
||||
import i18n from '../../i18n';
|
||||
import get from 'lodash/get';
|
||||
import pick from 'lodash/pick';
|
||||
import forEach from 'lodash/forEach';
|
||||
import i18n from '../../i18n';
|
||||
import content from '../../content/index';
|
||||
import splitWhitespace from '../../libs/splitWhitespace';
|
||||
import {
|
||||
NotFound,
|
||||
@@ -21,7 +21,7 @@ function getItemAndPrice (user, type, key, req) {
|
||||
item = content.gear.flat[key];
|
||||
|
||||
if (!item) {
|
||||
throw new NotFound(i18n.t('contentKeyNotFound', {type}, req.language));
|
||||
throw new NotFound(i18n.t('contentKeyNotFound', { type }, req.language));
|
||||
}
|
||||
|
||||
if (user.items.gear.owned[key]) {
|
||||
@@ -33,13 +33,13 @@ function getItemAndPrice (user, type, key, req) {
|
||||
item = content[type][key];
|
||||
|
||||
if (!item) {
|
||||
throw new NotFound(i18n.t('contentKeyNotFound', {type}, req.language));
|
||||
throw new NotFound(i18n.t('contentKeyNotFound', { type }, req.language));
|
||||
}
|
||||
|
||||
price = item.value / 4;
|
||||
}
|
||||
|
||||
return {item, price};
|
||||
return { item, price };
|
||||
}
|
||||
|
||||
function purchaseItem (user, item, price, type, key) {
|
||||
@@ -49,8 +49,8 @@ function purchaseItem (user, item, price, type, key) {
|
||||
user.items.gear.owned[key] = true;
|
||||
if (user.markModified) user.markModified('items.gear.owned');
|
||||
} else if (type === 'bundles') {
|
||||
let subType = item.type;
|
||||
forEach(item.bundleKeys, function addBundledItems (bundledKey) {
|
||||
const subType = item.type;
|
||||
forEach(item.bundleKeys, bundledKey => {
|
||||
if (!user.items[subType][bundledKey] || user.items[subType][key] < 0) {
|
||||
user.items[subType][bundledKey] = 0;
|
||||
}
|
||||
@@ -69,10 +69,10 @@ function purchaseItem (user, item, price, type, key) {
|
||||
const acceptedTypes = ['eggs', 'hatchingPotions', 'food', 'gear', 'bundles'];
|
||||
const singlePurchaseTypes = ['gear'];
|
||||
export default function purchase (user, req = {}, analytics) {
|
||||
let type = get(req.params, 'type');
|
||||
let key = get(req.params, 'key');
|
||||
const type = get(req.params, 'type');
|
||||
const key = get(req.params, 'key');
|
||||
|
||||
let quantity = req.quantity ? Number(req.quantity) : 1;
|
||||
const quantity = req.quantity ? Number(req.quantity) : 1;
|
||||
if (quantity < 1 || !Number.isInteger(quantity)) throw new BadRequest(i18n.t('invalidQuantity', req.language));
|
||||
|
||||
if (!type) {
|
||||
@@ -87,7 +87,7 @@ export default function purchase (user, req = {}, analytics) {
|
||||
throw new NotFound(i18n.t('notAccteptedType', req.language));
|
||||
}
|
||||
|
||||
let {price, item} = getItemAndPrice(user, type, key, req);
|
||||
const { price, item } = getItemAndPrice(user, type, key, req);
|
||||
|
||||
if (!item.canBuy(user)) {
|
||||
throw new NotAuthorized(i18n.t('messageNotAvailable', req.language));
|
||||
@@ -98,7 +98,7 @@ export default function purchase (user, req = {}, analytics) {
|
||||
}
|
||||
|
||||
if (singlePurchaseTypes.includes(type)) {
|
||||
let itemInfo = getItemInfo(user, type, item);
|
||||
const itemInfo = getItemInfo(user, type, item);
|
||||
removeItemByPath(user, itemInfo.path);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import i18n from '../i18n';
|
||||
import get from 'lodash/get';
|
||||
import pick from 'lodash/pick';
|
||||
import i18n from '../i18n';
|
||||
import splitWhitespace from '../libs/splitWhitespace';
|
||||
import { capByLevel } from '../statHelpers';
|
||||
import {
|
||||
@@ -34,7 +34,7 @@ function resetClass (user, req = {}) {
|
||||
}
|
||||
|
||||
export default function changeClass (user, req = {}, analytics) {
|
||||
let klass = get(req, 'query.class');
|
||||
const klass = get(req, 'query.class');
|
||||
let balanceRemoved = 0;
|
||||
// user.flags.classSelected is set to false after the user paid the 3 gems
|
||||
if (user.stats.lvl < 10) {
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
import i18n from '../i18n';
|
||||
import get from 'lodash/get';
|
||||
import findIndex from 'lodash/findIndex';
|
||||
import each from 'lodash/each';
|
||||
import i18n from '../i18n';
|
||||
import { NotFound } from '../libs/errors';
|
||||
|
||||
// TODO used only in client, move there?
|
||||
|
||||
export default function deleteTag (user, req = {}) {
|
||||
let tid = get(req, 'params.id');
|
||||
const tid = get(req, 'params.id');
|
||||
|
||||
let index = findIndex(user.tags, {
|
||||
const index = findIndex(user.tags, {
|
||||
id: tid,
|
||||
});
|
||||
|
||||
@@ -17,16 +17,14 @@ export default function deleteTag (user, req = {}) {
|
||||
throw new NotFound(i18n.t('messageTagNotFound', req.language));
|
||||
}
|
||||
|
||||
let tag = user.tags[index];
|
||||
const tag = user.tags[index];
|
||||
delete user.filters[tag.id];
|
||||
|
||||
user.tags.splice(index, 1);
|
||||
|
||||
each(user.tasks, (task) => {
|
||||
return delete task.tags[tag.id];
|
||||
});
|
||||
each(user.tasks, task => delete task.tags[tag.id]);
|
||||
|
||||
each(['habits', 'dailys', 'todos', 'rewards'], (type) => {
|
||||
each(['habits', 'dailys', 'todos', 'rewards'], type => {
|
||||
if (user.markModified) user.markModified(type);
|
||||
});
|
||||
|
||||
|
||||
@@ -1,17 +1,15 @@
|
||||
import i18n from '../i18n';
|
||||
import { NotFound } from '../libs/errors';
|
||||
import get from 'lodash/get';
|
||||
import findIndex from 'lodash/findIndex';
|
||||
import i18n from '../i18n';
|
||||
import { NotFound } from '../libs/errors';
|
||||
|
||||
// TODO used only in client, move there?
|
||||
|
||||
export default function deleteTask (user, req = {}) {
|
||||
let tid = get(req, 'params.id');
|
||||
let taskType = get(req, 'params.taskType');
|
||||
const tid = get(req, 'params.id');
|
||||
const taskType = get(req, 'params.taskType');
|
||||
|
||||
let index = findIndex(user[`${taskType}s`], function findById (task) {
|
||||
return task._id === tid;
|
||||
});
|
||||
const index = findIndex(user[`${taskType}s`], task => task._id === tid);
|
||||
|
||||
if (index === -1) {
|
||||
throw new NotFound(i18n.t('messageTaskNotFound', req.language));
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import pick from 'lodash/pick';
|
||||
import splitWhitespace from '../libs/splitWhitespace';
|
||||
import { capByLevel } from '../statHelpers';
|
||||
import pick from 'lodash/pick';
|
||||
|
||||
export default function disableClasses (user) {
|
||||
user.stats.class = 'warrior';
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import get from 'lodash/get';
|
||||
import content from '../content/index';
|
||||
import i18n from '../i18n';
|
||||
import handleTwoHanded from '../fns/handleTwoHanded';
|
||||
@@ -5,14 +6,13 @@ import {
|
||||
NotFound,
|
||||
BadRequest,
|
||||
} from '../libs/errors';
|
||||
import get from 'lodash/get';
|
||||
import errorMessage from '../libs/errorMessage';
|
||||
|
||||
export default function equip (user, req = {}) {
|
||||
// Being type a parameter followed by another parameter
|
||||
// when using the API it must be passes specifically in the URL, it's won't default to equipped
|
||||
let type = get(req, 'params.type', 'equipped');
|
||||
let key = get(req, 'params.key');
|
||||
const type = get(req, 'params.type', 'equipped');
|
||||
const key = get(req, 'params.key');
|
||||
|
||||
if (!key || !type) throw new BadRequest(errorMessage('missingTypeKeyEquip'));
|
||||
if (['mount', 'pet', 'costume', 'equipped'].indexOf(type) === -1) {
|
||||
@@ -44,25 +44,25 @@ export default function equip (user, req = {}) {
|
||||
throw new NotFound(i18n.t('gearNotOwned', req.language));
|
||||
}
|
||||
|
||||
let item = content.gear.flat[key];
|
||||
const item = content.gear.flat[key];
|
||||
|
||||
if (user.items.gear[type][item.type] === key) {
|
||||
user.items.gear[type] = Object.assign(
|
||||
{},
|
||||
user.items.gear[type].toObject ? user.items.gear[type].toObject() : user.items.gear[type],
|
||||
{[item.type]: `${item.type}_base_0`}
|
||||
);
|
||||
user.items.gear[type] = {
|
||||
|
||||
...(user.items.gear[type].toObject ? user.items.gear[type].toObject() : user.items.gear[type]),
|
||||
[item.type]: `${item.type}_base_0`,
|
||||
};
|
||||
if (user.markModified && type === 'owned') user.markModified('items.gear.owned');
|
||||
|
||||
message = i18n.t('messageUnEquipped', {
|
||||
itemText: item.text(req.language),
|
||||
}, req.language);
|
||||
} else {
|
||||
user.items.gear[type] = Object.assign(
|
||||
{},
|
||||
user.items.gear[type].toObject ? user.items.gear[type].toObject() : user.items.gear[type],
|
||||
{[item.type]: item.key}
|
||||
);
|
||||
user.items.gear[type] = {
|
||||
|
||||
...(user.items.gear[type].toObject ? user.items.gear[type].toObject() : user.items.gear[type]),
|
||||
[item.type]: item.key,
|
||||
};
|
||||
if (user.markModified && type === 'owned') user.markModified('items.gear.owned');
|
||||
|
||||
message = handleTwoHanded(user, item, type, req);
|
||||
@@ -71,7 +71,7 @@ export default function equip (user, req = {}) {
|
||||
}
|
||||
}
|
||||
|
||||
let res = [user.items];
|
||||
const res = [user.items];
|
||||
if (message) res.push(message);
|
||||
return res;
|
||||
}
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import content from '../content/index';
|
||||
import i18n from '../i18n';
|
||||
import forEach from 'lodash/forEach';
|
||||
import findIndex from 'lodash/findIndex';
|
||||
import get from 'lodash/get';
|
||||
import keys from 'lodash/keys';
|
||||
import upperFirst from 'lodash/upperFirst';
|
||||
import i18n from '../i18n';
|
||||
import content from '../content/index';
|
||||
import {
|
||||
BadRequest,
|
||||
NotAuthorized,
|
||||
@@ -32,7 +32,7 @@ function evolve (user, pet, req) {
|
||||
|
||||
export default function feed (user, req = {}) {
|
||||
let pet = get(req, 'params.pet');
|
||||
let foodK = get(req, 'params.food');
|
||||
const foodK = get(req, 'params.food');
|
||||
|
||||
if (!pet || !foodK) throw new BadRequest(errorMessage('missingPetFoodFeed'));
|
||||
|
||||
@@ -42,12 +42,12 @@ export default function feed (user, req = {}) {
|
||||
throw new BadRequest(errorMessage('invalidPetName'));
|
||||
}
|
||||
|
||||
let food = content.food[foodK];
|
||||
const food = content.food[foodK];
|
||||
if (!food) {
|
||||
throw new NotFound(errorMessage('invalidFoodName', req.language));
|
||||
}
|
||||
|
||||
let userPets = user.items.pets;
|
||||
const userPets = user.items.pets;
|
||||
|
||||
if (!userPets[pet.key]) {
|
||||
throw new NotFound(i18n.t('messagePetNotFound', req.language));
|
||||
@@ -70,7 +70,7 @@ export default function feed (user, req = {}) {
|
||||
if (food.key === 'Saddle') {
|
||||
message = evolve(user, pet, req);
|
||||
} else {
|
||||
let messageParams = {
|
||||
const messageParams = {
|
||||
egg: pet.text(req.language),
|
||||
foodText: food.textThe(req.language),
|
||||
};
|
||||
@@ -93,11 +93,9 @@ export default function feed (user, req = {}) {
|
||||
user.items.food[food.key]--;
|
||||
if (user.markModified) user.markModified('items.food');
|
||||
|
||||
forEach(content.animalColorAchievements, (achievement) => {
|
||||
forEach(content.animalColorAchievements, achievement => {
|
||||
if (!user.achievements[achievement.mountAchievement]) {
|
||||
const mountIndex = findIndex(keys(content.dropEggs), (animal) => {
|
||||
return !user.items.mounts[`${animal}-${achievement.color}`];
|
||||
});
|
||||
const mountIndex = findIndex(keys(content.dropEggs), animal => !user.items.mounts[`${animal}-${achievement.color}`]);
|
||||
if (mountIndex === -1) {
|
||||
user.achievements[achievement.mountAchievement] = true;
|
||||
if (user.addNotification) {
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user