Apply max-line length
parent
a2215eff59
commit
e7df8a0c94
|
@ -17,13 +17,7 @@ const AwardingModel = require('../models/awarding');
|
||||||
|
|
||||||
// result set for proposer(appUser) population
|
// result set for proposer(appUser) population
|
||||||
const resultSet = {
|
const resultSet = {
|
||||||
'__v': 0,
|
'__v': 0, 'updatedAt': 0, 'timestamp': 0, 'password': 0, 'permission': 0, 'secret': 0, 'activated': 0,
|
||||||
'updatedAt': 0,
|
|
||||||
'timestamp': 0,
|
|
||||||
'password': 0,
|
|
||||||
'permission': 0,
|
|
||||||
'secret': 0,
|
|
||||||
'activated': 0,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const awarding = express.Router();
|
const awarding = express.Router();
|
||||||
|
@ -56,28 +50,29 @@ awarding.route('/')
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
AwardingModel.find(filter, {}, {sort: {date: 'desc'}})
|
AwardingModel.find(filter, {}, {sort: {date: 'desc'}})
|
||||||
.populate('decorationId').populate('proposer', resultSet).populate('userId').exec((err, items) => {
|
.populate('decorationId').populate('proposer', resultSet).populate('userId')
|
||||||
if (err) {
|
.exec((err, items) => {
|
||||||
err.status = codes.servererror;
|
if (err) {
|
||||||
return next(err);
|
err.status = codes.servererror;
|
||||||
// with return before (or after) the next(err) we prevent that the code continues here after next(err)
|
return next(err);
|
||||||
// has finished. this saves an extra else {..}
|
// with return before (or after) the next(err) we prevent that the code continues here
|
||||||
}
|
// after next(err) has finished. this saves an extra else {..}
|
||||||
let results = [];
|
}
|
||||||
if (req.query.fractFilter) {
|
let results = [];
|
||||||
for (let item of items) {
|
if (req.query.fractFilter) {
|
||||||
if (item.decorationId.fraction === req.query.fractFilter) {
|
for (let item of items) {
|
||||||
results.push(item);
|
if (item.decorationId.fraction === req.query.fractFilter) {
|
||||||
}
|
results.push(item);
|
||||||
}
|
}
|
||||||
res.locals.items = results;
|
}
|
||||||
} else {
|
res.locals.items = results;
|
||||||
res.locals.items = items;
|
} else {
|
||||||
}
|
res.locals.items = items;
|
||||||
|
}
|
||||||
|
|
||||||
res.locals.processed = true;
|
res.locals.processed = true;
|
||||||
next();
|
next();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -98,9 +93,7 @@ awarding.route('/')
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
|
|
||||||
.all(
|
.all(routerHandling.httpMethodNotAllowed);
|
||||||
routerHandling.httpMethodNotAllowed
|
|
||||||
);
|
|
||||||
|
|
||||||
awarding.route('/:id')
|
awarding.route('/:id')
|
||||||
|
|
||||||
|
@ -146,9 +139,7 @@ awarding.route('/:id')
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
|
|
||||||
.all(
|
.all(routerHandling.httpMethodNotAllowed);
|
||||||
routerHandling.httpMethodNotAllowed
|
|
||||||
);
|
|
||||||
|
|
||||||
// this middleware function can be used, if you like or remove it
|
// this middleware function can be used, if you like or remove it
|
||||||
// it looks for object(s) in res.locals.items and if they exist, they are send to the client as json
|
// it looks for object(s) in res.locals.items and if they exist, they are send to the client as json
|
||||||
|
|
|
@ -67,7 +67,8 @@ decoration.route('/')
|
||||||
}
|
}
|
||||||
res.status(codes.created);
|
res.status(codes.created);
|
||||||
res.locals.items = decoration;
|
res.locals.items = decoration;
|
||||||
fs.appendFile(__dirname + '/../resource/decoration/' + decoration.id + '.png', new Buffer(req.file.buffer),
|
fs.appendFile(__dirname + '/../resource/decoration/' + decoration.id + '.png',
|
||||||
|
new Buffer(req.file.buffer),
|
||||||
(err) => {
|
(err) => {
|
||||||
if (err) next(err);
|
if (err) next(err);
|
||||||
});
|
});
|
||||||
|
|
|
@ -42,7 +42,8 @@ campaignPlayer.route('/ranking/:campaignId')
|
||||||
|
|
||||||
new Set(items.map(usesUUID ? (x) => x.steamUUID : (x) => x.name))
|
new Set(items.map(usesUUID ? (x) => x.steamUUID : (x) => x.name))
|
||||||
.forEach((player) => {
|
.forEach((player) => {
|
||||||
const playerInstances = items.filter(usesUUID ? (p) => p.steamUUID === player : (p) => p.name === player);
|
const playerInstances = items.filter(
|
||||||
|
usesUUID ? (p) => p.steamUUID === player : (p) => p.name === player);
|
||||||
const resItem = {
|
const resItem = {
|
||||||
name: usesUUID ? playerInstances[playerInstances.length - 1].name : player,
|
name: usesUUID ? playerInstances[playerInstances.length - 1].name : player,
|
||||||
kill: 0,
|
kill: 0,
|
||||||
|
|
|
@ -23,8 +23,8 @@ const createString = (possible, length) => {
|
||||||
let text = '';
|
let text = '';
|
||||||
|
|
||||||
for (let i = 0; i < length; i++) {
|
for (let i = 0; i < length; i++) {
|
||||||
text += possible.charAt(Math.floor(Math.random() * possible.length));
|
text += possible.charAt(Math.floor(Math.random() * possible.length));
|
||||||
}
|
}
|
||||||
|
|
||||||
return text;
|
return text;
|
||||||
};
|
};
|
||||||
|
|
|
@ -206,8 +206,10 @@ const parseWarLog = (lineArray, war) => {
|
||||||
const playerName = stats.players[i].name;
|
const playerName = stats.players[i].name;
|
||||||
stats.players[i]['respawn'] = stats.respawn.filter((res) => res.player === playerName).length;
|
stats.players[i]['respawn'] = stats.respawn.filter((res) => res.player === playerName).length;
|
||||||
stats.players[i]['kill'] = stats.kills.filter((kill) => kill.shooter === playerName && !kill.friendlyFire).length;
|
stats.players[i]['kill'] = stats.kills.filter((kill) => kill.shooter === playerName && !kill.friendlyFire).length;
|
||||||
stats.players[i]['vehicle'] = stats.vehicles.filter((vehicle) => vehicle.shooter === playerName && vehicleBlacklist.indexOf(vehicle.target) < 0).length;
|
stats.players[i]['vehicle'] = stats.vehicles.filter(
|
||||||
stats.players[i]['friendlyFire'] = stats.kills.filter((kill) => kill.shooter === playerName && kill.friendlyFire).length;
|
(vehicle) => vehicle.shooter === playerName && vehicleBlacklist.indexOf(vehicle.target) < 0).length;
|
||||||
|
stats.players[i]['friendlyFire'] = stats.kills.filter(
|
||||||
|
(kill) => kill.shooter === playerName && kill.friendlyFire).length;
|
||||||
stats.players[i]['death'] = stats.kills.filter((kill) => kill.target === playerName).length;
|
stats.players[i]['death'] = stats.kills.filter((kill) => kill.target === playerName).length;
|
||||||
stats.players[i]['revive'] = stats.revive.filter((rev) => rev.medic === playerName && !rev.stabilized).length;
|
stats.players[i]['revive'] = stats.revive.filter((rev) => rev.medic === playerName && !rev.stabilized).length;
|
||||||
stats.players[i]['flagTouch'] = stats.flag.filter((flag) => flag.player === playerName).length;
|
stats.players[i]['flagTouch'] = stats.flag.filter((flag) => flag.player === playerName).length;
|
||||||
|
|
|
@ -179,29 +179,30 @@ let addDecorationsAndSave = (userId, loadedImage, res, next) => {
|
||||||
|
|
||||||
// use synchronized call to keep correct order of decorations
|
// use synchronized call to keep correct order of decorations
|
||||||
async.eachSeries(awardings, (award, callback) => {
|
async.eachSeries(awardings, (award, callback) => {
|
||||||
jimp.read(resourceDir + 'decoration/' + award.decorationId._id + fileExt).then((decorationImage) => {
|
jimp.read(resourceDir + 'decoration/' + award.decorationId._id + fileExt)
|
||||||
if (award.decorationId.isMedal) {
|
.then((decorationImage) => {
|
||||||
decorationImage.resize(medalW, medalH);
|
if (award.decorationId.isMedal) {
|
||||||
loadedImage.composite(decorationImage, medalPx, medalPy);
|
decorationImage.resize(medalW, medalH);
|
||||||
if (medalPy === 5) {
|
loadedImage.composite(decorationImage, medalPx, medalPy);
|
||||||
medalPx = medalPx - 1 - medalW;
|
if (medalPy === 5) {
|
||||||
} else {
|
medalPx = medalPx - 1 - medalW;
|
||||||
medalPx = medalPx + 1 + medalW;
|
} else {
|
||||||
}
|
medalPx = medalPx + 1 + medalW;
|
||||||
if (medalPx <= 300) {
|
}
|
||||||
medalPy = medalPy + 3 + medalH;
|
if (medalPx <= 300) {
|
||||||
}
|
medalPy = medalPy + 3 + medalH;
|
||||||
} else {
|
}
|
||||||
decorationImage.resize(ribbonW, ribbonH);
|
} else {
|
||||||
loadedImage.composite(decorationImage, ribbonPx, ribbonPy);
|
decorationImage.resize(ribbonW, ribbonH);
|
||||||
ribbonPx = ribbonPx - 2 - ribbonW;
|
loadedImage.composite(decorationImage, ribbonPx, ribbonPy);
|
||||||
if (ribbonPx <= 154) {
|
ribbonPx = ribbonPx - 2 - ribbonW;
|
||||||
ribbonPy = ribbonPy - 3 - ribbonH;
|
if (ribbonPx <= 154) {
|
||||||
ribbonPx = 598;
|
ribbonPy = ribbonPy - 3 - ribbonH;
|
||||||
}
|
ribbonPx = 598;
|
||||||
}
|
}
|
||||||
callback();
|
}
|
||||||
});
|
callback();
|
||||||
|
});
|
||||||
}, (err) => {
|
}, (err) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
throw err;
|
throw err;
|
||||||
|
|
Loading…
Reference in New Issue