change types (might break databases\!)
This commit is contained in:
parent
a9fee71c6a
commit
49a349d237
|
@ -8,16 +8,16 @@ module.exports = (app, db) : void => {
|
||||||
|
|
||||||
console.log(req.body);
|
console.log(req.body);
|
||||||
|
|
||||||
if (req.body.featured != '0') searchQuery.featured = 1;
|
if (req.body.featured != '0') searchQuery.featured = true;
|
||||||
if (req.body.epic != '0') searchQuery.epic = 1;
|
if (req.body.epic != '0') searchQuery.epic = true;
|
||||||
if (req.body.coins != '0') searchQuery.coins = 1;
|
if (req.body.coins != '0') searchQuery.coins = true;
|
||||||
if (req.body.twoPlayer != '0') searchQuery.twoPlayer = 1;
|
if (req.body.twoPlayer != '0') searchQuery.twoPlayer = true;
|
||||||
if (req.body.star) searchQuery.stars = {$gt: 0};
|
if (req.body.star) searchQuery.stars = {$gt: 0};
|
||||||
if (req.body.original != '0') searchQuery.original = 1;
|
if (req.body.original != '0') searchQuery.original = true;
|
||||||
|
|
||||||
if (req.body.diff != '-') {
|
if (req.body.diff != '-') {
|
||||||
// if the client requests -1, -2 or -3 then it cant request any other difficulties
|
// if the client requests -1, -2 or -3 then it cant request any other difficulties
|
||||||
searchQuery.auto = 0;
|
searchQuery.auto = false;
|
||||||
if (req.body.diff == '-1') { // NA levels
|
if (req.body.diff == '-1') { // NA levels
|
||||||
searchQuery.diff = 0;
|
searchQuery.diff = 0;
|
||||||
} else if(req.body.diff == '-2') { // demons
|
} else if(req.body.diff == '-2') { // demons
|
||||||
|
@ -27,7 +27,7 @@ module.exports = (app, db) : void => {
|
||||||
searchQuery.diff = { $gte: 60 };
|
searchQuery.diff = { $gte: 60 };
|
||||||
}
|
}
|
||||||
} else if(req.body.diff == '-3') { // auto
|
} else if(req.body.diff == '-3') { // auto
|
||||||
searchQuery.auto = 1;
|
searchQuery.auto = true;
|
||||||
} else {
|
} else {
|
||||||
searchQuery.$or = req.body.diff
|
searchQuery.$or = req.body.diff
|
||||||
.split(',') // multiple diffs
|
.split(',') // multiple diffs
|
||||||
|
@ -91,7 +91,7 @@ module.exports = (app, db) : void => {
|
||||||
|
|
||||||
let results = foundLevels
|
let results = foundLevels
|
||||||
.map(l =>
|
.map(l =>
|
||||||
`1:${l.id}:2:${l.name}:5:0:6:16:8:10:9:${l.diff}:10:${l.downloads}:12:1:13:21:14:${l.likes}:17:0:43:0:25:${l.auto ? '1' : '0'}:18:${l.stars}:19:0:42:0:45:10:3:${l.description}:15:1:30:0:31:0:37:0:38:0:39:0:46:1:47:2:40:0:35:0`
|
`1:${l.id}:2:${l.name}:5:0:6:16:8:10:9:${l.diff}:10:${l.downloads}:12:1:13:21:14:${l.likes}:17:0:43:0:25:${Number(l.auto)}:18:${l.stars}:19:0:42:0:45:10:3:${l.description}:15:1:30:0:31:0:37:0:38:0:39:0:46:1:47:2:40:0:35:0`
|
||||||
)
|
)
|
||||||
.join('|');
|
.join('|');
|
||||||
|
|
||||||
|
|
|
@ -15,37 +15,37 @@ module.exports = (app, db): void => {
|
||||||
'id': levelID,
|
'id': levelID,
|
||||||
'level_data': req.body.levelString,
|
'level_data': req.body.levelString,
|
||||||
'extra_data': req.body.extraString || '29_29_29_40_29_29_29_29_29_29_29_29_29_29_29_29',
|
'extra_data': req.body.extraString || '29_29_29_40_29_29_29_29_29_29_29_29_29_29_29_29',
|
||||||
'level_info': req.body.levelInfo || 0,
|
'level_info': req.body.levelInfo || '0',
|
||||||
'timestamp': Date.now(),
|
'timestamp': Date.now(),
|
||||||
'description': req.body.levelDesc,
|
'description': req.body.levelDesc,
|
||||||
'game_version': req.body.gameVersion || 0,
|
'game_version': Number(req.body.gameVersion || 0),
|
||||||
'binary_version': req.body.binaryVersion || 0,
|
'binary_version': Number(req.body.binaryVersion || 0),
|
||||||
'username': req.body.userName,
|
'username': req.body.userName,
|
||||||
'version': req.body.levelVersion,
|
'version': Number(req.body.levelVersion),
|
||||||
'length': req.body.levelLength,
|
'length': Number(req.body.levelLength),
|
||||||
// difference between audio_track and song_id is
|
// difference between audio_track and song_id is
|
||||||
// audio_track is official songs and song_id is newgrounds aka custom songs
|
// audio_track is official songs and song_id is newgrounds aka custom songs
|
||||||
'audio_track': req.body.audioTrack,
|
'audio_track': Number(req.body.audioTrack),
|
||||||
'song_id': req.body.songID,
|
'song_id': Number(req.body.songID),
|
||||||
'auto': Number(req.body.auto || 0),
|
'auto': false,
|
||||||
'password': Number(req.body.password || 0),
|
'password': Number(req.body.password || 0),
|
||||||
'original': req.body.original || 0,
|
'original': Boolean(req.body.original || 0),
|
||||||
'two_player': Number(req.body.twoPlayer || 0),
|
'two_player': Boolean(req.body.twoPlayer || 0),
|
||||||
'objects': req.body.objects || 0,
|
'objects': Number(req.body.objects || 0),
|
||||||
'coins': req.body.coins || 0,
|
'coins': Number(req.body.coins || 0),
|
||||||
'requested_stars': req.body.requestedStars || 0,
|
'requested_stars': Number(req.body.requestedStars || 0),
|
||||||
'secret': req.body.secret,
|
'secret': req.body.secret,
|
||||||
'user_id': -1, // no user_id yet
|
'user_id': -1, // no user_id yet
|
||||||
'udid': udid, // ??? i have no idea what this is
|
'udid': udid, // ??? i have no idea what this is
|
||||||
'unlisted': req.body.unlisted || 0,
|
'unlisted': Boolean(req.body.unlisted || 0),
|
||||||
'ldm': req.body.ldm || 0,
|
'ldm': Boolean(req.body.ldm || 0),
|
||||||
// online stuff
|
// online stuff
|
||||||
'downloads': 0,
|
'downloads': 0,
|
||||||
'likes': 0,
|
'likes': 0,
|
||||||
'difficulty': 0, // 0 = N/A 10 = EASY 20 = NORMAL 30 = HARD 40 = HARDER 50 = INSANE 50 = AUTO 50 = DEMON
|
'difficulty': 0, // 0 = N/A 10 = EASY 20 = NORMAL 30 = HARD 40 = HARDER 50 = INSANE 50 = AUTO 50 = DEMON
|
||||||
'stars': 0,
|
'stars': 0,
|
||||||
'featured': 0,
|
'featured': false,
|
||||||
'epic': 0
|
'epic': false
|
||||||
});
|
});
|
||||||
|
|
||||||
res.status(200).send(String(levelID));
|
res.status(200).send(String(levelID));
|
||||||
|
|
Loading…
Reference in New Issue