Add plat level score and move classic endpoint
This commit is contained in:
4 files changed
+78
-19
No files matched your search
@@ -1,8 +1,17 @@
|
||||
import axios from 'axios'
|
||||
import { encodeGJP2, jsonResponse, splitGd } from '../../../lib/util'
|
||||
import {
|
||||
encodeGJP2,
|
||||
generateTimeLength,
|
||||
jsonResponse,
|
||||
splitGd
|
||||
} from '../../../lib/util'
|
||||
import { Context } from 'elysia'
|
||||
|
||||
export const handler = async (handler: Context, type: string) => {
|
||||
export const handler = async (
|
||||
handler: Context,
|
||||
type: string,
|
||||
classic: boolean
|
||||
) => {
|
||||
const id = handler.query.id
|
||||
|
||||
if (!process.env.ACCOUNT_ID || !process.env.ACCOUNT_PASSWORD)
|
||||
@@ -14,7 +23,9 @@ export const handler = async (handler: Context, type: string) => {
|
||||
})
|
||||
|
||||
const request = await axios.post(
|
||||
'https://www.boomlings.com/database/getGJLevelScores211.php',
|
||||
classic
|
||||
? 'https://www.boomlings.com/database/getGJLevelScores211.php'
|
||||
: 'https://www.boomlings.com/database/getGJLevelScoresPlat.php',
|
||||
new URLSearchParams({
|
||||
gameVersion: '22',
|
||||
binaryVersion: '45',
|
||||
@@ -39,6 +50,13 @@ export const handler = async (handler: Context, type: string) => {
|
||||
'Failed to authenticate (are you sure account ID and password are in .env?)',
|
||||
data: null
|
||||
})
|
||||
if (request.data.trim() == '')
|
||||
return jsonResponse({
|
||||
success: false,
|
||||
message:
|
||||
'Empty response (Check that you are using the right classic/platformer type)',
|
||||
data: null
|
||||
})
|
||||
|
||||
const responseText = request.data as string
|
||||
const responseSplit = responseText.split('|')
|
||||
@@ -48,10 +66,11 @@ export const handler = async (handler: Context, type: string) => {
|
||||
message: null,
|
||||
data: responseSplit.map(item => {
|
||||
const split = splitGd(item)
|
||||
return {
|
||||
split,
|
||||
const entry: Record<string, any> = {
|
||||
rank: +split['6'],
|
||||
username: split['1'],
|
||||
time: classic ? null : +split['3'],
|
||||
timeFormatted: classic ? null : generateTimeLength(+split['3']),
|
||||
coins: +split['13'],
|
||||
playerId: +split['2'],
|
||||
accountId: +split['16'],
|
||||
@@ -67,6 +86,11 @@ export const handler = async (handler: Context, type: string) => {
|
||||
glow: +split['15'] > 1
|
||||
}
|
||||
}
|
||||
if (classic) {
|
||||
delete entry.time
|
||||
delete entry.timeFormatted
|
||||
}
|
||||
return entry
|
||||
})
|
||||
})
|
||||
}
|
||||
Reference in new issue
Block a user