Add plat level score and move classic endpoint
This commit is contained in:
4 files changed
+71
-12
No files matched your search
@@ -11,14 +11,14 @@ This is very early in development and will not be finished for a long time likel
|
|||||||
- [x] Get gauntlets (not names yet)
|
- [x] Get gauntlets (not names yet)
|
||||||
- [x] Get map packs
|
- [x] Get map packs
|
||||||
- [x] Get leaderboards
|
- [x] Get leaderboards
|
||||||
- [x] Get level scores
|
- [x] Get classic level scores
|
||||||
|
- [x] Get plat level scores
|
||||||
- [ ] Get Levels List
|
- [ ] Get Levels List
|
||||||
- [ ] Get save data
|
- [ ] Get save data
|
||||||
- [ ] Get level lists (same as map packs?)
|
- [ ] Get level lists (same as map packs?)
|
||||||
- [ ] Get top artists (not sure what this is)
|
- [ ] Get top artists (not sure what this is)
|
||||||
- [ ] Get user (profile?)
|
- [ ] Get user (profile?)
|
||||||
- [ ] Get user info
|
- [ ] Get user info
|
||||||
- [ ] Get plat level scores
|
|
||||||
- [ ] Get messages (account?)
|
- [ ] Get messages (account?)
|
||||||
- [ ] Get comments
|
- [ ] Get comments
|
||||||
- [ ] Get comment history
|
- [ ] Get comment history
|
||||||
|
|||||||
+30
-5
@@ -5,11 +5,10 @@ import dotenv from 'dotenv'
|
|||||||
import { handler as gauntletsGetHandler } from './routes/gauntlets/get'
|
import { handler as gauntletsGetHandler } from './routes/gauntlets/get'
|
||||||
|
|
||||||
import { handler as leaderboardsGetHandler } from './routes/leaderboards/get'
|
import { handler as leaderboardsGetHandler } from './routes/leaderboards/get'
|
||||||
|
import { handler as leaderboardsLevelGetHandler } from './routes/leaderboards/level/get'
|
||||||
|
|
||||||
import { handler as mapPacksGetHandler } from './routes/map-packs/get'
|
import { handler as mapPacksGetHandler } from './routes/map-packs/get'
|
||||||
|
|
||||||
import { handler as scoresLevelGetHandler } from './routes/scores/level/get'
|
|
||||||
|
|
||||||
dotenv.config()
|
dotenv.config()
|
||||||
|
|
||||||
const app = new Elysia()
|
const app = new Elysia()
|
||||||
@@ -20,16 +19,42 @@ app.get('/gauntlets', gauntletsGetHandler)
|
|||||||
app.get('/map-packs', mapPacksGetHandler)
|
app.get('/map-packs', mapPacksGetHandler)
|
||||||
app.get('/leaderboards/top', () => leaderboardsGetHandler('top'))
|
app.get('/leaderboards/top', () => leaderboardsGetHandler('top'))
|
||||||
app.get('/leaderboards/creators', () => leaderboardsGetHandler('creators'))
|
app.get('/leaderboards/creators', () => leaderboardsGetHandler('creators'))
|
||||||
app.get('/scores/level/top', handler => scoresLevelGetHandler(handler, '1'), {
|
app.get(
|
||||||
|
'/leaderboards/level/classic/top',
|
||||||
|
handler => leaderboardsLevelGetHandler(handler, '1', true),
|
||||||
|
{
|
||||||
query: t.Object({
|
query: t.Object({
|
||||||
id: t.String()
|
id: t.String()
|
||||||
})
|
})
|
||||||
})
|
}
|
||||||
app.get('/scores/level/week', handler => scoresLevelGetHandler(handler, '2'), {
|
)
|
||||||
|
app.get(
|
||||||
|
'/leaderboards/level/platformer/top',
|
||||||
|
handler => leaderboardsLevelGetHandler(handler, '2', false),
|
||||||
|
{
|
||||||
query: t.Object({
|
query: t.Object({
|
||||||
id: t.String()
|
id: t.String()
|
||||||
})
|
})
|
||||||
|
}
|
||||||
|
)
|
||||||
|
app.get(
|
||||||
|
'/leaderboards/level/classic/week',
|
||||||
|
handler => leaderboardsLevelGetHandler(handler, '2', true),
|
||||||
|
{
|
||||||
|
query: t.Object({
|
||||||
|
id: t.String()
|
||||||
})
|
})
|
||||||
|
}
|
||||||
|
)
|
||||||
|
app.get(
|
||||||
|
'/leaderboards/level/platformer/week',
|
||||||
|
handler => leaderboardsLevelGetHandler(handler, '1', false),
|
||||||
|
{
|
||||||
|
query: t.Object({
|
||||||
|
id: t.String()
|
||||||
|
})
|
||||||
|
}
|
||||||
|
)
|
||||||
app.all('*', () =>
|
app.all('*', () =>
|
||||||
jsonResponse(
|
jsonResponse(
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -21,3 +21,13 @@ export const encodeGJP2 = async (password = '', salt = 'mI29fmAnxgTs') => {
|
|||||||
.map(b => b.toString(16).padStart(2, '0'))
|
.map(b => b.toString(16).padStart(2, '0'))
|
||||||
.join('')
|
.join('')
|
||||||
}
|
}
|
||||||
|
export const generateTimeLength = (ms: number): string => {
|
||||||
|
const minutes = Math.floor(ms / 60000)
|
||||||
|
const seconds = Math.floor((ms % 60000) / 1000)
|
||||||
|
const milliseconds = ms % 1000
|
||||||
|
|
||||||
|
const secStr = seconds.toString().padStart(2, '0')
|
||||||
|
const msStr = milliseconds.toString().padStart(3, '0')
|
||||||
|
|
||||||
|
return `${minutes}:${secStr}.${msStr}`
|
||||||
|
}
|
||||||
@@ -1,8 +1,17 @@
|
|||||||
import axios from 'axios'
|
import axios from 'axios'
|
||||||
import { encodeGJP2, jsonResponse, splitGd } from '../../../lib/util'
|
import {
|
||||||
|
encodeGJP2,
|
||||||
|
generateTimeLength,
|
||||||
|
jsonResponse,
|
||||||
|
splitGd
|
||||||
|
} from '../../../lib/util'
|
||||||
import { Context } from 'elysia'
|
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
|
const id = handler.query.id
|
||||||
|
|
||||||
if (!process.env.ACCOUNT_ID || !process.env.ACCOUNT_PASSWORD)
|
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(
|
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({
|
new URLSearchParams({
|
||||||
gameVersion: '22',
|
gameVersion: '22',
|
||||||
binaryVersion: '45',
|
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?)',
|
'Failed to authenticate (are you sure account ID and password are in .env?)',
|
||||||
data: null
|
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 responseText = request.data as string
|
||||||
const responseSplit = responseText.split('|')
|
const responseSplit = responseText.split('|')
|
||||||
@@ -48,10 +66,11 @@ export const handler = async (handler: Context, type: string) => {
|
|||||||
message: null,
|
message: null,
|
||||||
data: responseSplit.map(item => {
|
data: responseSplit.map(item => {
|
||||||
const split = splitGd(item)
|
const split = splitGd(item)
|
||||||
return {
|
const entry: Record<string, any> = {
|
||||||
split,
|
|
||||||
rank: +split['6'],
|
rank: +split['6'],
|
||||||
username: split['1'],
|
username: split['1'],
|
||||||
|
time: classic ? null : +split['3'],
|
||||||
|
timeFormatted: classic ? null : generateTimeLength(+split['3']),
|
||||||
coins: +split['13'],
|
coins: +split['13'],
|
||||||
playerId: +split['2'],
|
playerId: +split['2'],
|
||||||
accountId: +split['16'],
|
accountId: +split['16'],
|
||||||
@@ -67,6 +86,11 @@ export const handler = async (handler: Context, type: string) => {
|
|||||||
glow: +split['15'] > 1
|
glow: +split['15'] > 1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (classic) {
|
||||||
|
delete entry.time
|
||||||
|
delete entry.timeFormatted
|
||||||
|
}
|
||||||
|
return entry
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user