mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-14 05:07:22 +01:00
start upgrading eslint
This commit is contained in:
11
.eslintrc
11
.eslintrc
@@ -1,10 +1,11 @@
|
||||
{
|
||||
"root": true,
|
||||
"env": {
|
||||
"node": true,
|
||||
},
|
||||
"extends": [
|
||||
"habitrpg",
|
||||
"habitrpg/esnext"
|
||||
"habitrpg/lib/node"
|
||||
],
|
||||
"rules": {
|
||||
'no-param-reassign': ['error', {
|
||||
props: false,
|
||||
}],
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,12 +4,12 @@ import apidoc from 'apidoc';
|
||||
|
||||
const APIDOC_DEST_PATH = './apidoc_build';
|
||||
const APIDOC_SRC_PATH = './website/server';
|
||||
gulp.task('apidoc:clean', (done) => {
|
||||
gulp.task('apidoc:clean', done => {
|
||||
clean(APIDOC_DEST_PATH, done);
|
||||
});
|
||||
|
||||
gulp.task('apidoc', gulp.series('apidoc:clean', (done) => {
|
||||
let result = apidoc.createDoc({
|
||||
gulp.task('apidoc', gulp.series('apidoc:clean', done => {
|
||||
const result = apidoc.createDoc({
|
||||
src: APIDOC_SRC_PATH,
|
||||
dest: APIDOC_DEST_PATH,
|
||||
});
|
||||
@@ -21,6 +21,4 @@ gulp.task('apidoc', gulp.series('apidoc:clean', (done) => {
|
||||
}
|
||||
}));
|
||||
|
||||
gulp.task('apidoc:watch', gulp.series('apidoc', (done) => {
|
||||
return gulp.watch(`${APIDOC_SRC_PATH}/**/*.js`, gulp.series('apidoc', done));
|
||||
}));
|
||||
gulp.task('apidoc:watch', gulp.series('apidoc', done => gulp.watch(`${APIDOC_SRC_PATH}/**/*.js`, gulp.series('apidoc', done))));
|
||||
|
||||
@@ -1,32 +1,28 @@
|
||||
import gulp from 'gulp';
|
||||
import babel from 'gulp-babel';
|
||||
|
||||
gulp.task('build:src', () => {
|
||||
return gulp.src('website/server/**/*.js')
|
||||
gulp.task('build:src', () => gulp.src('website/server/**/*.js')
|
||||
.pipe(babel())
|
||||
.pipe(gulp.dest('website/transpiled-babel/'));
|
||||
});
|
||||
.pipe(gulp.dest('website/transpiled-babel/')));
|
||||
|
||||
gulp.task('build:common', () => {
|
||||
return gulp.src('website/common/script/**/*.js')
|
||||
gulp.task('build:common', () => gulp.src('website/common/script/**/*.js')
|
||||
.pipe(babel())
|
||||
.pipe(gulp.dest('website/common/transpiled-babel/'));
|
||||
});
|
||||
.pipe(gulp.dest('website/common/transpiled-babel/')));
|
||||
|
||||
gulp.task('build:server', gulp.series('build:src', 'build:common', done => done()));
|
||||
|
||||
gulp.task('build:prod', gulp.series(
|
||||
'build:server',
|
||||
'apidoc',
|
||||
done => done()
|
||||
done => done(),
|
||||
));
|
||||
|
||||
let buildArgs = [];
|
||||
const buildArgs = [];
|
||||
|
||||
if (process.env.NODE_ENV === 'production') { // eslint-disable-line no-process-env
|
||||
buildArgs.push('build:prod');
|
||||
}
|
||||
|
||||
gulp.task('build', gulp.series(buildArgs, (done) => {
|
||||
gulp.task('build', gulp.series(buildArgs, done => {
|
||||
done();
|
||||
}));
|
||||
@@ -1,22 +1,26 @@
|
||||
import mongoose from 'mongoose';
|
||||
import logger from '../website/server/libs/logger';
|
||||
import nconf from 'nconf';
|
||||
import repl from 'repl';
|
||||
import gulp from 'gulp';
|
||||
import logger from '../website/server/libs/logger';
|
||||
|
||||
// Add additional properties to the repl's context
|
||||
let improveRepl = (context) => {
|
||||
const improveRepl = context => {
|
||||
// Let "exit" and "quit" terminate the console
|
||||
['exit', 'quit'].forEach((term) => {
|
||||
Object.defineProperty(context, term, { get () {
|
||||
['exit', 'quit'].forEach(term => {
|
||||
Object.defineProperty(context, term, {
|
||||
get () { // eslint-disable-line getter-return
|
||||
process.exit();
|
||||
}});
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
// "clear" clears the screen
|
||||
Object.defineProperty(context, 'clear', { get () {
|
||||
Object.defineProperty(context, 'clear', {
|
||||
get () { // eslint-disable-line getter-return
|
||||
process.stdout.write('\u001B[2J\u001B[0;0f');
|
||||
}});
|
||||
},
|
||||
});
|
||||
|
||||
context.Challenge = require('../website/server/models/challenge').model; // eslint-disable-line global-require
|
||||
context.Group = require('../website/server/models/group').model; // eslint-disable-line global-require
|
||||
@@ -30,14 +34,14 @@ let improveRepl = (context) => {
|
||||
mongoose.connect(
|
||||
nconf.get('NODE_DB_URI'),
|
||||
mongooseOptions,
|
||||
(err) => {
|
||||
err => {
|
||||
if (err) throw err;
|
||||
logger.info('Connected with Mongoose');
|
||||
}
|
||||
},
|
||||
);
|
||||
};
|
||||
|
||||
gulp.task('console', (done) => {
|
||||
gulp.task('console', done => {
|
||||
improveRepl(repl.start({
|
||||
prompt: 'Habitica > ',
|
||||
}).context);
|
||||
|
||||
@@ -4,9 +4,9 @@ import spritesmith from 'gulp.spritesmith';
|
||||
import clean from 'rimraf';
|
||||
import sizeOf from 'image-size';
|
||||
import mergeStream from 'merge-stream';
|
||||
import {basename} from 'path';
|
||||
import {sync} from 'glob';
|
||||
import {each} from 'lodash';
|
||||
import { basename } from 'path';
|
||||
import { sync } from 'glob';
|
||||
import { each } from 'lodash';
|
||||
import vinylBuffer from 'vinyl-buffer';
|
||||
|
||||
// https://github.com/Ensighten/grunt-spritesmith/issues/67#issuecomment-34786248
|
||||
@@ -16,17 +16,17 @@ const IMG_DIST_PATH = 'website/client/src/assets/images/sprites/';
|
||||
const CSS_DIST_PATH = 'website/client/src/assets/css/sprites/';
|
||||
|
||||
function checkForSpecialTreatment (name) {
|
||||
let regex = /^hair|skin|beard|mustach|shirt|flower|^headAccessory_special_\w+Ears|^eyewear_special_\w+TopFrame|^eyewear_special_\w+HalfMoon/;
|
||||
const regex = /^hair|skin|beard|mustach|shirt|flower|^headAccessory_special_\w+Ears|^eyewear_special_\w+TopFrame|^eyewear_special_\w+HalfMoon/;
|
||||
return name.match(regex) || name === 'head_0';
|
||||
}
|
||||
|
||||
function calculateImgDimensions (img, addPadding) {
|
||||
let dims = sizeOf(img);
|
||||
|
||||
let requiresSpecialTreatment = checkForSpecialTreatment(img);
|
||||
const requiresSpecialTreatment = checkForSpecialTreatment(img);
|
||||
if (requiresSpecialTreatment) {
|
||||
let newWidth = dims.width < 90 ? 90 : dims.width;
|
||||
let newHeight = dims.height < 90 ? 90 : dims.height;
|
||||
const newWidth = dims.width < 90 ? 90 : dims.width;
|
||||
const newHeight = dims.height < 90 ? 90 : dims.height;
|
||||
dims = {
|
||||
width: newWidth,
|
||||
height: newHeight,
|
||||
@@ -41,17 +41,17 @@ function calculateImgDimensions (img, addPadding) {
|
||||
|
||||
if (!dims.width || !dims.height) console.error('MISSING DIMENSIONS:', dims); // eslint-disable-line no-console
|
||||
|
||||
let totalPixelSize = dims.width * dims.height + padding;
|
||||
const totalPixelSize = dims.width * dims.height + padding;
|
||||
|
||||
return totalPixelSize;
|
||||
}
|
||||
|
||||
function calculateSpritesheetsSrcIndicies (src) {
|
||||
let totalPixels = 0;
|
||||
let slices = [0];
|
||||
const slices = [0];
|
||||
|
||||
each(src, (img, index) => {
|
||||
let imageSize = calculateImgDimensions(img, true);
|
||||
const imageSize = calculateImgDimensions(img, true);
|
||||
totalPixels += imageSize;
|
||||
|
||||
if (totalPixels > MAX_SPRITESHEET_SIZE) {
|
||||
@@ -64,37 +64,35 @@ function calculateSpritesheetsSrcIndicies (src) {
|
||||
}
|
||||
|
||||
function cssVarMap (sprite) {
|
||||
// For hair, skins, beards, etc. we want to output a '.customize-options.WHATEVER' class, which works as a
|
||||
// 60x60 image pointing at the proper part of the 90x90 sprite.
|
||||
// For hair, skins, beards, etc. we want to output a '.customize-options.WHATEVER' class,
|
||||
// which works as a 60x60 image pointing at the proper part of the 90x90 sprite.
|
||||
// We set up the custom info here, and the template makes use of it.
|
||||
let requiresSpecialTreatment = checkForSpecialTreatment(sprite.name);
|
||||
const requiresSpecialTreatment = checkForSpecialTreatment(sprite.name);
|
||||
if (requiresSpecialTreatment) {
|
||||
sprite.custom = {
|
||||
px: {
|
||||
offsetX: `-${ sprite.x + 25 }px`,
|
||||
offsetY: `-${ sprite.y + 15 }px`,
|
||||
offsetX: `-${sprite.x + 25}px`,
|
||||
offsetY: `-${sprite.y + 15}px`,
|
||||
width: '60px',
|
||||
height: '60px',
|
||||
},
|
||||
};
|
||||
}
|
||||
if (sprite.name.indexOf('shirt') !== -1)
|
||||
sprite.custom.px.offsetY = `-${ sprite.y + 35 }px`; // even more for shirts
|
||||
if (sprite.name.indexOf('shirt') !== -1) sprite.custom.px.offsetY = `-${sprite.y + 35}px`; // even more for shirts
|
||||
if (sprite.name.indexOf('hair_base') !== -1) {
|
||||
let styleArray = sprite.name.split('_').slice(2, 3);
|
||||
if (Number(styleArray[0]) > 14)
|
||||
sprite.custom.px.offsetY = `-${ sprite.y }px`; // don't crop updos
|
||||
const styleArray = sprite.name.split('_').slice(2, 3);
|
||||
if (Number(styleArray[0]) > 14) sprite.custom.px.offsetY = `-${sprite.y}px`; // don't crop updos
|
||||
}
|
||||
}
|
||||
|
||||
function createSpritesStream (name, src) {
|
||||
let spritesheetSliceIndicies = calculateSpritesheetsSrcIndicies(src);
|
||||
let stream = mergeStream();
|
||||
const spritesheetSliceIndicies = calculateSpritesheetsSrcIndicies(src);
|
||||
const stream = mergeStream();
|
||||
|
||||
each(spritesheetSliceIndicies, (start, index) => {
|
||||
let slicedSrc = src.slice(start, spritesheetSliceIndicies[index + 1]);
|
||||
const slicedSrc = src.slice(start, spritesheetSliceIndicies[index + 1]);
|
||||
|
||||
let spriteData = gulp.src(slicedSrc)
|
||||
const spriteData = gulp.src(slicedSrc)
|
||||
.pipe(spritesmith({
|
||||
imgName: `spritesmith-${name}-${index}.png`,
|
||||
cssName: `spritesmith-${name}-${index}.css`,
|
||||
@@ -104,12 +102,12 @@ function createSpritesStream (name, src) {
|
||||
cssVarMap,
|
||||
}));
|
||||
|
||||
let imgStream = spriteData.img
|
||||
const imgStream = spriteData.img
|
||||
.pipe(vinylBuffer())
|
||||
.pipe(imagemin())
|
||||
.pipe(gulp.dest(IMG_DIST_PATH));
|
||||
|
||||
let cssStream = spriteData.css
|
||||
const cssStream = spriteData.css
|
||||
.pipe(gulp.dest(CSS_DIST_PATH));
|
||||
|
||||
stream.add(imgStream);
|
||||
@@ -120,32 +118,32 @@ function createSpritesStream (name, src) {
|
||||
}
|
||||
|
||||
gulp.task('sprites:main', () => {
|
||||
let mainSrc = sync('website/raw_sprites/spritesmith/**/*.png');
|
||||
const mainSrc = sync('website/raw_sprites/spritesmith/**/*.png');
|
||||
return createSpritesStream('main', mainSrc);
|
||||
});
|
||||
|
||||
gulp.task('sprites:largeSprites', () => {
|
||||
let largeSrc = sync('website/raw_sprites/spritesmith_large/**/*.png');
|
||||
const largeSrc = sync('website/raw_sprites/spritesmith_large/**/*.png');
|
||||
return createSpritesStream('largeSprites', largeSrc);
|
||||
});
|
||||
|
||||
gulp.task('sprites:clean', (done) => {
|
||||
gulp.task('sprites:clean', done => {
|
||||
clean(`${IMG_DIST_PATH}spritesmith*,${CSS_DIST_PATH}spritesmith*}`, done);
|
||||
});
|
||||
|
||||
gulp.task('sprites:checkCompiledDimensions', gulp.series('sprites:main', 'sprites:largeSprites', (done) => {
|
||||
gulp.task('sprites:checkCompiledDimensions', gulp.series('sprites:main', 'sprites:largeSprites', done => {
|
||||
console.log('Verifiying that images do not exceed max dimensions'); // eslint-disable-line no-console
|
||||
|
||||
let numberOfSheetsThatAreTooBig = 0;
|
||||
|
||||
let distSpritesheets = sync(`${IMG_DIST_PATH}*.png`);
|
||||
const distSpritesheets = sync(`${IMG_DIST_PATH}*.png`);
|
||||
|
||||
each(distSpritesheets, (img) => {
|
||||
let spriteSize = calculateImgDimensions(img);
|
||||
each(distSpritesheets, img => {
|
||||
const spriteSize = calculateImgDimensions(img);
|
||||
|
||||
if (spriteSize > MAX_SPRITESHEET_SIZE) {
|
||||
numberOfSheetsThatAreTooBig++;
|
||||
let name = basename(img, '.png');
|
||||
numberOfSheetsThatAreTooBig += 1;
|
||||
const name = basename(img, '.png');
|
||||
console.error(`WARNING: ${name} might be too big - ${spriteSize} > ${MAX_SPRITESHEET_SIZE}`); // eslint-disable-line no-console
|
||||
}
|
||||
});
|
||||
@@ -155,7 +153,8 @@ gulp.task('sprites:checkCompiledDimensions', gulp.series('sprites:main', 'sprite
|
||||
console.error( // eslint-disable-line no-console
|
||||
`${numberOfSheetsThatAreTooBig} sheets might too big for mobile Safari to be able to handle
|
||||
them, but there is a margin of error in these calculations so it is probably okay. Mention
|
||||
this to an admin so they can test a staging site on mobile Safari after your PR is merged.`);
|
||||
this to an admin so they can test a staging site on mobile Safari after your PR is merged.`,
|
||||
);
|
||||
} else {
|
||||
console.log('All images are within the correct dimensions'); // eslint-disable-line no-console
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import gulp from 'gulp';
|
||||
import nodemon from 'gulp-nodemon';
|
||||
|
||||
let pkg = require('../package.json');
|
||||
const pkg = require('../package.json');
|
||||
|
||||
gulp.task('nodemon', (done) => {
|
||||
gulp.task('nodemon', done => {
|
||||
nodemon({
|
||||
script: pkg.main,
|
||||
ignore: [
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import {
|
||||
pipe,
|
||||
} from './taskHelper';
|
||||
import mongoose from 'mongoose';
|
||||
import { exec } from 'child_process';
|
||||
import gulp from 'gulp';
|
||||
import os from 'os';
|
||||
import nconf from 'nconf';
|
||||
import {
|
||||
pipe,
|
||||
} from './taskHelper';
|
||||
|
||||
// TODO rewrite
|
||||
|
||||
@@ -17,44 +17,43 @@ const TEST_DB_URI = nconf.get('TEST_DB_URI');
|
||||
const SANITY_TEST_COMMAND = 'npm run test:sanity';
|
||||
const COMMON_TEST_COMMAND = 'npm run test:common';
|
||||
const CONTENT_TEST_COMMAND = 'npm run test:content';
|
||||
const CONTENT_OPTIONS = {maxBuffer: 1024 * 500};
|
||||
const CONTENT_OPTIONS = { maxBuffer: 1024 * 500 };
|
||||
|
||||
/* Helper methods for reporting test summary */
|
||||
let testResults = [];
|
||||
let testCount = (stdout, regexp) => {
|
||||
let match = stdout.match(regexp);
|
||||
return parseInt(match && match[1] || 0, 10);
|
||||
const testResults = [];
|
||||
const testCount = (stdout, regexp) => {
|
||||
const match = stdout.match(regexp);
|
||||
return parseInt(match && (match[1] || 0), 10);
|
||||
};
|
||||
|
||||
let testBin = (string, additionalEnvVariables = '') => {
|
||||
const testBin = (string, additionalEnvVariables = '') => {
|
||||
if (os.platform() === 'win32') {
|
||||
if (additionalEnvVariables !== '') {
|
||||
additionalEnvVariables = additionalEnvVariables.split(' ').join('&&set ');
|
||||
additionalEnvVariables = `set ${additionalEnvVariables}&&`;
|
||||
}
|
||||
return `set NODE_ENV=test&&${additionalEnvVariables}${string}`;
|
||||
} else {
|
||||
return `NODE_ENV=test ${additionalEnvVariables} ${string}`;
|
||||
}
|
||||
return `NODE_ENV=test ${additionalEnvVariables} ${string}`;
|
||||
};
|
||||
|
||||
gulp.task('test:nodemon', gulp.series(function setupNodemon (done) {
|
||||
gulp.task('test:nodemon', gulp.series(done => {
|
||||
process.env.PORT = TEST_SERVER_PORT; // eslint-disable-line no-process-env
|
||||
process.env.NODE_DB_URI = TEST_DB_URI; // eslint-disable-line no-process-env
|
||||
done();
|
||||
}, 'nodemon'));
|
||||
|
||||
gulp.task('test:prepare:mongo', (cb) => {
|
||||
mongoose.connect(TEST_DB_URI, (err) => {
|
||||
gulp.task('test:prepare:mongo', cb => {
|
||||
mongoose.connect(TEST_DB_URI, err => {
|
||||
if (err) return cb(`Unable to connect to mongo database. Are you sure it's running? \n\n${err}`);
|
||||
mongoose.connection.dropDatabase((err2) => {
|
||||
mongoose.connection.dropDatabase(err2 => {
|
||||
if (err2) return cb(err2);
|
||||
mongoose.connection.close(cb);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
gulp.task('test:prepare:server', gulp.series('test:prepare:mongo', (done) => {
|
||||
gulp.task('test:prepare:server', gulp.series('test:prepare:mongo', done => {
|
||||
if (!server) {
|
||||
server = exec(testBin('node ./website/server/index.js', `NODE_DB_URI=${TEST_DB_URI} PORT=${TEST_SERVER_PORT}`), (error, stdout, stderr) => {
|
||||
if (error) {
|
||||
@@ -73,45 +72,43 @@ gulp.task('test:prepare:build', gulp.series('build', done => done()));
|
||||
gulp.task('test:prepare', gulp.series(
|
||||
'test:prepare:build',
|
||||
'test:prepare:mongo',
|
||||
done => done()
|
||||
done => done(),
|
||||
));
|
||||
|
||||
gulp.task('test:sanity', (cb) => {
|
||||
let runner = exec(
|
||||
gulp.task('test:sanity', cb => {
|
||||
const runner = exec(
|
||||
testBin(SANITY_TEST_COMMAND),
|
||||
(err) => {
|
||||
err => {
|
||||
if (err) {
|
||||
process.exit(1);
|
||||
}
|
||||
cb();
|
||||
}
|
||||
},
|
||||
);
|
||||
pipe(runner);
|
||||
});
|
||||
|
||||
gulp.task('test:common', gulp.series('test:prepare:build', (cb) => {
|
||||
let runner = exec(
|
||||
gulp.task('test:common', gulp.series('test:prepare:build', cb => {
|
||||
const runner = exec(
|
||||
testBin(COMMON_TEST_COMMAND),
|
||||
(err) => {
|
||||
err => {
|
||||
if (err) {
|
||||
process.exit(1);
|
||||
}
|
||||
cb();
|
||||
}
|
||||
},
|
||||
);
|
||||
pipe(runner);
|
||||
}));
|
||||
|
||||
gulp.task('test:common:clean', (cb) => {
|
||||
gulp.task('test:common:clean', cb => {
|
||||
pipe(exec(testBin(COMMON_TEST_COMMAND), () => cb()));
|
||||
});
|
||||
|
||||
gulp.task('test:common:watch', gulp.series('test:common:clean', () => {
|
||||
return gulp.watch(['common/script/**/*', 'test/common/**/*'], gulp.series('test:common:clean', done => done()));
|
||||
}));
|
||||
gulp.task('test:common:watch', gulp.series('test:common:clean', () => gulp.watch(['common/script/**/*', 'test/common/**/*'], gulp.series('test:common:clean', done => done()))));
|
||||
|
||||
gulp.task('test:common:safe', gulp.series('test:prepare:build', (cb) => {
|
||||
let runner = exec(
|
||||
gulp.task('test:common:safe', gulp.series('test:prepare:build', cb => {
|
||||
const runner = exec(
|
||||
testBin(COMMON_TEST_COMMAND),
|
||||
(err, stdout) => { // eslint-disable-line handle-callback-err
|
||||
testResults.push({
|
||||
@@ -121,35 +118,33 @@ gulp.task('test:common:safe', gulp.series('test:prepare:build', (cb) => {
|
||||
pend: testCount(stdout, /(\d+) pending/),
|
||||
});
|
||||
cb();
|
||||
}
|
||||
},
|
||||
);
|
||||
pipe(runner);
|
||||
}));
|
||||
|
||||
gulp.task('test:content', gulp.series('test:prepare:build', (cb) => {
|
||||
let runner = exec(
|
||||
gulp.task('test:content', gulp.series('test:prepare:build', cb => {
|
||||
const runner = exec(
|
||||
testBin(CONTENT_TEST_COMMAND),
|
||||
CONTENT_OPTIONS,
|
||||
(err) => {
|
||||
err => {
|
||||
if (err) {
|
||||
process.exit(1);
|
||||
}
|
||||
cb();
|
||||
}
|
||||
},
|
||||
);
|
||||
pipe(runner);
|
||||
}));
|
||||
|
||||
gulp.task('test:content:clean', (cb) => {
|
||||
gulp.task('test:content:clean', cb => {
|
||||
pipe(exec(testBin(CONTENT_TEST_COMMAND), CONTENT_OPTIONS, () => cb()));
|
||||
});
|
||||
|
||||
gulp.task('test:content:watch', gulp.series('test:content:clean', () => {
|
||||
return gulp.watch(['common/script/content/**', 'test/**'], gulp.series('test:content:clean', done => done()));
|
||||
}));
|
||||
gulp.task('test:content:watch', gulp.series('test:content:clean', () => gulp.watch(['common/script/content/**', 'test/**'], gulp.series('test:content:clean', done => done()))));
|
||||
|
||||
gulp.task('test:content:safe', gulp.series('test:prepare:build', (cb) => {
|
||||
let runner = exec(
|
||||
gulp.task('test:content:safe', gulp.series('test:prepare:build', cb => {
|
||||
const runner = exec(
|
||||
testBin(CONTENT_TEST_COMMAND),
|
||||
CONTENT_OPTIONS,
|
||||
(err, stdout) => { // eslint-disable-line handle-callback-err
|
||||
@@ -160,81 +155,77 @@ gulp.task('test:content:safe', gulp.series('test:prepare:build', (cb) => {
|
||||
pend: testCount(stdout, /(\d+) pending/),
|
||||
});
|
||||
cb();
|
||||
}
|
||||
},
|
||||
);
|
||||
pipe(runner);
|
||||
}));
|
||||
|
||||
gulp.task('test:api:unit', (done) => {
|
||||
let runner = exec(
|
||||
gulp.task('test:api:unit', done => {
|
||||
const runner = exec(
|
||||
testBin('istanbul cover --dir coverage/api-unit node_modules/mocha/bin/_mocha -- test/api/unit --recursive --require ./test/helpers/start-server'),
|
||||
(err) => {
|
||||
err => {
|
||||
if (err) {
|
||||
process.exit(1);
|
||||
}
|
||||
done();
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
pipe(runner);
|
||||
});
|
||||
|
||||
gulp.task('test:api:unit:watch', () => {
|
||||
return gulp.watch(['website/server/libs/*', 'test/api/unit/**/*', 'website/server/controllers/**/*'], gulp.series('test:api:unit', done => done()));
|
||||
});
|
||||
gulp.task('test:api:unit:watch', () => gulp.watch(['website/server/libs/*', 'test/api/unit/**/*', 'website/server/controllers/**/*'], gulp.series('test:api:unit', done => done())));
|
||||
|
||||
gulp.task('test:api-v3:integration', (done) => {
|
||||
let runner = exec(
|
||||
gulp.task('test:api-v3:integration', done => {
|
||||
const runner = exec(
|
||||
testBin('istanbul cover --dir coverage/api-v3-integration --report lcovonly node_modules/mocha/bin/_mocha -- test/api/v3/integration --recursive --require ./test/helpers/start-server'),
|
||||
{maxBuffer: 500 * 1024},
|
||||
(err) => {
|
||||
{ maxBuffer: 500 * 1024 },
|
||||
err => {
|
||||
if (err) {
|
||||
process.exit(1);
|
||||
}
|
||||
done();
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
pipe(runner);
|
||||
});
|
||||
|
||||
gulp.task('test:api-v3:integration:watch', () => {
|
||||
return gulp.watch([
|
||||
gulp.task('test:api-v3:integration:watch', () => gulp.watch([
|
||||
'website/server/controllers/api-v3/**/*', 'common/script/ops/*', 'website/server/libs/*.js',
|
||||
'test/api/v3/integration/**/*',
|
||||
], gulp.series('test:api-v3:integration', done => done()));
|
||||
});
|
||||
], gulp.series('test:api-v3:integration', done => done())));
|
||||
|
||||
gulp.task('test:api-v3:integration:separate-server', (done) => {
|
||||
let runner = exec(
|
||||
gulp.task('test:api-v3:integration:separate-server', done => {
|
||||
const runner = exec(
|
||||
testBin('mocha test/api/v3/integration --recursive --require ./test/helpers/start-server', 'LOAD_SERVER=0'),
|
||||
{maxBuffer: 500 * 1024},
|
||||
(err) => done(err)
|
||||
{ maxBuffer: 500 * 1024 },
|
||||
err => done(err),
|
||||
);
|
||||
|
||||
pipe(runner);
|
||||
});
|
||||
|
||||
gulp.task('test:api-v4:integration', (done) => {
|
||||
let runner = exec(
|
||||
gulp.task('test:api-v4:integration', done => {
|
||||
const runner = exec(
|
||||
testBin('istanbul cover --dir coverage/api-v4-integration --report lcovonly node_modules/mocha/bin/_mocha -- test/api/v4 --recursive --require ./test/helpers/start-server'),
|
||||
{maxBuffer: 500 * 1024},
|
||||
(err) => {
|
||||
{ maxBuffer: 500 * 1024 },
|
||||
err => {
|
||||
if (err) {
|
||||
process.exit(1);
|
||||
}
|
||||
done();
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
pipe(runner);
|
||||
});
|
||||
|
||||
gulp.task('test:api-v4:integration:separate-server', (done) => {
|
||||
let runner = exec(
|
||||
gulp.task('test:api-v4:integration:separate-server', done => {
|
||||
const runner = exec(
|
||||
testBin('mocha test/api/v4 --recursive --require ./test/helpers/start-server', 'LOAD_SERVER=0'),
|
||||
{maxBuffer: 500 * 1024},
|
||||
(err) => done(err)
|
||||
{ maxBuffer: 500 * 1024 },
|
||||
err => done(err),
|
||||
);
|
||||
|
||||
pipe(runner);
|
||||
@@ -247,11 +238,11 @@ gulp.task('test', gulp.series(
|
||||
'test:api:unit',
|
||||
'test:api-v3:integration',
|
||||
'test:api-v4:integration',
|
||||
done => done()
|
||||
done => done(),
|
||||
));
|
||||
|
||||
gulp.task('test:api-v3', gulp.series(
|
||||
'test:api:unit',
|
||||
'test:api-v3:integration',
|
||||
done => done()
|
||||
done => done(),
|
||||
));
|
||||
|
||||
@@ -14,7 +14,7 @@ const ENGLISH_LOCALE = `${LOCALES}en/`;
|
||||
|
||||
|
||||
function getArrayOfLanguages () {
|
||||
let languages = fs.readdirSync(LOCALES);
|
||||
const languages = fs.readdirSync(LOCALES);
|
||||
languages.shift(); // Remove README.md from array of languages
|
||||
|
||||
return languages;
|
||||
@@ -23,18 +23,16 @@ function getArrayOfLanguages () {
|
||||
const ALL_LANGUAGES = getArrayOfLanguages();
|
||||
|
||||
function stripOutNonJsonFiles (collection) {
|
||||
let onlyJson = _.filter(collection, (file) => {
|
||||
return file.match(/[a-zA-Z]*\.json/);
|
||||
});
|
||||
const onlyJson = _.filter(collection, file => file.match(/[a-zA-Z]*\.json/));
|
||||
|
||||
return onlyJson;
|
||||
}
|
||||
|
||||
function eachTranslationFile (languages, cb) {
|
||||
let jsonFiles = stripOutNonJsonFiles(fs.readdirSync(ENGLISH_LOCALE));
|
||||
const jsonFiles = stripOutNonJsonFiles(fs.readdirSync(ENGLISH_LOCALE));
|
||||
|
||||
_.each(languages, (lang) => {
|
||||
_.each(jsonFiles, (filename) => {
|
||||
_.each(languages, lang => {
|
||||
_.each(jsonFiles, filename => {
|
||||
let parsedTranslationFile;
|
||||
try {
|
||||
const translationFile = fs.readFileSync(`${LOCALES}${lang}/${filename}`);
|
||||
@@ -43,8 +41,8 @@ function eachTranslationFile (languages, cb) {
|
||||
return cb(err);
|
||||
}
|
||||
|
||||
let englishFile = fs.readFileSync(ENGLISH_LOCALE + filename);
|
||||
let parsedEnglishFile = JSON.parse(englishFile);
|
||||
const englishFile = fs.readFileSync(ENGLISH_LOCALE + filename);
|
||||
const parsedEnglishFile = JSON.parse(englishFile);
|
||||
|
||||
cb(null, lang, filename, parsedEnglishFile, parsedTranslationFile);
|
||||
});
|
||||
@@ -71,9 +69,9 @@ function formatMessageForPosting (msg, items) {
|
||||
}
|
||||
|
||||
function getStringsWith (json, interpolationRegex) {
|
||||
let strings = {};
|
||||
const strings = {};
|
||||
|
||||
_.each(json, (fileName) => {
|
||||
_.each(json, fileName => {
|
||||
const rawFile = fs.readFileSync(ENGLISH_LOCALE + fileName);
|
||||
const parsedJson = JSON.parse(rawFile);
|
||||
|
||||
@@ -93,66 +91,69 @@ const malformedStringExceptions = {
|
||||
feedPet: true,
|
||||
};
|
||||
|
||||
gulp.task('transifex:missingFiles', (done) => {
|
||||
let missingStrings = [];
|
||||
gulp.task('transifex:missingFiles', done => {
|
||||
const missingStrings = [];
|
||||
|
||||
eachTranslationFile(ALL_LANGUAGES, (error) => {
|
||||
eachTranslationFile(ALL_LANGUAGES, error => {
|
||||
if (error) {
|
||||
missingStrings.push(error.path);
|
||||
}
|
||||
});
|
||||
|
||||
if (!_.isEmpty(missingStrings)) {
|
||||
let message = 'the following files were missing from the translations folder';
|
||||
let formattedMessage = formatMessageForPosting(message, missingStrings);
|
||||
const message = 'the following files were missing from the translations folder';
|
||||
const formattedMessage = formatMessageForPosting(message, missingStrings);
|
||||
postToSlack(formattedMessage, SLACK_CONFIG);
|
||||
}
|
||||
done();
|
||||
});
|
||||
|
||||
gulp.task('transifex:missingStrings', (done) => {
|
||||
let missingStrings = [];
|
||||
gulp.task('transifex:missingStrings', done => {
|
||||
const missingStrings = [];
|
||||
|
||||
eachTranslationString(ALL_LANGUAGES, (language, filename, key, englishString, translationString) => {
|
||||
eachTranslationString(ALL_LANGUAGES, (lang, filename, key, englishString, translationString) => {
|
||||
if (!translationString) {
|
||||
let errorString = `${language} - ${filename} - ${key} - ${englishString}`;
|
||||
const errorString = `${lang} - ${filename} - ${key} - ${englishString}`;
|
||||
missingStrings.push(errorString);
|
||||
}
|
||||
});
|
||||
|
||||
if (!_.isEmpty(missingStrings)) {
|
||||
let message = 'The following strings are not translated';
|
||||
let formattedMessage = formatMessageForPosting(message, missingStrings);
|
||||
const message = 'The following strings are not translated';
|
||||
const formattedMessage = formatMessageForPosting(message, missingStrings);
|
||||
postToSlack(formattedMessage, SLACK_CONFIG);
|
||||
}
|
||||
done();
|
||||
});
|
||||
|
||||
gulp.task('transifex:malformedStrings', (done) => {
|
||||
let jsonFiles = stripOutNonJsonFiles(fs.readdirSync(ENGLISH_LOCALE));
|
||||
let interpolationRegex = /<%= [a-zA-Z]* %>/g;
|
||||
let stringsToLookFor = getStringsWith(jsonFiles, interpolationRegex);
|
||||
gulp.task('transifex:malformedStrings', done => {
|
||||
const jsonFiles = stripOutNonJsonFiles(fs.readdirSync(ENGLISH_LOCALE));
|
||||
const interpolationRegex = /<%= [a-zA-Z]* %>/g;
|
||||
const stringsToLookFor = getStringsWith(jsonFiles, interpolationRegex);
|
||||
|
||||
let stringsWithMalformedInterpolations = [];
|
||||
let stringsWithIncorrectNumberOfInterpolations = [];
|
||||
const stringsWithMalformedInterpolations = [];
|
||||
const stringsWithIncorrectNumberOfInterpolations = [];
|
||||
|
||||
_.each(ALL_LANGUAGES, (lang) => {
|
||||
_.each(ALL_LANGUAGES, lang => {
|
||||
_.each(stringsToLookFor, (strings, filename) => {
|
||||
let translationFile = fs.readFileSync(`${LOCALES}${lang}/${filename}`);
|
||||
let parsedTranslationFile = JSON.parse(translationFile);
|
||||
const translationFile = fs.readFileSync(`${LOCALES}${lang}/${filename}`);
|
||||
const parsedTranslationFile = JSON.parse(translationFile);
|
||||
|
||||
_.each(strings, (value, key) => { // eslint-disable-line max-nested-callbacks
|
||||
let translationString = parsedTranslationFile[key];
|
||||
const translationString = parsedTranslationFile[key];
|
||||
if (!translationString) return;
|
||||
|
||||
let englishOccurences = stringsToLookFor[filename][key];
|
||||
let translationOccurences = translationString.match(interpolationRegex);
|
||||
const englishOccurences = stringsToLookFor[filename][key];
|
||||
const translationOccurences = translationString.match(interpolationRegex);
|
||||
|
||||
if (!translationOccurences) {
|
||||
let malformedString = `${lang} - ${filename} - ${key} - ${translationString}`;
|
||||
const malformedString = `${lang} - ${filename} - ${key} - ${translationString}`;
|
||||
stringsWithMalformedInterpolations.push(malformedString);
|
||||
} else if (englishOccurences.length !== translationOccurences.length && !malformedStringExceptions[key]) {
|
||||
let missingInterpolationString = `${lang} - ${filename} - ${key} - ${translationString}`;
|
||||
} else if (
|
||||
englishOccurences.length !== translationOccurences.length
|
||||
&& !malformedStringExceptions[key]
|
||||
) {
|
||||
const missingInterpolationString = `${lang} - ${filename} - ${key} - ${translationString}`;
|
||||
stringsWithIncorrectNumberOfInterpolations.push(missingInterpolationString);
|
||||
}
|
||||
});
|
||||
@@ -160,14 +161,17 @@ gulp.task('transifex:malformedStrings', (done) => {
|
||||
});
|
||||
|
||||
if (!_.isEmpty(stringsWithMalformedInterpolations)) {
|
||||
let message = 'The following strings have malformed or missing interpolations';
|
||||
let formattedMessage = formatMessageForPosting(message, stringsWithMalformedInterpolations);
|
||||
const message = 'The following strings have malformed or missing interpolations';
|
||||
const formattedMessage = formatMessageForPosting(message, stringsWithMalformedInterpolations);
|
||||
postToSlack(formattedMessage, SLACK_CONFIG);
|
||||
}
|
||||
|
||||
if (!_.isEmpty(stringsWithIncorrectNumberOfInterpolations)) {
|
||||
let message = 'The following strings have a different number of string interpolations';
|
||||
let formattedMessage = formatMessageForPosting(message, stringsWithIncorrectNumberOfInterpolations);
|
||||
const message = 'The following strings have a different number of string interpolations';
|
||||
const formattedMessage = formatMessageForPosting(
|
||||
message,
|
||||
stringsWithIncorrectNumberOfInterpolations,
|
||||
);
|
||||
postToSlack(formattedMessage, SLACK_CONFIG);
|
||||
}
|
||||
done();
|
||||
@@ -176,5 +180,5 @@ gulp.task('transifex:malformedStrings', (done) => {
|
||||
gulp.task(
|
||||
'transifex',
|
||||
gulp.series('transifex:missingFiles', 'transifex:missingStrings', 'transifex:malformedStrings'),
|
||||
(done) => done()
|
||||
done => done(),
|
||||
);
|
||||
@@ -4,7 +4,7 @@ import nconf from 'nconf';
|
||||
import net from 'net';
|
||||
import { post } from 'superagent';
|
||||
import { sync as glob } from 'glob';
|
||||
import Mocha from 'mocha';
|
||||
import Mocha from 'mocha'; // eslint-disable-line import/no-extraneous-dependencies
|
||||
import { resolve } from 'path';
|
||||
|
||||
/*
|
||||
@@ -19,15 +19,15 @@ export const conf = nconf;
|
||||
* its tasks.
|
||||
*/
|
||||
export function kill (proc) {
|
||||
let killProcess = (pid) => {
|
||||
const killProcess = pid => {
|
||||
psTree(pid, (_, pids) => {
|
||||
if (pids.length) {
|
||||
pids.forEach(kill); return;
|
||||
}
|
||||
try {
|
||||
exec(/^win/.test(process.platform) ?
|
||||
`taskkill /PID ${pid} /T /F` :
|
||||
`kill -9 ${pid}`);
|
||||
exec(/^win/.test(process.platform)
|
||||
? `taskkill /PID ${pid} /T /F`
|
||||
: `kill -9 ${pid}`);
|
||||
} catch (e) {
|
||||
console.log(e); // eslint-disable-line no-console
|
||||
}
|
||||
@@ -46,16 +46,15 @@ export function kill (proc) {
|
||||
export function awaitPort (port, max = 60) {
|
||||
return new Promise((rej, res) => {
|
||||
let socket;
|
||||
let timeout;
|
||||
let interval;
|
||||
|
||||
timeout = setTimeout(() => {
|
||||
const timeout = setTimeout(() => {
|
||||
clearInterval(interval);
|
||||
rej(`Timed out after ${max} seconds`);
|
||||
}, max * 1000);
|
||||
|
||||
interval = setInterval(() => {
|
||||
socket = net.connect({port}, () => {
|
||||
socket = net.connect({ port }, () => {
|
||||
clearInterval(interval);
|
||||
clearTimeout(timeout);
|
||||
socket.destroy();
|
||||
@@ -71,10 +70,10 @@ export function awaitPort (port, max = 60) {
|
||||
* Pipe the child's stdin and stderr to the parent process.
|
||||
*/
|
||||
export function pipe (child) {
|
||||
child.stdout.on('data', (data) => {
|
||||
child.stdout.on('data', data => {
|
||||
process.stdout.write(data);
|
||||
});
|
||||
child.stderr.on('data', (data) => {
|
||||
child.stderr.on('data', data => {
|
||||
process.stderr.write(data);
|
||||
});
|
||||
}
|
||||
@@ -83,7 +82,7 @@ export function pipe (child) {
|
||||
* Post request to notify configured slack channel
|
||||
*/
|
||||
export function postToSlack (msg, config = {}) {
|
||||
let slackUrl = nconf.get('SLACK_URL');
|
||||
const slackUrl = nconf.get('SLACK_URL');
|
||||
|
||||
if (!slackUrl) {
|
||||
console.error('No slack post url specified. Your message was:'); // eslint-disable-line no-console
|
||||
@@ -99,7 +98,7 @@ export function postToSlack (msg, config = {}) {
|
||||
text: msg,
|
||||
icon_emoji: `:${config.emoji || 'gulp'}:`, // eslint-disable-line camelcase
|
||||
})
|
||||
.end((err) => {
|
||||
.end(err => {
|
||||
if (err) console.error('Unable to post to slack', err); // eslint-disable-line no-console
|
||||
});
|
||||
}
|
||||
@@ -107,15 +106,15 @@ export function postToSlack (msg, config = {}) {
|
||||
export function runMochaTests (files, server, cb) {
|
||||
require('../test/helpers/globals.helper'); // eslint-disable-line global-require
|
||||
|
||||
let mocha = new Mocha({reporter: 'spec'});
|
||||
let tests = glob(files);
|
||||
const mocha = new Mocha({ reporter: 'spec' });
|
||||
const tests = glob(files);
|
||||
|
||||
tests.forEach((test) => {
|
||||
tests.forEach(test => {
|
||||
delete require.cache[resolve(test)];
|
||||
mocha.addFile(test);
|
||||
});
|
||||
|
||||
mocha.run((numberOfFailures) => {
|
||||
mocha.run(numberOfFailures => {
|
||||
if (!process.env.RUN_INTEGRATION_TEST_FOREVER) { // eslint-disable-line no-process-env
|
||||
if (server) kill(server);
|
||||
process.exit(numberOfFailures);
|
||||
|
||||
@@ -2,14 +2,14 @@ import { model as Challenges } from '../../website/server/models/challenge';
|
||||
import { model as User } from '../../website/server/models/user';
|
||||
|
||||
async function syncChallengeToMembers (challenges) {
|
||||
let challengSyncPromises = challenges.map(async (challenge) => {
|
||||
let users = await User.find({
|
||||
const challengSyncPromises = challenges.map(async challenge => {
|
||||
const users = await User.find({
|
||||
// _id: '',
|
||||
challenges: challenge._id,
|
||||
}).exec();
|
||||
|
||||
let promises = [];
|
||||
users.forEach((user) => {
|
||||
const promises = [];
|
||||
users.forEach(user => {
|
||||
promises.push(challenge.syncToUser(user));
|
||||
promises.push(challenge.save());
|
||||
promises.push(user.save());
|
||||
@@ -22,7 +22,7 @@ async function syncChallengeToMembers (challenges) {
|
||||
}
|
||||
|
||||
async function syncChallenges (lastChallengeDate) {
|
||||
let query = {
|
||||
const query = {
|
||||
// _id: '',
|
||||
};
|
||||
|
||||
@@ -30,14 +30,14 @@ async function syncChallenges (lastChallengeDate) {
|
||||
query.createdOn = { $lte: lastChallengeDate };
|
||||
}
|
||||
|
||||
let challengesFound = await Challenges.find(query)
|
||||
const challengesFound = await Challenges.find(query)
|
||||
.limit(10)
|
||||
.sort('-createdAt')
|
||||
.exec();
|
||||
|
||||
let syncedChallenges = await syncChallengeToMembers(challengesFound)
|
||||
const syncedChallenges = await syncChallengeToMembers(challengesFound)
|
||||
.catch(reason => console.error(reason));
|
||||
let lastChallenge = challengesFound[challengesFound.length - 1];
|
||||
const lastChallenge = challengesFound[challengesFound.length - 1];
|
||||
if (lastChallenge) syncChallenges(lastChallenge.createdAt);
|
||||
return syncedChallenges;
|
||||
}
|
||||
|
||||
@@ -1 +1 @@
|
||||
db.users.update({_id: {$in: ['']}}, {$inc: {balance: 0.5}}, {multi: true});
|
||||
db.users.update({ _id: { $in: [''] } }, { $inc: { balance: 0.5 } }, { multi: true });
|
||||
|
||||
@@ -4,8 +4,10 @@
|
||||
// the FAQ (http://goo.gl/1uoPGQ) they insist...
|
||||
|
||||
db.users.update(
|
||||
{_id: ''},
|
||||
{$set: {
|
||||
{ _id: '' },
|
||||
{
|
||||
$set: {
|
||||
'purchased.plan.dateTerminated': moment().add('month', 1).toDate(),
|
||||
}}
|
||||
},
|
||||
},
|
||||
);
|
||||
@@ -2,7 +2,7 @@
|
||||
db.users.update(
|
||||
|
||||
{
|
||||
'contributor.level': {$gte: 7},
|
||||
'contributor.level': { $gte: 7 },
|
||||
'purchased.plan.customerId': null,
|
||||
},
|
||||
|
||||
@@ -18,6 +18,6 @@ db.users.update(
|
||||
},
|
||||
},
|
||||
|
||||
{multi: true}
|
||||
{ multi: true },
|
||||
|
||||
);
|
||||
@@ -1,5 +1,5 @@
|
||||
// mongo habitrpg ./node_modules/moment/moment.js ./migrations/current_period_end.js
|
||||
db.users.update(
|
||||
{_id: ''},
|
||||
{$set: {'purchased.plan.dateTerminated': moment().add({days: 7}).toDate()}}
|
||||
{ _id: '' },
|
||||
{ $set: { 'purchased.plan.dateTerminated': moment().add({ days: 7 }).toDate() } },
|
||||
);
|
||||
@@ -39,38 +39,52 @@
|
||||
// needed. Do not miss any of them!
|
||||
|
||||
|
||||
let uuid = '30fb2640-7121-4968-ace5-f385e60ea6c5';
|
||||
const uuid = '30fb2640-7121-4968-ace5-f385e60ea6c5';
|
||||
|
||||
db.users.aggregate([
|
||||
{$match: {
|
||||
{
|
||||
$match: {
|
||||
_id: uuid,
|
||||
}},
|
||||
{$project: {
|
||||
},
|
||||
},
|
||||
{
|
||||
$project: {
|
||||
_id: 0, todos: 1,
|
||||
}},
|
||||
{$unwind: '$todos'},
|
||||
{$group: {
|
||||
},
|
||||
},
|
||||
{ $unwind: '$todos' },
|
||||
{
|
||||
$group: {
|
||||
_id: { taskid: '$todos.id' },
|
||||
count: { $sum: 1 },
|
||||
}},
|
||||
{$match: {
|
||||
},
|
||||
},
|
||||
{
|
||||
$match: {
|
||||
count: { $gt: 1 },
|
||||
}},
|
||||
{$project: {
|
||||
},
|
||||
},
|
||||
{
|
||||
$project: {
|
||||
'_id.taskid': 1,
|
||||
}},
|
||||
{$group: {
|
||||
},
|
||||
},
|
||||
{
|
||||
$group: {
|
||||
_id: { taskid: '$todos.id' },
|
||||
troublesomeIds: { $addToSet: '$_id.taskid' },
|
||||
}},
|
||||
{$project: {
|
||||
},
|
||||
},
|
||||
{
|
||||
$project: {
|
||||
_id: 0,
|
||||
troublesomeIds: 1,
|
||||
}},
|
||||
]).forEach((data) => {
|
||||
},
|
||||
},
|
||||
]).forEach(data => {
|
||||
// print( "\n" ); printjson(data);
|
||||
data.troublesomeIds.forEach((taskid) => {
|
||||
print(`non-unique task: ${ taskid}`);
|
||||
data.troublesomeIds.forEach(taskid => {
|
||||
print(`non-unique task: ${taskid}`);
|
||||
db.users.update({
|
||||
_id: uuid,
|
||||
todos: { $elemMatch: { id: taskid } },
|
||||
@@ -81,8 +95,7 @@ db.users.aggregate([
|
||||
});
|
||||
|
||||
db.users.update(
|
||||
{_id: uuid},
|
||||
{$pull: { todos: { id: 'de666' } } },
|
||||
{multi: false }
|
||||
{ _id: uuid },
|
||||
{ $pull: { todos: { id: 'de666' } } },
|
||||
{ multi: false },
|
||||
);
|
||||
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
let oldId = '';
|
||||
let newId = '';
|
||||
let newUser = db.users.findOne({_id: newId});
|
||||
const oldId = '';
|
||||
const newId = '';
|
||||
const newUser = db.users.findOne({ _id: newId });
|
||||
|
||||
db.users.update({_id: oldId}, {$set: {auth: newUser.auth}});
|
||||
db.users.update({ _id: oldId }, { $set: { auth: newUser.auth } });
|
||||
|
||||
// remove the auth on the new user (which is a template account). The account will be preened automatically later,
|
||||
// this allows us to keep the account around a few days in case there was a mistake
|
||||
db.users.update({_id: newId}, {$unset: {auth: 1}});
|
||||
|
||||
db.users.update({ _id: newId }, { $unset: { auth: 1 } });
|
||||
|
||||
@@ -5,8 +5,8 @@
|
||||
* Past in the text of a unique habit here to find the user, then you can restore their UUID
|
||||
*/
|
||||
|
||||
db.users.find().forEach((user) => {
|
||||
db.users.find().forEach(user => {
|
||||
user.tasks = user.habits.concat(user.dailys).concat(user.todos).concat(user.rewards);
|
||||
let found = _.some(user.tasks, {text: ''});
|
||||
if (found) printjson({id: user._id, auth: user.auth});
|
||||
const found = _.some(user.tasks, { text: '' });
|
||||
if (found) printjson({ id: user._id, auth: user.auth });
|
||||
});
|
||||
@@ -1,13 +1,15 @@
|
||||
// mongo habitrpg ./node_modules/moment/moment.js ./migrations/freeMonth.js
|
||||
|
||||
db.users.update(
|
||||
{_id: ''},
|
||||
{$set: {
|
||||
{ _id: '' },
|
||||
{
|
||||
$set: {
|
||||
'purchased.plan.customerId': 'temporary',
|
||||
'purchased.plan.paymentMethod': 'Stripe',
|
||||
'purchased.plan.planId': 'basic_earned',
|
||||
'purchased.plan.dateTerminated': moment().add('month', 1).toDate(),
|
||||
}}
|
||||
},
|
||||
},
|
||||
);
|
||||
// var m = 12;
|
||||
// db.users.update(
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
db.users.update(
|
||||
{},
|
||||
{$inc: {'achievements.habiticaDays': 1}},
|
||||
{multi: 1}
|
||||
{ $inc: { 'achievements.habiticaDays': 1 } },
|
||||
{ multi: 1 },
|
||||
);
|
||||
|
||||
@@ -1 +1 @@
|
||||
db.users.update({_id: ''}, {$inc: {balance: 5}});
|
||||
db.users.update({ _id: '' }, { $inc: { balance: 5 } });
|
||||
|
||||
@@ -13,7 +13,7 @@ import { model as Group } from '../../website/server/models/group';
|
||||
|
||||
// @TODO: this should probably be a GroupManager library method
|
||||
async function addUnlimitedSubscription (groupId, dateTerminated) {
|
||||
let group = await Group.findOne({_id: groupId});
|
||||
const group = await Group.findOne({ _id: groupId });
|
||||
|
||||
group.purchased.plan.customerId = 'group-unlimited';
|
||||
group.purchased.plan.dateCreated = new Date();
|
||||
@@ -22,7 +22,7 @@ async function addUnlimitedSubscription (groupId, dateTerminated) {
|
||||
group.purchased.plan.planId = 'group_monthly';
|
||||
group.purchased.plan.dateTerminated = null;
|
||||
if (dateTerminated) {
|
||||
let dateToEnd = moment(dateTerminated).toDate();
|
||||
const dateToEnd = moment(dateTerminated).toDate();
|
||||
group.purchased.plan.dateTerminated = dateToEnd;
|
||||
}
|
||||
// group.purchased.plan.owner = ObjectId();
|
||||
@@ -32,11 +32,11 @@ async function addUnlimitedSubscription (groupId, dateTerminated) {
|
||||
}
|
||||
|
||||
module.exports = async function addUnlimitedSubscriptionCreator () {
|
||||
let groupId = process.argv[2];
|
||||
const groupId = process.argv[2];
|
||||
|
||||
if (!groupId) throw Error('Group ID is required');
|
||||
|
||||
let dateTerminated = process.argv[3];
|
||||
const dateTerminated = process.argv[3];
|
||||
|
||||
await addUnlimitedSubscription(groupId, dateTerminated);
|
||||
};
|
||||
|
||||
@@ -3,9 +3,9 @@ import { model as User } from '../../website/server/models/user';
|
||||
|
||||
// @TODO: this should probably be a GroupManager library method
|
||||
async function createGroup (name, privacy, type, leaderId) {
|
||||
let user = await User.findOne({_id: leaderId});
|
||||
const user = await User.findOne({ _id: leaderId });
|
||||
|
||||
let group = new Group({
|
||||
const group = new Group({
|
||||
name,
|
||||
privacy,
|
||||
type,
|
||||
@@ -18,12 +18,10 @@ async function createGroup (name, privacy, type, leaderId) {
|
||||
}
|
||||
|
||||
module.exports = async function groupCreator () {
|
||||
let name = process.argv[2];
|
||||
let privacy = process.argv[3];
|
||||
let type = process.argv[4];
|
||||
let leaderId = process.argv[5];
|
||||
const name = process.argv[2];
|
||||
const privacy = process.argv[3];
|
||||
const type = process.argv[4];
|
||||
const leaderId = process.argv[5];
|
||||
|
||||
await createGroup(name, privacy, type, leaderId);
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -8,29 +8,27 @@ import { model as Group } from '../../website/server/models/group';
|
||||
import { model as User } from '../../website/server/models/user';
|
||||
|
||||
async function handOutJackalopes () {
|
||||
let promises = [];
|
||||
let cursor = User.find({
|
||||
const promises = [];
|
||||
const cursor = User.find({
|
||||
'purchased.plan.customerId': 'habitrpg',
|
||||
}).cursor();
|
||||
|
||||
cursor.on('data', async (user) => {
|
||||
console.log(`User: ${ user._id}`);
|
||||
cursor.on('data', async user => {
|
||||
console.log(`User: ${user._id}`);
|
||||
|
||||
let groupList = [];
|
||||
if (user.party._id) groupList.push(user.party._id);
|
||||
groupList = groupList.concat(user.guilds);
|
||||
|
||||
let subscribedGroup =
|
||||
await Group.findOne({
|
||||
_id: {$in: groupList},
|
||||
const subscribedGroup = await Group.findOne({
|
||||
_id: { $in: groupList },
|
||||
'purchased.plan.planId': 'group_monthly',
|
||||
'purchased.plan.dateTerminated': null,
|
||||
},
|
||||
{_id: 1}
|
||||
);
|
||||
{ _id: 1 });
|
||||
|
||||
if (subscribedGroup) {
|
||||
User.update({_id: user._id}, {$set: {'items.mounts.Jackalope-RoyalPurple': true}}).exec();
|
||||
User.update({ _id: user._id }, { $set: { 'items.mounts.Jackalope-RoyalPurple': true } }).exec();
|
||||
promises.push(user.save());
|
||||
}
|
||||
});
|
||||
|
||||
@@ -12,8 +12,8 @@ import stripePayments from '../../website/server/libs/payments/stripe';
|
||||
|
||||
const CONNECTION_STRING = nconf.get('MIGRATION_CONNECT_STRING');
|
||||
|
||||
let dbGroups = monk(CONNECTION_STRING).get('groups', { castIds: false });
|
||||
let dbUsers = monk(CONNECTION_STRING).get('users', { castIds: false });
|
||||
const dbGroups = monk(CONNECTION_STRING).get('groups', { castIds: false });
|
||||
const dbUsers = monk(CONNECTION_STRING).get('users', { castIds: false });
|
||||
|
||||
async function fixGroupPlanMembers () {
|
||||
console.info('Group ID, Customer ID, Plan ID, Quantity, Recorded Member Count, Actual Member Count');
|
||||
@@ -24,15 +24,15 @@ async function fixGroupPlanMembers () {
|
||||
{
|
||||
$and:
|
||||
[
|
||||
{'purchased.plan.planId': {$ne: null}},
|
||||
{'purchased.plan.planId': {$ne: ''}},
|
||||
{'purchased.plan.customerId': {$ne: 'cus_9f0DV4g7WHRzpM'}}, // Demo groups
|
||||
{'purchased.plan.customerId': {$ne: 'cus_9maalqDOFTrvqx'}},
|
||||
{ 'purchased.plan.planId': { $ne: null } },
|
||||
{ 'purchased.plan.planId': { $ne: '' } },
|
||||
{ 'purchased.plan.customerId': { $ne: 'cus_9f0DV4g7WHRzpM' } }, // Demo groups
|
||||
{ 'purchased.plan.customerId': { $ne: 'cus_9maalqDOFTrvqx' } },
|
||||
],
|
||||
$or:
|
||||
[
|
||||
{'purchased.plan.dateTerminated': null},
|
||||
{'purchased.plan.dateTerminated': ''},
|
||||
{ 'purchased.plan.dateTerminated': null },
|
||||
{ 'purchased.plan.dateTerminated': '' },
|
||||
],
|
||||
},
|
||||
{
|
||||
@@ -40,8 +40,8 @@ async function fixGroupPlanMembers () {
|
||||
memberCount: 1,
|
||||
'purchased.plan': 1,
|
||||
},
|
||||
}
|
||||
).each(async (group, {close, pause, resume}) => { // eslint-disable-line no-unused-vars
|
||||
},
|
||||
).each(async (group, { close, pause, resume }) => { // eslint-disable-line no-unused-vars
|
||||
pause();
|
||||
groupPlanCount++;
|
||||
|
||||
@@ -49,10 +49,10 @@ async function fixGroupPlanMembers () {
|
||||
{
|
||||
$or:
|
||||
[
|
||||
{'party._id': group._id},
|
||||
{guilds: group._id},
|
||||
{ 'party._id': group._id },
|
||||
{ guilds: group._id },
|
||||
],
|
||||
}
|
||||
},
|
||||
);
|
||||
const incorrectMemberCount = group.memberCount !== canonicalMemberCount;
|
||||
|
||||
@@ -73,7 +73,7 @@ async function fixGroupPlanMembers () {
|
||||
$set: {
|
||||
memberCount: canonicalMemberCount,
|
||||
},
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
if (!groupUpdate) return;
|
||||
@@ -82,15 +82,15 @@ async function fixGroupPlanMembers () {
|
||||
if (group.purchased.plan.paymentMethod === 'Stripe') {
|
||||
await stripePayments.chargeForAdditionalGroupMember(group);
|
||||
await dbGroups.update(
|
||||
{_id: group._id},
|
||||
{$set: {'purchased.plan.quantity': canonicalMemberCount + 2}}
|
||||
{ _id: group._id },
|
||||
{ $set: { 'purchased.plan.quantity': canonicalMemberCount + 2 } },
|
||||
);
|
||||
}
|
||||
|
||||
if (incorrectQuantity) {
|
||||
await dbGroups.update(
|
||||
{_id: group._id},
|
||||
{$set: {'purchased.plan.quantity': canonicalMemberCount + 2}}
|
||||
{ _id: group._id },
|
||||
{ $set: { 'purchased.plan.quantity': canonicalMemberCount + 2 } },
|
||||
);
|
||||
}
|
||||
|
||||
@@ -98,7 +98,7 @@ async function fixGroupPlanMembers () {
|
||||
}).then(() => {
|
||||
console.info(`Fixed ${fixedGroupCount} out of ${groupPlanCount} active Group Plans`);
|
||||
return process.exit(0);
|
||||
}).catch((err) => {
|
||||
}).catch(err => {
|
||||
console.log(err);
|
||||
return process.exit(1);
|
||||
});
|
||||
|
||||
@@ -13,21 +13,19 @@ import { model as Group } from '../../website/server/models/group';
|
||||
import * as payments from '../../website/server/libs/payments';
|
||||
|
||||
async function updateGroupsWithGroupPlans () {
|
||||
let cursor = Group.find({
|
||||
const cursor = Group.find({
|
||||
'purchased.plan.planId': 'group_monthly',
|
||||
'purchased.plan.dateTerminated': null,
|
||||
}).cursor();
|
||||
|
||||
let promises = [];
|
||||
const promises = [];
|
||||
|
||||
cursor.on('data', (group) => {
|
||||
cursor.on('data', group => {
|
||||
promises.push(payments.addSubscriptionToGroupUsers(group));
|
||||
promises.push(group.save());
|
||||
});
|
||||
|
||||
cursor.on('close', async () => {
|
||||
return await Promise.all(promises);
|
||||
});
|
||||
cursor.on('close', async () => await Promise.all(promises));
|
||||
}
|
||||
|
||||
module.exports = updateGroupsWithGroupPlans;
|
||||
|
||||
@@ -18,11 +18,12 @@ setUpServer();
|
||||
|
||||
// Replace this with your migration
|
||||
const processUsers = require('');
|
||||
|
||||
processUsers()
|
||||
.then(function success () {
|
||||
.then(() => {
|
||||
process.exit(0);
|
||||
})
|
||||
.catch(function failure (err) {
|
||||
.catch(err => {
|
||||
console.log(err);
|
||||
process.exit(1);
|
||||
});
|
||||
|
||||
@@ -1,19 +1,20 @@
|
||||
/* let migrationName = 'new_stuff.js'; */
|
||||
let authorName = 'Sabe'; // in case script author needs to know when their ...
|
||||
let authorUuid = '7f14ed62-5408-4e1b-be83-ada62d504931'; // ... own data is done
|
||||
const authorName = 'Sabe'; // in case script author needs to know when their ...
|
||||
const authorUuid = '7f14ed62-5408-4e1b-be83-ada62d504931'; // ... own data is done
|
||||
|
||||
/*
|
||||
* set the newStuff flag in all user accounts so they see a Bailey message
|
||||
*/
|
||||
|
||||
let monk = require('monk');
|
||||
let connectionString = 'mongodb://localhost:27017/habitrpg?auto_reconnect=true'; // FOR TEST DATABASE
|
||||
let dbUsers = monk(connectionString).get('users', { castIds: false });
|
||||
const monk = require('monk');
|
||||
|
||||
const connectionString = 'mongodb://localhost:27017/habitrpg?auto_reconnect=true'; // FOR TEST DATABASE
|
||||
const dbUsers = monk(connectionString).get('users', { castIds: false });
|
||||
|
||||
function processUsers (lastId) {
|
||||
// specify a query to limit the affected users (empty for all users):
|
||||
let query = {
|
||||
'flags.newStuff': {$ne: true},
|
||||
const query = {
|
||||
'flags.newStuff': { $ne: true },
|
||||
};
|
||||
|
||||
if (lastId) {
|
||||
@@ -23,18 +24,18 @@ function processUsers (lastId) {
|
||||
}
|
||||
|
||||
dbUsers.find(query, {
|
||||
sort: {_id: 1},
|
||||
sort: { _id: 1 },
|
||||
limit: 250,
|
||||
fields: [], // specify fields we are interested in to limit retrieved data (empty if we're not reading data):
|
||||
})
|
||||
.then(updateUsers)
|
||||
.catch((err) => {
|
||||
.catch(err => {
|
||||
console.log(err);
|
||||
return exiting(1, `ERROR! ${ err}`);
|
||||
return exiting(1, `ERROR! ${err}`);
|
||||
});
|
||||
}
|
||||
|
||||
let progressCount = 1000;
|
||||
const progressCount = 1000;
|
||||
let count = 0;
|
||||
|
||||
function updateUsers (users) {
|
||||
@@ -44,8 +45,8 @@ function updateUsers (users) {
|
||||
return;
|
||||
}
|
||||
|
||||
let userPromises = users.map(updateUser);
|
||||
let lastUser = users[users.length - 1];
|
||||
const userPromises = users.map(updateUser);
|
||||
const lastUser = users[users.length - 1];
|
||||
|
||||
return Promise.all(userPromises)
|
||||
.then(() => {
|
||||
@@ -56,16 +57,16 @@ function updateUsers (users) {
|
||||
function updateUser (user) {
|
||||
count++;
|
||||
|
||||
let set = {'flags.newStuff': true};
|
||||
const set = { 'flags.newStuff': true };
|
||||
|
||||
dbUsers.update({_id: user._id}, {$set: set});
|
||||
dbUsers.update({ _id: user._id }, { $set: set });
|
||||
|
||||
if (count % progressCount === 0) console.warn(`${count } ${ user._id}`);
|
||||
if (user._id === authorUuid) console.warn(`${authorName } processed`);
|
||||
if (count % progressCount === 0) console.warn(`${count} ${user._id}`);
|
||||
if (user._id === authorUuid) console.warn(`${authorName} processed`);
|
||||
}
|
||||
|
||||
function displayData () {
|
||||
console.warn(`\n${ count } users processed\n`);
|
||||
console.warn(`\n${count} users processed\n`);
|
||||
return exiting(0);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,18 +1,19 @@
|
||||
let migrationName = 'restock_armoire.js';
|
||||
let authorName = 'Sabe'; // in case script author needs to know when their ...
|
||||
let authorUuid = '7f14ed62-5408-4e1b-be83-ada62d504931'; // ... own data is done
|
||||
const migrationName = 'restock_armoire.js';
|
||||
const authorName = 'Sabe'; // in case script author needs to know when their ...
|
||||
const authorUuid = '7f14ed62-5408-4e1b-be83-ada62d504931'; // ... own data is done
|
||||
|
||||
/*
|
||||
* Remove flag stating that the Enchanted Armoire is empty, for when new equipment is added
|
||||
*/
|
||||
|
||||
let monk = require('monk');
|
||||
let connectionString = 'mongodb://localhost:27017/habitrpg?auto_reconnect=true'; // FOR TEST DATABASE
|
||||
let dbUsers = monk(connectionString).get('users', { castIds: false });
|
||||
const monk = require('monk');
|
||||
|
||||
const connectionString = 'mongodb://localhost:27017/habitrpg?auto_reconnect=true'; // FOR TEST DATABASE
|
||||
const dbUsers = monk(connectionString).get('users', { castIds: false });
|
||||
|
||||
function processUsers (lastId) {
|
||||
// specify a query to limit the affected users (empty for all users):
|
||||
let query = {
|
||||
const query = {
|
||||
'flags.armoireEmpty': true,
|
||||
};
|
||||
|
||||
@@ -23,18 +24,18 @@ function processUsers (lastId) {
|
||||
}
|
||||
|
||||
dbUsers.find(query, {
|
||||
sort: {_id: 1},
|
||||
sort: { _id: 1 },
|
||||
limit: 250,
|
||||
fields: [], // specify fields we are interested in to limit retrieved data (empty if we're not reading data):
|
||||
})
|
||||
.then(updateUsers)
|
||||
.catch((err) => {
|
||||
.catch(err => {
|
||||
console.log(err);
|
||||
return exiting(1, `ERROR! ${ err}`);
|
||||
return exiting(1, `ERROR! ${err}`);
|
||||
});
|
||||
}
|
||||
|
||||
let progressCount = 1000;
|
||||
const progressCount = 1000;
|
||||
let count = 0;
|
||||
|
||||
function updateUsers (users) {
|
||||
@@ -44,8 +45,8 @@ function updateUsers (users) {
|
||||
return;
|
||||
}
|
||||
|
||||
let userPromises = users.map(updateUser);
|
||||
let lastUser = users[users.length - 1];
|
||||
const userPromises = users.map(updateUser);
|
||||
const lastUser = users[users.length - 1];
|
||||
|
||||
return Promise.all(userPromises)
|
||||
.then(() => {
|
||||
@@ -56,16 +57,16 @@ function updateUsers (users) {
|
||||
function updateUser (user) {
|
||||
count++;
|
||||
|
||||
let set = {migration: migrationName, 'flags.armoireEmpty': false};
|
||||
const set = { migration: migrationName, 'flags.armoireEmpty': false };
|
||||
|
||||
dbUsers.update({_id: user._id}, {$set: set});
|
||||
dbUsers.update({ _id: user._id }, { $set: set });
|
||||
|
||||
if (count % progressCount === 0) console.warn(`${count } ${ user._id}`);
|
||||
if (user._id === authorUuid) console.warn(`${authorName } processed`);
|
||||
if (count % progressCount === 0) console.warn(`${count} ${user._id}`);
|
||||
if (user._id === authorUuid) console.warn(`${authorName} processed`);
|
||||
}
|
||||
|
||||
function displayData () {
|
||||
console.warn(`\n${ count } users processed\n`);
|
||||
console.warn(`\n${count} users processed\n`);
|
||||
return exiting(0);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
let migrationName = 'restock_armoire_for_users_that_need_it.js';
|
||||
let authorName = 'Alys (ALittleYellowSpider)'; // in case script author needs to know when their ...
|
||||
let authorUuid = '3e595299-3d8a-4a10-bfe0-88f555e4aa0c'; // ... own data is done
|
||||
const migrationName = 'restock_armoire_for_users_that_need_it.js';
|
||||
const authorName = 'Alys (ALittleYellowSpider)'; // in case script author needs to know when their ...
|
||||
const authorUuid = '3e595299-3d8a-4a10-bfe0-88f555e4aa0c'; // ... own data is done
|
||||
|
||||
/*
|
||||
* Remove flag stating that the Enchanted Armoire is empty,
|
||||
@@ -18,16 +18,17 @@ let authorUuid = '3e595299-3d8a-4a10-bfe0-88f555e4aa0c'; // ... own data is done
|
||||
*
|
||||
*/
|
||||
|
||||
let connectionString = 'mongodb://localhost:27017/habitrpg?auto_reconnect=true'; // FOR TEST DATABASE
|
||||
const connectionString = 'mongodb://localhost:27017/habitrpg?auto_reconnect=true'; // FOR TEST DATABASE
|
||||
|
||||
let monk = require('monk');
|
||||
let dbUsers = monk(connectionString).get('users', { castIds: false });
|
||||
const monk = require('monk');
|
||||
|
||||
const dbUsers = monk(connectionString).get('users', { castIds: false });
|
||||
|
||||
|
||||
function processUsers (lastId) {
|
||||
// specify a query to limit the affected users (empty for all users):
|
||||
let query = {
|
||||
'auth.timestamps.loggedin': {$gt: new Date('2016-01-04')},
|
||||
const query = {
|
||||
'auth.timestamps.loggedin': { $gt: new Date('2016-01-04') },
|
||||
// '_id': authorUuid // FOR TESTING
|
||||
};
|
||||
|
||||
@@ -35,7 +36,7 @@ function processUsers (lastId) {
|
||||
/* let fields = {
|
||||
'flags.armoireEmpty': 1,
|
||||
'items.gear.owned': 1,
|
||||
};*/
|
||||
}; */
|
||||
|
||||
if (lastId) {
|
||||
query._id = {
|
||||
@@ -44,7 +45,7 @@ function processUsers (lastId) {
|
||||
}
|
||||
|
||||
dbUsers.find(query, {
|
||||
sort: {_id: 1},
|
||||
sort: { _id: 1 },
|
||||
limit: 250,
|
||||
fields: {
|
||||
'flags.armoireEmpty': 1,
|
||||
@@ -52,13 +53,13 @@ function processUsers (lastId) {
|
||||
}, // specify fields we are interested in to limit retrieved data (empty if we're not reading data):
|
||||
})
|
||||
.then(updateUsers)
|
||||
.catch((err) => {
|
||||
.catch(err => {
|
||||
console.log(err);
|
||||
return exiting(1, `ERROR! ${ err}`);
|
||||
return exiting(1, `ERROR! ${err}`);
|
||||
});
|
||||
}
|
||||
|
||||
let progressCount = 1000;
|
||||
const progressCount = 1000;
|
||||
let count = 0;
|
||||
|
||||
function updateUsers (users) {
|
||||
@@ -68,8 +69,8 @@ function updateUsers (users) {
|
||||
return;
|
||||
}
|
||||
|
||||
let userPromises = users.map(updateUser);
|
||||
let lastUser = users[users.length - 1];
|
||||
const userPromises = users.map(updateUser);
|
||||
const lastUser = users[users.length - 1];
|
||||
|
||||
return Promise.all(userPromises)
|
||||
.then(() => {
|
||||
@@ -80,7 +81,7 @@ function updateUsers (users) {
|
||||
function updateUser (user) {
|
||||
count++;
|
||||
|
||||
let set = {migration: migrationName, 'flags.armoireEmpty': false};
|
||||
const set = { migration: migrationName, 'flags.armoireEmpty': false };
|
||||
|
||||
|
||||
if (user.flags.armoireEmpty) {
|
||||
@@ -90,7 +91,7 @@ function updateUser (user) {
|
||||
// console.log("don't change: " + user._id); // FOR TESTING
|
||||
} else {
|
||||
// console.log("change: " + user._id); // FOR TESTING
|
||||
dbUsers.update({_id: user._id}, {$set: set});
|
||||
dbUsers.update({ _id: user._id }, { $set: set });
|
||||
}
|
||||
} else {
|
||||
// this user already has armoire marked as containing items to be bought
|
||||
@@ -98,12 +99,12 @@ function updateUser (user) {
|
||||
// console.log("DON'T CHANGE: " + user._id); // FOR TESTING
|
||||
}
|
||||
|
||||
if (count % progressCount === 0) console.warn(`${count } ${ user._id}`);
|
||||
if (user._id === authorUuid) console.warn(`${authorName } processed`);
|
||||
if (count % progressCount === 0) console.warn(`${count} ${user._id}`);
|
||||
if (user._id === authorUuid) console.warn(`${authorName} processed`);
|
||||
}
|
||||
|
||||
function displayData () {
|
||||
console.warn(`\n${ count } users processed\n`);
|
||||
console.warn(`\n${count} users processed\n`);
|
||||
return exiting(0);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,22 +1,24 @@
|
||||
/* let migrationName = 'restore_profile_data.js'; */
|
||||
let authorName = 'ThehollidayInn'; // in case script author needs to know when their ...
|
||||
let authorUuid = ''; // ... own data is done
|
||||
const authorName = 'ThehollidayInn'; // in case script author needs to know when their ...
|
||||
const authorUuid = ''; // ... own data is done
|
||||
|
||||
/*
|
||||
* Check if users have empty profile data in new database and update it with old database info
|
||||
*/
|
||||
|
||||
let monk = require('monk');
|
||||
let connectionString = ''; // FOR TEST DATABASE
|
||||
let dbUsers = monk(connectionString).get('users', { castIds: false });
|
||||
const monk = require('monk');
|
||||
|
||||
let monk2 = require('monk');
|
||||
let oldDbConnectionString = 'mongodb://localhost:27017/habitrpg?auto_reconnect=true'; // FOR TEST DATABASE
|
||||
let olDbUsers = monk2(oldDbConnectionString).get('users', { castIds: false });
|
||||
const connectionString = ''; // FOR TEST DATABASE
|
||||
const dbUsers = monk(connectionString).get('users', { castIds: false });
|
||||
|
||||
const monk2 = require('monk');
|
||||
|
||||
const oldDbConnectionString = 'mongodb://localhost:27017/habitrpg?auto_reconnect=true'; // FOR TEST DATABASE
|
||||
const olDbUsers = monk2(oldDbConnectionString).get('users', { castIds: false });
|
||||
|
||||
function processUsers (lastId) {
|
||||
// specify a query to limit the affected users (empty for all users):
|
||||
let query = {
|
||||
const query = {
|
||||
// 'profile.name': 'profile name not found',
|
||||
'profile.blurb': null,
|
||||
// 'auth.timestamps.loggedin': {$gt: new Date('11/30/2016')},
|
||||
@@ -29,18 +31,18 @@ function processUsers (lastId) {
|
||||
}
|
||||
|
||||
dbUsers.find(query, {
|
||||
sort: {_id: 1},
|
||||
sort: { _id: 1 },
|
||||
limit: 250,
|
||||
fields: ['_id', 'profile', 'auth.timestamps.loggedin'], // specify fields we are interested in to limit retrieved data (empty if we're not reading data):
|
||||
})
|
||||
.then(updateUsers)
|
||||
.catch((err) => {
|
||||
.catch(err => {
|
||||
console.log(err);
|
||||
return exiting(1, `ERROR! ${ err}`);
|
||||
return exiting(1, `ERROR! ${err}`);
|
||||
});
|
||||
}
|
||||
|
||||
let progressCount = 1000;
|
||||
const progressCount = 1000;
|
||||
let count = 0;
|
||||
|
||||
function updateUsers (users) {
|
||||
@@ -50,28 +52,26 @@ function updateUsers (users) {
|
||||
return;
|
||||
}
|
||||
|
||||
let userPaymentPromises = users.map(updateUser);
|
||||
let lastUser = users[users.length - 1];
|
||||
const userPaymentPromises = users.map(updateUser);
|
||||
const lastUser = users[users.length - 1];
|
||||
|
||||
return Promise.all(userPaymentPromises)
|
||||
.then(() => {
|
||||
return processUsers(lastUser._id);
|
||||
});
|
||||
.then(() => processUsers(lastUser._id));
|
||||
}
|
||||
|
||||
function updateUser (user) {
|
||||
count++;
|
||||
|
||||
if (!user.profile.name || user.profile.name === 'profile name not found' || !user.profile.imageUrl || !user.profile.blurb) {
|
||||
return olDbUsers.findOne({_id: user._id}, '_id profile')
|
||||
.then((oldUserData) => {
|
||||
return olDbUsers.findOne({ _id: user._id }, '_id profile')
|
||||
.then(oldUserData => {
|
||||
if (!oldUserData) return;
|
||||
// specify user data to change:
|
||||
let set = {};
|
||||
const set = {};
|
||||
|
||||
if (oldUserData.profile.name === 'profile name not found') return;
|
||||
|
||||
let userNeedsProfileName = !user.profile.name || user.profile.name === 'profile name not found';
|
||||
const userNeedsProfileName = !user.profile.name || user.profile.name === 'profile name not found';
|
||||
if (userNeedsProfileName && oldUserData.profile.name) {
|
||||
set['profile.name'] = oldUserData.profile.name;
|
||||
}
|
||||
@@ -86,17 +86,17 @@ function updateUser (user) {
|
||||
|
||||
if (Object.keys(set).length !== 0 && set.constructor === Object) {
|
||||
console.log(set);
|
||||
return dbUsers.update({_id: user._id}, {$set: set});
|
||||
return dbUsers.update({ _id: user._id }, { $set: set });
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (count % progressCount === 0) console.warn(`${count } ${ user._id}`);
|
||||
if (user._id === authorUuid) console.warn(`${authorName } processed`);
|
||||
if (count % progressCount === 0) console.warn(`${count} ${user._id}`);
|
||||
if (user._id === authorUuid) console.warn(`${authorName} processed`);
|
||||
}
|
||||
|
||||
function displayData () {
|
||||
console.warn(`\n${ count } users processed\n`);
|
||||
console.warn(`\n${count} users processed\n`);
|
||||
return exiting(0);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
let request = require('superagent');
|
||||
let last = require('lodash/last');
|
||||
let AWS = require('aws-sdk');
|
||||
const request = require('superagent');
|
||||
const last = require('lodash/last');
|
||||
const AWS = require('aws-sdk');
|
||||
|
||||
const config = require('../config');
|
||||
|
||||
let config = require('../config');
|
||||
const S3_DIRECTORY = 'mobileApp/images'; // config.S3.SPRITES_DIRECTORY;
|
||||
|
||||
AWS.config.update({
|
||||
@@ -11,8 +12,8 @@ AWS.config.update({
|
||||
// region: config.get('S3_REGION'),
|
||||
});
|
||||
|
||||
let BUCKET_NAME = config.S3.bucket;
|
||||
let s3 = new AWS.S3();
|
||||
const BUCKET_NAME = config.S3.bucket;
|
||||
const s3 = new AWS.S3();
|
||||
|
||||
// Adapted from http://stackoverflow.com/a/22210077/2601552
|
||||
function uploadFile (buffer, fileName) {
|
||||
@@ -21,7 +22,7 @@ function uploadFile (buffer, fileName) {
|
||||
Body: buffer,
|
||||
Key: fileName,
|
||||
Bucket: BUCKET_NAME,
|
||||
}, (error) => {
|
||||
}, error => {
|
||||
if (error) {
|
||||
reject(error);
|
||||
} else {
|
||||
@@ -33,9 +34,9 @@ function uploadFile (buffer, fileName) {
|
||||
}
|
||||
|
||||
function getFileName (file) {
|
||||
let piecesOfPath = file.split('/');
|
||||
let name = last(piecesOfPath);
|
||||
let fullName = S3_DIRECTORY + name;
|
||||
const piecesOfPath = file.split('/');
|
||||
const name = last(piecesOfPath);
|
||||
const fullName = S3_DIRECTORY + name;
|
||||
|
||||
return fullName;
|
||||
}
|
||||
@@ -44,7 +45,7 @@ function getFileFromUrl (url) {
|
||||
return new Promise((resolve, reject) => {
|
||||
request.get(url).end((err, res) => {
|
||||
if (err) return reject(err);
|
||||
let file = res.body;
|
||||
const file = res.body;
|
||||
resolve(file);
|
||||
});
|
||||
});
|
||||
@@ -52,25 +53,21 @@ function getFileFromUrl (url) {
|
||||
|
||||
let commit = '78f94e365c72cc58f66857d5941105638db7d35c';
|
||||
commit = 'df0dbaba636c9ce424cc7040f7bd7fc1aa311015';
|
||||
let gihuburl = `https://api.github.com/repos/HabitRPG/habitica/commits/${commit}`;
|
||||
const gihuburl = `https://api.github.com/repos/HabitRPG/habitica/commits/${commit}`;
|
||||
|
||||
|
||||
let currentIndex = 0;
|
||||
|
||||
function uploadToS3 (start, end, filesUrls) {
|
||||
let urls = filesUrls.slice(start, end);
|
||||
const urls = filesUrls.slice(start, end);
|
||||
|
||||
if (urls.length === 0) {
|
||||
console.log('done');
|
||||
return;
|
||||
}
|
||||
|
||||
let promises = urls.map(fullUrl => {
|
||||
return getFileFromUrl(fullUrl)
|
||||
.then((buffer) => {
|
||||
return uploadFile(buffer, getFileName(fullUrl));
|
||||
});
|
||||
});
|
||||
const promises = urls.map(fullUrl => getFileFromUrl(fullUrl)
|
||||
.then(buffer => uploadFile(buffer, getFileName(fullUrl))));
|
||||
console.log(promises.length);
|
||||
|
||||
return Promise.all(promises)
|
||||
@@ -86,12 +83,10 @@ function uploadToS3 (start, end, filesUrls) {
|
||||
request.get(gihuburl)
|
||||
.end((err, res) => {
|
||||
console.log(err);
|
||||
let files = res.body.files;
|
||||
const { files } = res.body;
|
||||
|
||||
let filesUrls = [''];
|
||||
filesUrls = files.map(file => {
|
||||
return file.raw_url;
|
||||
});
|
||||
filesUrls = files.map(file => file.raw_url);
|
||||
|
||||
uploadToS3(currentIndex, currentIndex + 50, filesUrls);
|
||||
});
|
||||
|
||||
@@ -9,13 +9,14 @@
|
||||
const monk = require('monk');
|
||||
const _ = require('lodash');
|
||||
const moment = require('moment');
|
||||
|
||||
const connectionString = 'mongodb://localhost:27017/habitrpg?auto_reconnect=true'; // FOR TEST DATABASE
|
||||
const dbTasks = monk(connectionString).get('tasks', { castIds: false });
|
||||
|
||||
function processChallengeHabits (lastId) {
|
||||
let query = {
|
||||
'challenge.id': {$exists: true},
|
||||
userId: {$exists: false},
|
||||
const query = {
|
||||
'challenge.id': { $exists: true },
|
||||
userId: { $exists: false },
|
||||
type: 'habit',
|
||||
};
|
||||
|
||||
@@ -26,17 +27,17 @@ function processChallengeHabits (lastId) {
|
||||
}
|
||||
|
||||
dbTasks.find(query, {
|
||||
sort: {_id: 1},
|
||||
sort: { _id: 1 },
|
||||
limit: 500,
|
||||
})
|
||||
.then(updateChallengeHabits)
|
||||
.catch((err) => {
|
||||
.catch(err => {
|
||||
console.log(err);
|
||||
return exiting(1, `ERROR! ${ err}`);
|
||||
return exiting(1, `ERROR! ${err}`);
|
||||
});
|
||||
}
|
||||
|
||||
let progressCount = 1000;
|
||||
const progressCount = 1000;
|
||||
let count = 0;
|
||||
|
||||
function updateChallengeHabits (habits) {
|
||||
@@ -46,13 +47,11 @@ function updateChallengeHabits (habits) {
|
||||
return;
|
||||
}
|
||||
|
||||
let habitsPromises = habits.map(updateChallengeHabit);
|
||||
let lastHabit = habits[habits.length - 1];
|
||||
const habitsPromises = habits.map(updateChallengeHabit);
|
||||
const lastHabit = habits[habits.length - 1];
|
||||
|
||||
return Promise.all(habitsPromises)
|
||||
.then(() => {
|
||||
return processChallengeHabits(lastHabit._id);
|
||||
});
|
||||
.then(() => processChallengeHabits(lastHabit._id));
|
||||
}
|
||||
|
||||
function updateChallengeHabit (habit) {
|
||||
@@ -76,13 +75,12 @@ function updateChallengeHabit (habit) {
|
||||
entry.scoreDirection = entry.value > previousValue ? 'up' : 'down';
|
||||
}
|
||||
})
|
||||
.groupBy(entry => { // group entries by aggregateBy
|
||||
return moment(entry.date).format('YYYYMMDD');
|
||||
})
|
||||
.groupBy(entry => // group entries by aggregateBy
|
||||
moment(entry.date).format('YYYYMMDD'))
|
||||
.toPairs() // [key, entry]
|
||||
.sortBy(([key]) => key) // sort by date
|
||||
.map(keyEntryPair => {
|
||||
let entries = keyEntryPair[1]; // 1 is entry, 0 is key
|
||||
const entries = keyEntryPair[1]; // 1 is entry, 0 is key
|
||||
let scoredUp = 0;
|
||||
let scoredDown = 0;
|
||||
|
||||
@@ -107,16 +105,16 @@ function updateChallengeHabit (habit) {
|
||||
})
|
||||
.value();
|
||||
|
||||
return dbTasks.update({_id: habit._id}, {
|
||||
$set: {history: habit.history},
|
||||
return dbTasks.update({ _id: habit._id }, {
|
||||
$set: { history: habit.history },
|
||||
});
|
||||
}
|
||||
|
||||
if (count % progressCount === 0) console.warn(`${count } habits processed`);
|
||||
if (count % progressCount === 0) console.warn(`${count} habits processed`);
|
||||
}
|
||||
|
||||
function displayData () {
|
||||
console.warn(`\n${ count } tasks processed\n`);
|
||||
console.warn(`\n${count} tasks processed\n`);
|
||||
return exiting(0);
|
||||
}
|
||||
|
||||
|
||||
@@ -9,13 +9,14 @@ const authorUuid = 'ed4c688c-6652-4a92-9d03-a5a79844174a'; // ... own data is do
|
||||
const monk = require('monk');
|
||||
const _ = require('lodash');
|
||||
const moment = require('moment');
|
||||
|
||||
const connectionString = 'mongodb://localhost:27017/habitrpg?auto_reconnect=true'; // FOR TEST DATABASE
|
||||
const dbTasks = monk(connectionString).get('tasks', { castIds: false });
|
||||
const dbUsers = monk(connectionString).get('users', { castIds: false });
|
||||
|
||||
function processUsers (lastId) {
|
||||
let query = {
|
||||
migration: {$ne: migrationName},
|
||||
const query = {
|
||||
migration: { $ne: migrationName },
|
||||
};
|
||||
|
||||
if (lastId) {
|
||||
@@ -25,18 +26,18 @@ function processUsers (lastId) {
|
||||
}
|
||||
|
||||
dbUsers.find(query, {
|
||||
sort: {_id: 1},
|
||||
sort: { _id: 1 },
|
||||
limit: 50, // just 50 users per time since we have to process all their habits as well
|
||||
fields: ['_id', 'preferences.timezoneOffset', 'preferences.dayStart'],
|
||||
})
|
||||
.then(updateUsers)
|
||||
.catch((err) => {
|
||||
.catch(err => {
|
||||
console.log(err);
|
||||
return exiting(1, `ERROR! ${ err}`);
|
||||
return exiting(1, `ERROR! ${err}`);
|
||||
});
|
||||
}
|
||||
|
||||
let progressCount = 1000;
|
||||
const progressCount = 1000;
|
||||
let count = 0;
|
||||
|
||||
function updateUsers (users) {
|
||||
@@ -46,13 +47,11 @@ function updateUsers (users) {
|
||||
return;
|
||||
}
|
||||
|
||||
let usersPromises = users.map(updateUser);
|
||||
let lastUser = users[users.length - 1];
|
||||
const usersPromises = users.map(updateUser);
|
||||
const lastUser = users[users.length - 1];
|
||||
|
||||
return Promise.all(usersPromises)
|
||||
.then(() => {
|
||||
return processUsers(lastUser._id);
|
||||
});
|
||||
.then(() => processUsers(lastUser._id));
|
||||
}
|
||||
|
||||
function updateHabit (habit, timezoneOffset, dayStart) {
|
||||
@@ -82,7 +81,7 @@ function updateHabit (habit, timezoneOffset, dayStart) {
|
||||
.toPairs() // [key, entry]
|
||||
.sortBy(([key]) => key) // sort by date
|
||||
.map(keyEntryPair => {
|
||||
let entries = keyEntryPair[1]; // 1 is entry, 0 is key
|
||||
const entries = keyEntryPair[1]; // 1 is entry, 0 is key
|
||||
let scoredUp = 0;
|
||||
let scoredDown = 0;
|
||||
|
||||
@@ -107,8 +106,8 @@ function updateHabit (habit, timezoneOffset, dayStart) {
|
||||
})
|
||||
.value();
|
||||
|
||||
return dbTasks.update({_id: habit._id}, {
|
||||
$set: {history: habit.history},
|
||||
return dbTasks.update({ _id: habit._id }, {
|
||||
$set: { history: habit.history },
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -116,32 +115,28 @@ function updateHabit (habit, timezoneOffset, dayStart) {
|
||||
function updateUser (user) {
|
||||
count++;
|
||||
|
||||
const timezoneOffset = user.preferences.timezoneOffset;
|
||||
const dayStart = user.preferences.dayStart;
|
||||
const { timezoneOffset } = user.preferences;
|
||||
const { dayStart } = user.preferences;
|
||||
|
||||
if (count % progressCount === 0) console.warn(`${count } ${ user._id}`);
|
||||
if (user._id === authorUuid) console.warn(`${authorName } being processed`);
|
||||
if (count % progressCount === 0) console.warn(`${count} ${user._id}`);
|
||||
if (user._id === authorUuid) console.warn(`${authorName} being processed`);
|
||||
|
||||
return dbTasks.find({
|
||||
type: 'habit',
|
||||
userId: user._id,
|
||||
})
|
||||
.then(habits => {
|
||||
return Promise.all(habits.map(habit => updateHabit(habit, timezoneOffset, dayStart)));
|
||||
})
|
||||
.then(() => {
|
||||
return dbUsers.update({_id: user._id}, {
|
||||
$set: {migration: migrationName},
|
||||
});
|
||||
})
|
||||
.catch((err) => {
|
||||
.then(habits => Promise.all(habits.map(habit => updateHabit(habit, timezoneOffset, dayStart))))
|
||||
.then(() => dbUsers.update({ _id: user._id }, {
|
||||
$set: { migration: migrationName },
|
||||
}))
|
||||
.catch(err => {
|
||||
console.log(err);
|
||||
return exiting(1, `ERROR! ${ err}`);
|
||||
return exiting(1, `ERROR! ${err}`);
|
||||
});
|
||||
}
|
||||
|
||||
function displayData () {
|
||||
console.warn(`\n${ count } tasks processed\n`);
|
||||
console.warn(`\n${count} tasks processed\n`);
|
||||
return exiting(0);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,18 +1,19 @@
|
||||
/* let migrationName = 'tasks-set-everyX'; */
|
||||
let authorName = 'Sabe'; // in case script author needs to know when their ...
|
||||
let authorUuid = '7f14ed62-5408-4e1b-be83-ada62d504931'; // ... own data is done
|
||||
const authorName = 'Sabe'; // in case script author needs to know when their ...
|
||||
const authorUuid = '7f14ed62-5408-4e1b-be83-ada62d504931'; // ... own data is done
|
||||
|
||||
/*
|
||||
* Iterates over all tasks and sets invalid everyX values (less than 0 or more than 9999 or not an int) field to 0
|
||||
*/
|
||||
|
||||
let monk = require('monk');
|
||||
let connectionString = 'mongodb://localhost:27017/habitrpg?auto_reconnect=true';
|
||||
let dbTasks = monk(connectionString).get('tasks', { castIds: false });
|
||||
const monk = require('monk');
|
||||
|
||||
const connectionString = 'mongodb://localhost:27017/habitrpg?auto_reconnect=true';
|
||||
const dbTasks = monk(connectionString).get('tasks', { castIds: false });
|
||||
|
||||
function processTasks (lastId) {
|
||||
// specify a query to limit the affected tasks (empty for all tasks):
|
||||
let query = {
|
||||
const query = {
|
||||
type: 'daily',
|
||||
everyX: {
|
||||
$not: {
|
||||
@@ -30,18 +31,18 @@ function processTasks (lastId) {
|
||||
}
|
||||
|
||||
dbTasks.find(query, {
|
||||
sort: {_id: 1},
|
||||
sort: { _id: 1 },
|
||||
limit: 250,
|
||||
fields: [],
|
||||
})
|
||||
.then(updateTasks)
|
||||
.catch((err) => {
|
||||
.catch(err => {
|
||||
console.log(err);
|
||||
return exiting(1, `ERROR! ${ err}`);
|
||||
return exiting(1, `ERROR! ${err}`);
|
||||
});
|
||||
}
|
||||
|
||||
let progressCount = 1000;
|
||||
const progressCount = 1000;
|
||||
let count = 0;
|
||||
|
||||
function updateTasks (tasks) {
|
||||
@@ -51,27 +52,25 @@ function updateTasks (tasks) {
|
||||
return;
|
||||
}
|
||||
|
||||
let taskPromises = tasks.map(updatetask);
|
||||
let lasttask = tasks[tasks.length - 1];
|
||||
const taskPromises = tasks.map(updatetask);
|
||||
const lasttask = tasks[tasks.length - 1];
|
||||
|
||||
return Promise.all(taskPromises)
|
||||
.then(() => {
|
||||
return processTasks(lasttask._id);
|
||||
});
|
||||
.then(() => processTasks(lasttask._id));
|
||||
}
|
||||
|
||||
function updatetask (task) {
|
||||
count++;
|
||||
let set = {everyX: 0};
|
||||
const set = { everyX: 0 };
|
||||
|
||||
dbTasks.update({_id: task._id}, {$set: set});
|
||||
dbTasks.update({ _id: task._id }, { $set: set });
|
||||
|
||||
if (count % progressCount === 0) console.warn(`${count } ${ task._id}`);
|
||||
if (task._id === authorUuid) console.warn(`${authorName } processed`);
|
||||
if (count % progressCount === 0) console.warn(`${count} ${task._id}`);
|
||||
if (task._id === authorUuid) console.warn(`${authorName} processed`);
|
||||
}
|
||||
|
||||
function displayData () {
|
||||
console.warn(`\n${ count } tasks processed\n`);
|
||||
console.warn(`\n${count} tasks processed\n`);
|
||||
return exiting(0);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
/* let migrationName = 'tasks-set-yesterdaily'; */
|
||||
let authorName = 'TheHollidayInn'; // in case script author needs to know when their ...
|
||||
let authorUuid = ''; // ... own data is done
|
||||
// ... own data is done
|
||||
|
||||
/*
|
||||
* Iterates over all tasks and sets the yseterDaily field to True
|
||||
@@ -8,10 +7,13 @@ let authorUuid = ''; // ... own data is done
|
||||
|
||||
import monk from 'monk';
|
||||
|
||||
let connectionString = 'mongodb://localhost:27017/habitrpg?auto_reconnect=true'; // FOR TEST DATABASE
|
||||
let dbTasks = monk(connectionString).get('tasks', { castIds: false });
|
||||
const authorName = 'TheHollidayInn'; // in case script author needs to know when their ...
|
||||
const authorUuid = '';
|
||||
|
||||
let progressCount = 1000;
|
||||
const connectionString = 'mongodb://localhost:27017/habitrpg?auto_reconnect=true'; // FOR TEST DATABASE
|
||||
const dbTasks = monk(connectionString).get('tasks', { castIds: false });
|
||||
|
||||
const progressCount = 1000;
|
||||
let count = 0;
|
||||
|
||||
function exiting (code, msg) {
|
||||
@@ -30,18 +32,18 @@ function exiting (code, msg) {
|
||||
}
|
||||
|
||||
function displayData () {
|
||||
console.warn(`\n${ count } tasks processed\n`);
|
||||
console.warn(`\n${count} tasks processed\n`);
|
||||
return exiting(0);
|
||||
}
|
||||
|
||||
function updatetask (task) {
|
||||
count++;
|
||||
let set = {yesterDaily: true};
|
||||
const set = { yesterDaily: true };
|
||||
|
||||
dbTasks.update({_id: task._id}, {$set: set});
|
||||
dbTasks.update({ _id: task._id }, { $set: set });
|
||||
|
||||
if (count % progressCount === 0) console.warn(`${count } ${ task._id}`);
|
||||
if (task._id === authorUuid) console.warn(`${authorName } processed`);
|
||||
if (count % progressCount === 0) console.warn(`${count} ${task._id}`);
|
||||
if (task._id === authorUuid) console.warn(`${authorName} processed`);
|
||||
}
|
||||
|
||||
function updateTasks (tasks) {
|
||||
@@ -51,18 +53,17 @@ function updateTasks (tasks) {
|
||||
return;
|
||||
}
|
||||
|
||||
let taskPromises = tasks.map(updatetask);
|
||||
let lasttask = tasks[tasks.length - 1];
|
||||
const taskPromises = tasks.map(updatetask);
|
||||
const lasttask = tasks[tasks.length - 1];
|
||||
|
||||
return Promise.all(taskPromises)
|
||||
.then(() => {
|
||||
return processTasks(lasttask._id); // eslint-disable-line no-use-before-define
|
||||
});
|
||||
.then(() => processTasks(lasttask._id), // eslint-disable-line no-use-before-define
|
||||
);
|
||||
}
|
||||
|
||||
function processTasks (lastId) {
|
||||
// specify a query to limit the affected tasks (empty for all tasks):
|
||||
let query = {
|
||||
const query = {
|
||||
yesterDaily: false,
|
||||
};
|
||||
|
||||
@@ -73,15 +74,15 @@ function processTasks (lastId) {
|
||||
}
|
||||
|
||||
dbTasks.find(query, {
|
||||
sort: {_id: 1},
|
||||
sort: { _id: 1 },
|
||||
limit: 250,
|
||||
fields: [ // specify fields we are interested in to limit retrieved data (empty if we're not reading data):
|
||||
],
|
||||
})
|
||||
.then(updateTasks)
|
||||
.catch((err) => {
|
||||
.catch(err => {
|
||||
console.log(err);
|
||||
return exiting(1, `ERROR! ${ err}`);
|
||||
return exiting(1, `ERROR! ${err}`);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@ let authorUuid = ''; // ... own data is done
|
||||
*/
|
||||
|
||||
const monk = require('monk');
|
||||
|
||||
const connectionString = '';
|
||||
const Users = monk(connectionString).get('users', { castIds: false });
|
||||
|
||||
@@ -16,21 +17,21 @@ module.exports = async function accountTransfer () {
|
||||
const fromAccountId = '';
|
||||
const toAccountId = '';
|
||||
|
||||
const fromAccount = await Users.findOne({_id: fromAccountId});
|
||||
const toAccount = await Users.findOne({_id: toAccountId});
|
||||
const fromAccount = await Users.findOne({ _id: fromAccountId });
|
||||
const toAccount = await Users.findOne({ _id: toAccountId });
|
||||
|
||||
const newMounts = Object.assign({}, fromAccount.items.mounts, toAccount.items.mounts);
|
||||
const newPets = Object.assign({}, fromAccount.items.pets, toAccount.items.pets);
|
||||
const newBackgrounds = Object.assign({}, fromAccount.purchased.background, toAccount.purchased.background);
|
||||
const newMounts = { ...fromAccount.items.mounts, ...toAccount.items.mounts };
|
||||
const newPets = { ...fromAccount.items.pets, ...toAccount.items.pets };
|
||||
const newBackgrounds = { ...fromAccount.purchased.background, ...toAccount.purchased.background };
|
||||
|
||||
await Users.update({_id: toAccountId}, {
|
||||
await Users.update({ _id: toAccountId }, {
|
||||
$set: {
|
||||
'items.pets': newPets,
|
||||
'items.mounts': newMounts,
|
||||
'purchased.background': newBackgrounds,
|
||||
},
|
||||
})
|
||||
.then((result) => {
|
||||
.then(result => {
|
||||
console.log(result);
|
||||
});
|
||||
};
|
||||
|
||||
@@ -9,6 +9,7 @@ const authorUuid = ''; // ... own data is done
|
||||
*/
|
||||
|
||||
const monk = require('monk');
|
||||
|
||||
const connectionString = 'mongodb://localhost/new-habit';
|
||||
const Users = monk(connectionString).get('users', { castIds: false });
|
||||
|
||||
@@ -19,13 +20,13 @@ function getAchievementUpdate (newUser, oldUser) {
|
||||
const oldAchievements = oldUser.achievements;
|
||||
const newAchievements = newUser.achievements;
|
||||
|
||||
let achievementsUpdate = Object.assign({}, newAchievements);
|
||||
const achievementsUpdate = { ...newAchievements };
|
||||
|
||||
// ultimateGearSets
|
||||
if (!achievementsUpdate.ultimateGearSets && oldAchievements.ultimateGearSets) {
|
||||
achievementsUpdate.ultimateGearSets = oldAchievements.ultimateGearSets;
|
||||
} else if (oldAchievements.ultimateGearSets) {
|
||||
for (let index in oldAchievements.ultimateGearSets) {
|
||||
for (const index in oldAchievements.ultimateGearSets) {
|
||||
if (oldAchievements.ultimateGearSets[index]) achievementsUpdate.ultimateGearSets[index] = true;
|
||||
}
|
||||
}
|
||||
@@ -37,7 +38,7 @@ function getAchievementUpdate (newUser, oldUser) {
|
||||
|
||||
// Quests
|
||||
if (!achievementsUpdate.quests) achievementsUpdate.quests = {};
|
||||
for (let index in oldAchievements.quests) {
|
||||
for (const index in oldAchievements.quests) {
|
||||
if (!achievementsUpdate.quests[index]) {
|
||||
achievementsUpdate.quests[index] = oldAchievements.quests[index];
|
||||
} else {
|
||||
@@ -54,7 +55,7 @@ function getAchievementUpdate (newUser, oldUser) {
|
||||
|
||||
// All others
|
||||
const indexsToIgnore = ['ultimateGearSets', 'challenges', 'quests', 'rebirthLevel'];
|
||||
for (let index in oldAchievements) {
|
||||
for (const index in oldAchievements) {
|
||||
if (indexsToIgnore.indexOf(index) !== -1) continue; // eslint-disable-line no-continue
|
||||
|
||||
if (!achievementsUpdate[index]) {
|
||||
@@ -75,18 +76,19 @@ module.exports = async function achievementRestore () {
|
||||
];
|
||||
|
||||
/* eslint-disable no-await-in-loop */
|
||||
for (let index in userIds) {
|
||||
for (const index in userIds) {
|
||||
const userId = userIds[index];
|
||||
const oldUser = await UsersOld.findOne({_id: userId}, 'achievements');
|
||||
const newUser = await Users.findOne({_id: userId}, 'achievements');
|
||||
const oldUser = await UsersOld.findOne({ _id: userId }, 'achievements');
|
||||
const newUser = await Users.findOne({ _id: userId }, 'achievements');
|
||||
const achievementUpdate = getAchievementUpdate(newUser, oldUser);
|
||||
await Users.update(
|
||||
{_id: userId},
|
||||
{ _id: userId },
|
||||
{
|
||||
$set: {
|
||||
achievements: achievementUpdate,
|
||||
},
|
||||
});
|
||||
},
|
||||
);
|
||||
console.log(`Updated ${userId}`);
|
||||
/* eslint-enable no-await-in-loop */
|
||||
}
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
/* eslint-disable no-console */
|
||||
import { sendTxn } from '../../website/server/libs/email';
|
||||
import { model as User } from '../../website/server/models/user';
|
||||
import moment from 'moment';
|
||||
import nconf from 'nconf';
|
||||
import { sendTxn } from '../../website/server/libs/email';
|
||||
import { model as User } from '../../website/server/models/user';
|
||||
|
||||
const BASE_URL = nconf.get('BASE_URL');
|
||||
const EMAIL_SLUG = 'mandrill-email-slug'; // Set email template to send
|
||||
const MIGRATION_NAME = 'bulk-email';
|
||||
@@ -18,16 +19,16 @@ async function updateUser (user) {
|
||||
sendTxn(
|
||||
user,
|
||||
EMAIL_SLUG,
|
||||
[{name: 'BASE_URL', content: BASE_URL}] // Add variables from template
|
||||
[{ name: 'BASE_URL', content: BASE_URL }], // Add variables from template
|
||||
);
|
||||
|
||||
return await User.update({_id: user._id}, {$set: {migration: MIGRATION_NAME}}).exec();
|
||||
return await User.update({ _id: user._id }, { $set: { migration: MIGRATION_NAME } }).exec();
|
||||
}
|
||||
|
||||
module.exports = async function processUsers () {
|
||||
let query = {
|
||||
migration: {$ne: MIGRATION_NAME},
|
||||
'auth.timestamps.loggedin': {$gt: moment().subtract(2, 'weeks').toDate()}, // customize or remove to target different populations
|
||||
const query = {
|
||||
migration: { $ne: MIGRATION_NAME },
|
||||
'auth.timestamps.loggedin': { $gt: moment().subtract(2, 'weeks').toDate() }, // customize or remove to target different populations
|
||||
};
|
||||
|
||||
const fields = {
|
||||
@@ -41,7 +42,7 @@ module.exports = async function processUsers () {
|
||||
const users = await User // eslint-disable-line no-await-in-loop
|
||||
.find(query)
|
||||
.limit(250)
|
||||
.sort({_id: 1})
|
||||
.sort({ _id: 1 })
|
||||
.select(fields)
|
||||
.lean()
|
||||
.exec();
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
/* eslint-disable no-console */
|
||||
const MIGRATION_NAME = 'full-stable';
|
||||
import each from 'lodash/each';
|
||||
import keys from 'lodash/keys';
|
||||
import content from '../../website/common/script/content/index';
|
||||
|
||||
import { model as User } from '../../website/server/models/user';
|
||||
|
||||
const MIGRATION_NAME = 'full-stable';
|
||||
|
||||
const progressCount = 1000;
|
||||
let count = 0;
|
||||
|
||||
@@ -20,39 +21,39 @@ async function updateUser (user) {
|
||||
|
||||
set.migration = MIGRATION_NAME;
|
||||
|
||||
each(keys(content.pets), (pet) => {
|
||||
each(keys(content.pets), pet => {
|
||||
set[`items.pets.${pet}`] = 5;
|
||||
});
|
||||
each(keys(content.premiumPets), (pet) => {
|
||||
each(keys(content.premiumPets), pet => {
|
||||
set[`items.pets.${pet}`] = 5;
|
||||
});
|
||||
each(keys(content.questPets), (pet) => {
|
||||
each(keys(content.questPets), pet => {
|
||||
set[`items.pets.${pet}`] = 5;
|
||||
});
|
||||
each(keys(content.specialPets), (pet) => {
|
||||
each(keys(content.specialPets), pet => {
|
||||
set[`items.pets.${pet}`] = 5;
|
||||
});
|
||||
each(keys(content.mounts), (mount) => {
|
||||
each(keys(content.mounts), mount => {
|
||||
set[`items.mounts.${mount}`] = true;
|
||||
});
|
||||
each(keys(content.premiumMounts), (mount) => {
|
||||
each(keys(content.premiumMounts), mount => {
|
||||
set[`items.mounts.${mount}`] = true;
|
||||
});
|
||||
each(keys(content.questMounts), (mount) => {
|
||||
each(keys(content.questMounts), mount => {
|
||||
set[`items.mounts.${mount}`] = true;
|
||||
});
|
||||
each(keys(content.specialMounts), (mount) => {
|
||||
each(keys(content.specialMounts), mount => {
|
||||
set[`items.mounts.${mount}`] = true;
|
||||
});
|
||||
|
||||
if (count % progressCount === 0) console.warn(`${count} ${user._id}`);
|
||||
|
||||
return await User.update({_id: user._id}, {$set: set}).exec();
|
||||
return await User.update({ _id: user._id }, { $set: set }).exec();
|
||||
}
|
||||
|
||||
module.exports = async function processUsers () {
|
||||
let query = {
|
||||
migration: {$ne: MIGRATION_NAME},
|
||||
const query = {
|
||||
migration: { $ne: MIGRATION_NAME },
|
||||
'auth.local.username': 'olson22',
|
||||
};
|
||||
|
||||
@@ -64,7 +65,7 @@ module.exports = async function processUsers () {
|
||||
const users = await User // eslint-disable-line no-await-in-loop
|
||||
.find(query)
|
||||
.limit(250)
|
||||
.sort({_id: 1})
|
||||
.sort({ _id: 1 })
|
||||
.select(fields)
|
||||
.lean()
|
||||
.exec();
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
/* eslint-disable no-console */
|
||||
const MIGRATION_NAME = 'mystery_items_201909';
|
||||
const MYSTERY_ITEMS = ['armor_mystery_201909', 'head_mystery_201909'];
|
||||
import { model as User } from '../../website/server/models/user';
|
||||
import { model as UserNotification } from '../../website/server/models/userNotification';
|
||||
|
||||
const MIGRATION_NAME = 'mystery_items_201909';
|
||||
const MYSTERY_ITEMS = ['armor_mystery_201909', 'head_mystery_201909'];
|
||||
|
||||
const progressCount = 1000;
|
||||
let count = 0;
|
||||
|
||||
@@ -29,12 +30,12 @@ async function updateUser (user) {
|
||||
|
||||
if (count % progressCount === 0) console.warn(`${count} ${user._id}`);
|
||||
|
||||
return await User.update({_id: user._id}, {$set: set, $push: push, $addToSet: addToSet}).exec();
|
||||
return await User.update({ _id: user._id }, { $set: set, $push: push, $addToSet: addToSet }).exec();
|
||||
}
|
||||
|
||||
module.exports = async function processUsers () {
|
||||
let query = {
|
||||
migration: {$ne: MIGRATION_NAME},
|
||||
const query = {
|
||||
migration: { $ne: MIGRATION_NAME },
|
||||
'purchased.plan.customerId': { $ne: null },
|
||||
$or: [
|
||||
{ 'purchased.plan.dateTerminated': { $gte: new Date() } },
|
||||
@@ -51,7 +52,7 @@ module.exports = async function processUsers () {
|
||||
const users = await User // eslint-disable-line no-await-in-loop
|
||||
.find(query)
|
||||
.limit(250)
|
||||
.sort({_id: 1})
|
||||
.sort({ _id: 1 })
|
||||
.select(fields)
|
||||
.lean()
|
||||
.exec();
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
/* eslint-disable no-console */
|
||||
const MIGRATION_NAME = '20190314_pi_day';
|
||||
import { v4 as uuid } from 'uuid';
|
||||
|
||||
import { model as User } from '../../website/server/models/user';
|
||||
|
||||
const MIGRATION_NAME = '20190314_pi_day';
|
||||
|
||||
const progressCount = 1000;
|
||||
let count = 0;
|
||||
|
||||
@@ -29,19 +30,19 @@ async function updateUser (user) {
|
||||
set['items.gear.owned.head_special_piDay'] = false;
|
||||
set['items.gear.owned.shield_special_piDay'] = false;
|
||||
const push = [
|
||||
{type: 'marketGear', path: 'gear.flat.head_special_piDay', _id: uuid()},
|
||||
{type: 'marketGear', path: 'gear.flat.shield_special_piDay', _id: uuid()},
|
||||
{ type: 'marketGear', path: 'gear.flat.head_special_piDay', _id: uuid() },
|
||||
{ type: 'marketGear', path: 'gear.flat.shield_special_piDay', _id: uuid() },
|
||||
];
|
||||
|
||||
if (count % progressCount === 0) console.warn(`${count} ${user._id}`);
|
||||
|
||||
return await User.update({_id: user._id}, {$inc: inc, $set: set, $push: {pinnedItems: {$each: push}}}).exec();
|
||||
return await User.update({ _id: user._id }, { $inc: inc, $set: set, $push: { pinnedItems: { $each: push } } }).exec();
|
||||
}
|
||||
|
||||
module.exports = async function processUsers () {
|
||||
let query = {
|
||||
migration: {$ne: MIGRATION_NAME},
|
||||
'auth.timestamps.loggedin': {$gt: new Date('2019-02-15')},
|
||||
const query = {
|
||||
migration: { $ne: MIGRATION_NAME },
|
||||
'auth.timestamps.loggedin': { $gt: new Date('2019-02-15') },
|
||||
};
|
||||
|
||||
const fields = {
|
||||
@@ -53,7 +54,7 @@ module.exports = async function processUsers () {
|
||||
const users = await User // eslint-disable-line no-await-in-loop
|
||||
.find(query)
|
||||
.limit(250)
|
||||
.sort({_id: 1})
|
||||
.sort({ _id: 1 })
|
||||
.select(fields)
|
||||
.lean()
|
||||
.exec();
|
||||
|
||||
@@ -8,12 +8,13 @@ const authorUuid = 'ed4c688c-6652-4a92-9d03-a5a79844174a'; // ... own data is do
|
||||
const connectionString = 'mongodb://localhost:27017/habitrpg?auto_reconnect=true'; // FOR TEST DATABASE
|
||||
|
||||
const monk = require('monk');
|
||||
|
||||
const dbUsers = monk(connectionString).get('users', { castIds: false });
|
||||
|
||||
function processUsers (lastId) {
|
||||
// specify a query to limit the affected users (empty for all users):
|
||||
let query = {
|
||||
migration: {$ne: migrationName},
|
||||
const query = {
|
||||
migration: { $ne: migrationName },
|
||||
$or: [
|
||||
{ 'auth.facebook.id': { $exists: true } },
|
||||
{ 'auth.google.id': { $exists: true } },
|
||||
@@ -27,17 +28,17 @@ function processUsers (lastId) {
|
||||
}
|
||||
|
||||
dbUsers.find(query, {
|
||||
sort: {_id: 1},
|
||||
sort: { _id: 1 },
|
||||
limit: 250,
|
||||
})
|
||||
.then(updateUsers)
|
||||
.catch((err) => {
|
||||
.catch(err => {
|
||||
console.log(err);
|
||||
return exiting(1, `ERROR! ${ err}`);
|
||||
return exiting(1, `ERROR! ${err}`);
|
||||
});
|
||||
}
|
||||
|
||||
let progressCount = 1000;
|
||||
const progressCount = 1000;
|
||||
let count = 0;
|
||||
|
||||
function updateUsers (users) {
|
||||
@@ -47,8 +48,8 @@ function updateUsers (users) {
|
||||
return;
|
||||
}
|
||||
|
||||
let userPromises = users.map(updateUser);
|
||||
let lastUser = users[users.length - 1];
|
||||
const userPromises = users.map(updateUser);
|
||||
const lastUser = users[users.length - 1];
|
||||
|
||||
return Promise.all(userPromises)
|
||||
.then(() => {
|
||||
@@ -82,12 +83,12 @@ function updateUser (user) {
|
||||
_id: user._id,
|
||||
}, update);
|
||||
|
||||
if (count % progressCount === 0) console.warn(`${count } ${ user._id}`);
|
||||
if (user._id === authorUuid) console.warn(`${authorName } processed`);
|
||||
if (count % progressCount === 0) console.warn(`${count} ${user._id}`);
|
||||
if (user._id === authorUuid) console.warn(`${authorName} processed`);
|
||||
}
|
||||
|
||||
function displayData () {
|
||||
console.warn(`\n${ count } users processed\n`);
|
||||
console.warn(`\n${count} users processed\n`);
|
||||
return exiting(0);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
/* eslint-disable no-console */
|
||||
const MIGRATION_NAME = '20181203_take_this';
|
||||
import { v4 as uuid } from 'uuid';
|
||||
|
||||
import { model as User } from '../../website/server/models/user';
|
||||
|
||||
const MIGRATION_NAME = '20181203_take_this';
|
||||
|
||||
const progressCount = 1000;
|
||||
let count = 0;
|
||||
|
||||
@@ -19,36 +20,35 @@ async function updateUser (user) {
|
||||
push = false;
|
||||
} else if (typeof user.items.gear.owned.body_special_takeThis !== 'undefined') {
|
||||
set['items.gear.owned.back_special_takeThis'] = false;
|
||||
push = {pinnedItems: {type: 'marketGear', path: 'gear.flat.back_special_takeThis', _id: uuid()}};
|
||||
push = { pinnedItems: { type: 'marketGear', path: 'gear.flat.back_special_takeThis', _id: uuid() } };
|
||||
} else if (typeof user.items.gear.owned.head_special_takeThis !== 'undefined') {
|
||||
set['items.gear.owned.body_special_takeThis'] = false;
|
||||
push = {pinnedItems: {type: 'marketGear', path: 'gear.flat.body_special_takeThis', _id: uuid()}};
|
||||
push = { pinnedItems: { type: 'marketGear', path: 'gear.flat.body_special_takeThis', _id: uuid() } };
|
||||
} else if (typeof user.items.gear.owned.armor_special_takeThis !== 'undefined') {
|
||||
set['items.gear.owned.head_special_takeThis'] = false;
|
||||
push = {pinnedItems: {type: 'marketGear', path: 'gear.flat.head_special_takeThis', _id: uuid()}};
|
||||
push = { pinnedItems: { type: 'marketGear', path: 'gear.flat.head_special_takeThis', _id: uuid() } };
|
||||
} else if (typeof user.items.gear.owned.weapon_special_takeThis !== 'undefined') {
|
||||
set['items.gear.owned.armor_special_takeThis'] = false;
|
||||
push = {pinnedItems: {type: 'marketGear', path: 'gear.flat.armor_special_takeThis', _id: uuid()}};
|
||||
push = { pinnedItems: { type: 'marketGear', path: 'gear.flat.armor_special_takeThis', _id: uuid() } };
|
||||
} else if (typeof user.items.gear.owned.shield_special_takeThis !== 'undefined') {
|
||||
set['items.gear.owned.weapon_special_takeThis'] = false;
|
||||
push = {pinnedItems: {type: 'marketGear', path: 'gear.flat.weapon_special_takeThis', _id: uuid()}};
|
||||
push = { pinnedItems: { type: 'marketGear', path: 'gear.flat.weapon_special_takeThis', _id: uuid() } };
|
||||
} else {
|
||||
set['items.gear.owned.shield_special_takeThis'] = false;
|
||||
push = {pinnedItems: {type: 'marketGear', path: 'gear.flat.shield_special_takeThis', _id: uuid()}};
|
||||
push = { pinnedItems: { type: 'marketGear', path: 'gear.flat.shield_special_takeThis', _id: uuid() } };
|
||||
}
|
||||
|
||||
if (count % progressCount === 0) console.warn(`${count} ${user._id}`);
|
||||
|
||||
if (push) {
|
||||
return await User.update({_id: user._id}, {$set: set, $push: push}).exec();
|
||||
} else {
|
||||
return await User.update({_id: user._id}, {$set: set}).exec();
|
||||
return await User.update({ _id: user._id }, { $set: set, $push: push }).exec();
|
||||
}
|
||||
return await User.update({ _id: user._id }, { $set: set }).exec();
|
||||
}
|
||||
|
||||
module.exports = async function processUsers () {
|
||||
let query = {
|
||||
migration: {$ne: MIGRATION_NAME},
|
||||
const query = {
|
||||
migration: { $ne: MIGRATION_NAME },
|
||||
challenges: '00708425-d477-41a5-bf27-6270466e7976',
|
||||
};
|
||||
|
||||
@@ -61,7 +61,7 @@ module.exports = async function processUsers () {
|
||||
const users = await User // eslint-disable-line no-await-in-loop
|
||||
.find(query)
|
||||
.limit(250)
|
||||
.sort({_id: 1})
|
||||
.sort({ _id: 1 })
|
||||
.select(fields)
|
||||
.lean()
|
||||
.exec();
|
||||
|
||||
@@ -8,22 +8,24 @@ let authorUuid = ''; // ... own data is done
|
||||
* This migraition will copy user data from prod to test
|
||||
*/
|
||||
|
||||
let monk = require('monk');
|
||||
let testConnectionSting = ''; // FOR TEST DATABASE
|
||||
let usersTest = monk(testConnectionSting).get('users', { castIds: false });
|
||||
let groupsTest = monk(testConnectionSting).get('groups', { castIds: false });
|
||||
let challengesTest = monk(testConnectionSting).get('challenges', { castIds: false });
|
||||
let tasksTest = monk(testConnectionSting).get('tasks', { castIds: false });
|
||||
|
||||
let monk2 = require('monk');
|
||||
let liveConnectString = ''; // FOR TEST DATABASE
|
||||
let userLive = monk2(liveConnectString).get('users', { castIds: false });
|
||||
let groupsLive = monk2(liveConnectString).get('groups', { castIds: false });
|
||||
let challengesLive = monk2(liveConnectString).get('challenges', { castIds: false });
|
||||
let tasksLive = monk2(liveConnectString).get('tasks', { castIds: false });
|
||||
|
||||
import uniq from 'lodash/uniq';
|
||||
|
||||
const monk = require('monk');
|
||||
|
||||
const testConnectionSting = ''; // FOR TEST DATABASE
|
||||
const usersTest = monk(testConnectionSting).get('users', { castIds: false });
|
||||
const groupsTest = monk(testConnectionSting).get('groups', { castIds: false });
|
||||
const challengesTest = monk(testConnectionSting).get('challenges', { castIds: false });
|
||||
const tasksTest = monk(testConnectionSting).get('tasks', { castIds: false });
|
||||
|
||||
const monk2 = require('monk');
|
||||
|
||||
const liveConnectString = ''; // FOR TEST DATABASE
|
||||
const userLive = monk2(liveConnectString).get('users', { castIds: false });
|
||||
const groupsLive = monk2(liveConnectString).get('groups', { castIds: false });
|
||||
const challengesLive = monk2(liveConnectString).get('challenges', { castIds: false });
|
||||
const tasksLive = monk2(liveConnectString).get('tasks', { castIds: false });
|
||||
|
||||
// Variabls for updating
|
||||
/*
|
||||
let userIds = [
|
||||
@@ -36,11 +38,11 @@ let challengeIds = [];
|
||||
let tasksIds = [];
|
||||
|
||||
async function processUsers () {
|
||||
let userPromises = [];
|
||||
const userPromises = [];
|
||||
// {_id: {$in: userIds}}
|
||||
|
||||
return userLive.find({guilds: 'b0764d64-8276-45a1-afa5-5ca9a5c64ca0'})
|
||||
.each((user) => {
|
||||
return userLive.find({ guilds: 'b0764d64-8276-45a1-afa5-5ca9a5c64ca0' })
|
||||
.each(user => {
|
||||
if (user.guilds.length > 0) groupIds = groupIds.concat(user.guilds);
|
||||
if (user.party._id) groupIds.push(user.party._id);
|
||||
if (user.challenges.length > 0) challengeIds = challengeIds.concat(user.challenges);
|
||||
@@ -49,56 +51,48 @@ async function processUsers () {
|
||||
if (user.tasksOrder.dailys.length > 0) tasksIds = tasksIds.concat(user.tasksOrder.dailys);
|
||||
if (user.tasksOrder.habits.length > 0) tasksIds = tasksIds.concat(user.tasksOrder.habits);
|
||||
|
||||
let userPromise = usersTest.update({_id: user._id}, user, {upsert: true});
|
||||
const userPromise = usersTest.update({ _id: user._id }, user, { upsert: true });
|
||||
userPromises.push(userPromise);
|
||||
}).then(() => {
|
||||
return Promise.all(userPromises);
|
||||
})
|
||||
}).then(() => Promise.all(userPromises))
|
||||
.then(() => {
|
||||
console.log('Done User');
|
||||
});
|
||||
}
|
||||
|
||||
function processGroups () {
|
||||
let promises = [];
|
||||
let groupsToQuery = uniq(groupIds);
|
||||
return groupsLive.find({_id: {$in: groupsToQuery}})
|
||||
.each((group) => {
|
||||
let promise = groupsTest.update({_id: group._id}, group, {upsert: true});
|
||||
const promises = [];
|
||||
const groupsToQuery = uniq(groupIds);
|
||||
return groupsLive.find({ _id: { $in: groupsToQuery } })
|
||||
.each(group => {
|
||||
const promise = groupsTest.update({ _id: group._id }, group, { upsert: true });
|
||||
promises.push(promise);
|
||||
}).then(() => {
|
||||
return Promise.all(promises);
|
||||
})
|
||||
}).then(() => Promise.all(promises))
|
||||
.then(() => {
|
||||
console.log('Done Group');
|
||||
});
|
||||
}
|
||||
|
||||
function processChallenges () {
|
||||
let promises = [];
|
||||
let challengesToQuery = uniq(challengeIds);
|
||||
return challengesLive.find({_id: {$in: challengesToQuery}})
|
||||
.each((challenge) => {
|
||||
let promise = challengesTest.update({_id: challenge._id}, challenge, {upsert: true});
|
||||
const promises = [];
|
||||
const challengesToQuery = uniq(challengeIds);
|
||||
return challengesLive.find({ _id: { $in: challengesToQuery } })
|
||||
.each(challenge => {
|
||||
const promise = challengesTest.update({ _id: challenge._id }, challenge, { upsert: true });
|
||||
promises.push(promise);
|
||||
}).then(() => {
|
||||
return Promise.all(promises);
|
||||
})
|
||||
}).then(() => Promise.all(promises))
|
||||
.then(() => {
|
||||
console.log('Done Challenge');
|
||||
});
|
||||
}
|
||||
|
||||
function processTasks () {
|
||||
let promises = [];
|
||||
let tasksToQuery = uniq(tasksIds);
|
||||
return tasksLive.find({_id: {$in: tasksToQuery}})
|
||||
.each((task) => {
|
||||
let promise = tasksTest.update({_id: task._id}, task, {upsert: true});
|
||||
const promises = [];
|
||||
const tasksToQuery = uniq(tasksIds);
|
||||
return tasksLive.find({ _id: { $in: tasksToQuery } })
|
||||
.each(task => {
|
||||
const promise = tasksTest.update({ _id: task._id }, task, { upsert: true });
|
||||
promises.push(promise);
|
||||
}).then(() => {
|
||||
return Promise.all(promises);
|
||||
})
|
||||
}).then(() => Promise.all(promises))
|
||||
.then(() => {
|
||||
console.log('Done Tasks');
|
||||
});
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
'use strict';
|
||||
|
||||
const MongoClient = require('mongodb').MongoClient;
|
||||
const { MongoClient } = require('mongodb');
|
||||
const logger = require('./logger');
|
||||
|
||||
let dbConnection;
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
'use strict';
|
||||
|
||||
const chalk = require('chalk');
|
||||
|
||||
function loggerGenerator (type, color) {
|
||||
return function logger () {
|
||||
let args = Array.from(arguments).map(arg => chalk[color](arg));
|
||||
const args = Array.from(arguments).map(arg => chalk[color](arg));
|
||||
console[type].apply(null, args);
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,30 +1,31 @@
|
||||
'use strict';
|
||||
|
||||
let logger = require('./logger');
|
||||
const logger = require('./logger');
|
||||
|
||||
class Timer {
|
||||
constructor (options) {
|
||||
options = options || {};
|
||||
let warningThreshold = options.minutesWarningThreshold || 10;
|
||||
const warningThreshold = options.minutesWarningThreshold || 10;
|
||||
|
||||
this.count = 0;
|
||||
this._minutesWarningThreshold = warningThreshold * 60;
|
||||
|
||||
if (!options.disableAutoStart) this.start();
|
||||
}
|
||||
|
||||
start () {
|
||||
this._internalTimer = setInterval(() => {
|
||||
this.count++;
|
||||
|
||||
let shouldWarn = this._minutesWarningThreshold < this.count;
|
||||
let logStyle = shouldWarn ? 'error' : 'warn';
|
||||
let dangerMessage = shouldWarn ? 'DANGER: ' : '';
|
||||
const shouldWarn = this._minutesWarningThreshold < this.count;
|
||||
const logStyle = shouldWarn ? 'error' : 'warn';
|
||||
const dangerMessage = shouldWarn ? 'DANGER: ' : '';
|
||||
|
||||
if (this.count % 30 === 0) {
|
||||
logger[logStyle](`${dangerMessage}Process has been running for`, this.count / 60, 'minutes');
|
||||
}
|
||||
}, 1000);
|
||||
}
|
||||
|
||||
stop () {
|
||||
if (!this._internalTimer) {
|
||||
throw new Error('Timer has not started');
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
'use strict';
|
||||
|
||||
function unique (array) {
|
||||
return Array.from(new Set(array));
|
||||
|
||||
905
package-lock.json
generated
905
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -72,7 +72,7 @@
|
||||
"npm": "^6"
|
||||
},
|
||||
"scripts": {
|
||||
"lint": "eslint --ext .js . && cd website/client && npm run lint",
|
||||
"lint": "eslint --ext .js ./website/common --fix",
|
||||
"test": "npm run lint && gulp test && gulp apidoc",
|
||||
"test:build": "gulp test:prepare:build",
|
||||
"test:api-v3": "gulp test:api-v3",
|
||||
@@ -101,8 +101,8 @@
|
||||
"chai": "^4.1.2",
|
||||
"chai-as-promised": "^7.1.1",
|
||||
"chalk": "^2.4.1",
|
||||
"eslint": "^4.19.1",
|
||||
"eslint-config-habitrpg": "^4.0.0",
|
||||
"eslint": "^6.5.1",
|
||||
"eslint-config-habitrpg": "^6.0.3",
|
||||
"eslint-plugin-mocha": "^5.0.0",
|
||||
"expect.js": "^0.3.1",
|
||||
"istanbul": "^1.1.0-alpha.1",
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
/* eslint-disable no-console */
|
||||
import axios from 'axios';
|
||||
import { model as User } from '../website/server/models/user';
|
||||
import nconf from 'nconf';
|
||||
import { model as User } from '../website/server/models/user';
|
||||
|
||||
const AMPLITUDE_KEY = nconf.get('AMPLITUDE_KEY');
|
||||
const AMPLITUDE_SECRET = nconf.get('AMPLITUDE_SECRET');
|
||||
const BASE_URL = nconf.get('BASE_URL');
|
||||
|
||||
async function _deleteAmplitudeData (userId, email) {
|
||||
async function deleteAmplitudeData (userId, email) {
|
||||
const response = await axios.post(
|
||||
'https://amplitude.com/api/2/deletions/users',
|
||||
{
|
||||
@@ -19,22 +19,24 @@ async function _deleteAmplitudeData (userId, email) {
|
||||
username: AMPLITUDE_KEY,
|
||||
password: AMPLITUDE_SECRET,
|
||||
},
|
||||
}
|
||||
).catch((err) => {
|
||||
},
|
||||
).catch(err => {
|
||||
console.log(err.response.data);
|
||||
});
|
||||
|
||||
if (response) console.log(`${response.status} ${response.statusText}`);
|
||||
}
|
||||
|
||||
async function _deleteHabiticaData (user, email) {
|
||||
async function deleteHabiticaData (user, email) {
|
||||
await User.update(
|
||||
{_id: user._id},
|
||||
{$set: {
|
||||
{ _id: user._id },
|
||||
{
|
||||
$set: {
|
||||
'auth.local.email': email,
|
||||
'auth.local.hashed_password': '$2a$10$QDnNh1j1yMPnTXDEOV38xOePEWFd4X8DSYwAM8XTmqmacG5X0DKjW',
|
||||
'auth.local.passwordHashMethod': 'bcrypt',
|
||||
}}
|
||||
},
|
||||
},
|
||||
);
|
||||
const response = await axios.delete(
|
||||
`${BASE_URL}/api/v3/user`,
|
||||
@@ -46,8 +48,8 @@ async function _deleteHabiticaData (user, email) {
|
||||
'x-api-user': user._id,
|
||||
'x-api-key': user.apiToken,
|
||||
},
|
||||
}
|
||||
).catch((err) => {
|
||||
},
|
||||
).catch(err => {
|
||||
console.log(err.response.data);
|
||||
});
|
||||
|
||||
@@ -57,14 +59,15 @@ async function _deleteHabiticaData (user, email) {
|
||||
}
|
||||
}
|
||||
|
||||
async function _processEmailAddress (email) {
|
||||
async function processEmailAddress (email) {
|
||||
const emailRegex = new RegExp(`^${email}$`, 'i');
|
||||
const users = await User.find({
|
||||
$or: [
|
||||
{'auth.local.email': emailRegex},
|
||||
{'auth.facebook.emails.value': emailRegex},
|
||||
{'auth.google.emails.value': emailRegex},
|
||||
]},
|
||||
{ 'auth.local.email': emailRegex },
|
||||
{ 'auth.facebook.emails.value': emailRegex },
|
||||
{ 'auth.google.emails.value': emailRegex },
|
||||
],
|
||||
},
|
||||
{
|
||||
_id: 1,
|
||||
apiToken: 1,
|
||||
@@ -75,14 +78,14 @@ async function _processEmailAddress (email) {
|
||||
console.log(`No users found with email address ${email}`);
|
||||
} else {
|
||||
for (const user of users) {
|
||||
await _deleteAmplitudeData(user._id, email); // eslint-disable-line no-await-in-loop
|
||||
await _deleteHabiticaData(user, email); // eslint-disable-line no-await-in-loop
|
||||
await deleteAmplitudeData(user._id, email); // eslint-disable-line no-await-in-loop
|
||||
await deleteHabiticaData(user, email); // eslint-disable-line no-await-in-loop
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function deleteUserData (emails) {
|
||||
const emailPromises = emails.map(_processEmailAddress);
|
||||
const emailPromises = emails.map(processEmailAddress);
|
||||
return Promise.all(emailPromises);
|
||||
}
|
||||
|
||||
|
||||
@@ -12,11 +12,12 @@ const nconf = require('nconf');
|
||||
const _ = require('lodash');
|
||||
const paypal = require('paypal-rest-sdk');
|
||||
const blocks = require('../website/common').content.subscriptionBlocks;
|
||||
|
||||
const live = nconf.get('PAYPAL_MODE') === 'live';
|
||||
|
||||
nconf.argv().env().file('user', path.join(path.resolve(__dirname, '../config.json')));
|
||||
|
||||
let OP = 'create'; // list get update create create-webprofile
|
||||
const OP = 'create'; // list get update create create-webprofile
|
||||
|
||||
paypal.configure({
|
||||
mode: nconf.get('PAYPAL_MODE'), // sandbox or live
|
||||
@@ -25,8 +26,8 @@ paypal.configure({
|
||||
});
|
||||
|
||||
// https://developer.paypal.com/docs/api/#billing-plans-and-agreements
|
||||
let billingPlanTitle = 'Habitica Subscription';
|
||||
let billingPlanAttributes = {
|
||||
const billingPlanTitle = 'Habitica Subscription';
|
||||
const billingPlanAttributes = {
|
||||
description: billingPlanTitle,
|
||||
type: 'INFINITE',
|
||||
merchant_preferences: {
|
||||
@@ -41,7 +42,7 @@ let billingPlanAttributes = {
|
||||
}],
|
||||
};
|
||||
|
||||
_.each(blocks, (block) => {
|
||||
_.each(blocks, block => {
|
||||
block.definition = _.cloneDeep(billingPlanAttributes);
|
||||
_.merge(block.definition.payment_definitions[0], {
|
||||
name: `${billingPlanTitle} ($${block.price} every ${block.months} months, recurring)`,
|
||||
@@ -57,17 +58,17 @@ _.each(blocks, (block) => {
|
||||
|
||||
switch (OP) {
|
||||
case 'list':
|
||||
paypal.billingPlan.list({status: 'ACTIVE'}, (err, plans) => {
|
||||
console.log({err, plans});
|
||||
paypal.billingPlan.list({ status: 'ACTIVE' }, (err, plans) => {
|
||||
console.log({ err, plans });
|
||||
});
|
||||
break;
|
||||
case 'get':
|
||||
paypal.billingPlan.get(nconf.get('PAYPAL_BILLING_PLANS_basic_12mo'), (err, plan) => {
|
||||
console.log({err, plan});
|
||||
console.log({ err, plan });
|
||||
});
|
||||
break;
|
||||
case 'update':
|
||||
let updatePayload = {
|
||||
const updatePayload = {
|
||||
op: 'replace',
|
||||
path: '/merchant_preferences',
|
||||
value: {
|
||||
@@ -75,7 +76,7 @@ switch (OP) {
|
||||
},
|
||||
};
|
||||
paypal.billingPlan.update(nconf.get('PAYPAL_BILLING_PLANS_basic_12mo'), updatePayload, (err, res) => {
|
||||
console.log({err, plan: res});
|
||||
console.log({ err, plan: res });
|
||||
});
|
||||
break;
|
||||
case 'create':
|
||||
@@ -83,10 +84,10 @@ switch (OP) {
|
||||
if (err) return console.log(err);
|
||||
|
||||
if (plan.state === 'ACTIVE') {
|
||||
return console.log({err, plan});
|
||||
return console.log({ err, plan });
|
||||
}
|
||||
|
||||
let billingPlanUpdateAttributes = [{
|
||||
const billingPlanUpdateAttributes = [{
|
||||
op: 'replace',
|
||||
path: '/',
|
||||
value: {
|
||||
@@ -96,12 +97,12 @@ switch (OP) {
|
||||
|
||||
// Activate the plan by changing status to Active
|
||||
paypal.billingPlan.update(plan.id, billingPlanUpdateAttributes, (err2, response) => {
|
||||
console.log({err: err2, response, id: plan.id});
|
||||
console.log({ err: err2, response, id: plan.id });
|
||||
});
|
||||
});
|
||||
break;
|
||||
case 'create-webprofile':
|
||||
let webexpinfo = {
|
||||
const webexpinfo = {
|
||||
name: 'HabiticaProfile',
|
||||
input_fields: {
|
||||
no_shipping: 1,
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
'use strict';
|
||||
|
||||
let pathToCommon;
|
||||
|
||||
|
||||
@@ -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 */
|
||||
});
|
||||
|
||||
@@ -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 }),
|
||||
|
||||
@@ -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'),
|
||||
|
||||
@@ -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'),
|
||||
|
||||
@@ -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'),
|
||||
|
||||
@@ -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'),
|
||||
|
||||
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);
|
||||
};
|
||||
};
|
||||
|
||||
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,
|
||||
|
||||
@@ -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);
|
||||
};
|
||||
};
|
||||
|
||||
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;
|
||||
},
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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 }),
|
||||
|
||||
@@ -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'),
|
||||
|
||||
@@ -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,
|
||||
@@ -46,12 +46,12 @@ const rtlLanguages = [
|
||||
'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,8 +810,7 @@ api.food = {
|
||||
/* eslint-enable camelcase */
|
||||
};
|
||||
|
||||
each(api.food, (food, key) => {
|
||||
return defaults(food, {
|
||||
each(api.food, (food, key) => defaults(food, {
|
||||
value: 1,
|
||||
key,
|
||||
notes: t('foodNotes'),
|
||||
@@ -819,8 +818,7 @@ each(api.food, (food, key) => {
|
||||
return false;
|
||||
},
|
||||
canDrop: false,
|
||||
});
|
||||
});
|
||||
}));
|
||||
|
||||
api.appearances = appearances;
|
||||
|
||||
|
||||
@@ -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', {
|
||||
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', {
|
||||
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', {
|
||||
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', {
|
||||
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', {
|
||||
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', {
|
||||
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', {
|
||||
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', {
|
||||
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;
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user