From 49a349d237aa958352bfb817a25a198ebd0ce205 Mon Sep 17 00:00:00 2001 From: oatmealine Date: Sat, 25 Jan 2020 16:30:53 +0300 Subject: [PATCH] change types (might break databases\!) --- src/getGJLevels21.ts | 16 ++++++++-------- src/uploadGJLevel21.ts | 34 +++++++++++++++++----------------- 2 files changed, 25 insertions(+), 25 deletions(-) diff --git a/src/getGJLevels21.ts b/src/getGJLevels21.ts index bb6dc51..4992f2c 100644 --- a/src/getGJLevels21.ts +++ b/src/getGJLevels21.ts @@ -8,16 +8,16 @@ module.exports = (app, db) : void => { console.log(req.body); - if (req.body.featured != '0') searchQuery.featured = 1; - if (req.body.epic != '0') searchQuery.epic = 1; - if (req.body.coins != '0') searchQuery.coins = 1; - if (req.body.twoPlayer != '0') searchQuery.twoPlayer = 1; + if (req.body.featured != '0') searchQuery.featured = true; + if (req.body.epic != '0') searchQuery.epic = true; + if (req.body.coins != '0') searchQuery.coins = true; + if (req.body.twoPlayer != '0') searchQuery.twoPlayer = true; 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 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 searchQuery.diff = 0; } else if(req.body.diff == '-2') { // demons @@ -27,7 +27,7 @@ module.exports = (app, db) : void => { searchQuery.diff = { $gte: 60 }; } } else if(req.body.diff == '-3') { // auto - searchQuery.auto = 1; + searchQuery.auto = true; } else { searchQuery.$or = req.body.diff .split(',') // multiple diffs @@ -91,7 +91,7 @@ module.exports = (app, db) : void => { let results = foundLevels .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('|'); diff --git a/src/uploadGJLevel21.ts b/src/uploadGJLevel21.ts index 9364e2d..83731e6 100644 --- a/src/uploadGJLevel21.ts +++ b/src/uploadGJLevel21.ts @@ -15,37 +15,37 @@ module.exports = (app, db): void => { 'id': levelID, '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', - 'level_info': req.body.levelInfo || 0, + 'level_info': req.body.levelInfo || '0', 'timestamp': Date.now(), 'description': req.body.levelDesc, - 'game_version': req.body.gameVersion || 0, - 'binary_version': req.body.binaryVersion || 0, + 'game_version': Number(req.body.gameVersion || 0), + 'binary_version': Number(req.body.binaryVersion || 0), 'username': req.body.userName, - 'version': req.body.levelVersion, - 'length': req.body.levelLength, + 'version': Number(req.body.levelVersion), + 'length': Number(req.body.levelLength), // difference between audio_track and song_id is // audio_track is official songs and song_id is newgrounds aka custom songs - 'audio_track': req.body.audioTrack, - 'song_id': req.body.songID, - 'auto': Number(req.body.auto || 0), + 'audio_track': Number(req.body.audioTrack), + 'song_id': Number(req.body.songID), + 'auto': false, 'password': Number(req.body.password || 0), - 'original': req.body.original || 0, - 'two_player': Number(req.body.twoPlayer || 0), - 'objects': req.body.objects || 0, - 'coins': req.body.coins || 0, - 'requested_stars': req.body.requestedStars || 0, + 'original': Boolean(req.body.original || 0), + 'two_player': Boolean(req.body.twoPlayer || 0), + 'objects': Number(req.body.objects || 0), + 'coins': Number(req.body.coins || 0), + 'requested_stars': Number(req.body.requestedStars || 0), 'secret': req.body.secret, 'user_id': -1, // no user_id yet 'udid': udid, // ??? i have no idea what this is - 'unlisted': req.body.unlisted || 0, - 'ldm': req.body.ldm || 0, + 'unlisted': Boolean(req.body.unlisted || 0), + 'ldm': Boolean(req.body.ldm || 0), // online stuff 'downloads': 0, 'likes': 0, 'difficulty': 0, // 0 = N/A 10 = EASY 20 = NORMAL 30 = HARD 40 = HARDER 50 = INSANE 50 = AUTO 50 = DEMON 'stars': 0, - 'featured': 0, - 'epic': 0 + 'featured': false, + 'epic': false }); res.status(200).send(String(levelID));