2019-10-16 19:47:53 -03:00
|
|
|
module.exports = async (app, req, res) => {
|
2019-10-15 23:42:47 -03:00
|
|
|
|
2021-01-18 23:54:18 -03:00
|
|
|
if (req.offline) return res.send("-1")
|
2020-09-10 10:02:40 -03:00
|
|
|
|
2019-10-15 23:42:47 -03:00
|
|
|
let amount = 100;
|
|
|
|
let count = req.query.count ? parseInt(req.query.count) : null
|
|
|
|
if (count && count > 0) {
|
2019-11-09 21:59:11 -03:00
|
|
|
if (count > 5000) amount = 5000
|
2019-10-15 23:42:47 -03:00
|
|
|
else amount = count;
|
|
|
|
}
|
|
|
|
|
2021-01-11 18:00:21 -03:00
|
|
|
let params = {count: amount, type: "top"}
|
2019-10-15 23:42:47 -03:00
|
|
|
|
2021-01-11 18:00:21 -03:00
|
|
|
if (["creators", "creator", "cp"].some(x => req.query.hasOwnProperty(x) || req.query.type == x)) params.type = "creators"
|
2021-01-23 00:28:26 -03:00
|
|
|
else if (["week", "weekly"].some(x => req.query.hasOwnProperty(x) || req.query.type == x)) params.type = "week"
|
2021-01-07 12:38:55 -03:00
|
|
|
|
2021-01-18 23:54:18 -03:00
|
|
|
req.gdRequest('getGJScores20', params, function(err, resp, body) {
|
2019-10-15 23:42:47 -03:00
|
|
|
|
2021-08-18 20:10:35 -04:00
|
|
|
if (err) return res.send("-1")
|
2019-10-15 23:42:47 -03:00
|
|
|
scores = body.split('|').map(x => app.parseResponse(x)).filter(x => x[1])
|
|
|
|
if (!scores.length) return res.send("-1")
|
|
|
|
|
|
|
|
scores.forEach(x => {
|
|
|
|
let keys = Object.keys(x)
|
2020-10-02 15:33:24 -03:00
|
|
|
x.rank = +x[6]
|
2019-10-15 23:42:47 -03:00
|
|
|
x.username = x[1]
|
|
|
|
x.playerID = x[2]
|
|
|
|
x.accountID = x[16]
|
2020-10-02 15:33:24 -03:00
|
|
|
x.stars = +x[3]
|
|
|
|
x.demons = +x[4]
|
|
|
|
x.cp = +x[8]
|
|
|
|
x.coins = +x[13]
|
|
|
|
x.usercoins = +x[17]
|
|
|
|
x.diamonds = +x[46]
|
2020-11-12 22:32:15 -03:00
|
|
|
x.icon = {
|
|
|
|
form: ['icon', 'ship', 'ball', 'ufo', 'wave', 'robot', 'spider'][+x[14]],
|
2021-01-23 00:28:26 -03:00
|
|
|
icon: +x[9] || 1,
|
2020-11-12 22:32:15 -03:00
|
|
|
col1: +x[10],
|
|
|
|
col2: +x[11],
|
2021-01-18 23:54:18 -03:00
|
|
|
glow: +x[15] > 1
|
2020-11-12 22:32:15 -03:00
|
|
|
}
|
2019-10-15 23:42:47 -03:00
|
|
|
keys.forEach(k => delete x[k])
|
2021-01-21 19:15:31 -03:00
|
|
|
app.userCache(req.id, x.accountID, x.playerID, x.username)
|
2019-10-15 23:42:47 -03:00
|
|
|
})
|
|
|
|
return res.send(scores)
|
|
|
|
})
|
|
|
|
}
|