mirror of https://github.com/hykilpikonna/AquaDX
[+] Actually query for data
parent
4b71cd9940
commit
6690c665dd
|
@ -0,0 +1,31 @@
|
|||
import {aqua_host} from "./config";
|
||||
|
||||
|
||||
const multTable = [
|
||||
[100.5, 22.4, "SSSp"],
|
||||
[100, 21.6, "SSS"],
|
||||
[99.5, 21.1, "SSp"],
|
||||
[99, 20.8, "SS"],
|
||||
[98, 20.3, "Sp"],
|
||||
[97, 20, "S"],
|
||||
[94, 16.8, "AAA"],
|
||||
[90, 15.2, "AA"],
|
||||
[80, 13.6, "A"]
|
||||
]
|
||||
|
||||
|
||||
export function getMult(achievement: number) {
|
||||
achievement /= 10000
|
||||
for (let i = 0; i < multTable.length; i++) {
|
||||
if (achievement >= (multTable[i][0] as number)) return multTable[i]
|
||||
}
|
||||
return [0, 0, 0]
|
||||
}
|
||||
|
||||
|
||||
export async function getMaimai(endpoint: string, params: any) {
|
||||
return await fetch(`${aqua_host}/Maimai2Servlet/${endpoint}`, {
|
||||
method: "POST",
|
||||
body: JSON.stringify(params)
|
||||
}).then(res => res.json())
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
export interface Rating {
|
||||
musicId: number
|
||||
level: number
|
||||
achievement: number
|
||||
}
|
||||
|
||||
export interface ParsedRating extends Rating {
|
||||
music: {
|
||||
name: string,
|
||||
composer: string,
|
||||
bpm: number,
|
||||
ver: number,
|
||||
note: {
|
||||
lv: number
|
||||
designer: string
|
||||
lv_id: number
|
||||
notes: number
|
||||
}
|
||||
},
|
||||
calc: number,
|
||||
rank: string
|
||||
}
|
|
@ -1,77 +1,33 @@
|
|||
<script lang="ts">
|
||||
import {data_host} from "../libs/config";
|
||||
import {getMaimai, getMult} from "../libs/maimai";
|
||||
import type {ParsedRating, Rating} from "../libs/maimaiTypes";
|
||||
|
||||
const data = {
|
||||
username: "AZA☆",
|
||||
rating: "701:2:19011:1006030,11528:2:23500:1006452,836:2:19910:995577,572:2:18021:997469,757:2:19507:993536,839:2:19911:1005278,606:2:18019:982216,11517:2:23014:993709,625:2:18503:993160,11408:2:22501:1005514,771:2:19511:993191,734:2:19500:989036,11479:2:23011:988050,11594:2:23503:1002051,682:2:19004:1000732,797:2:19900:982911,772:2:19511:987791,10204:2:23506:1001532,841:2:19912:992283,11565:3:23500:983334,11489:2:23000:997830,709:2:19013:986791,11469:2:23012:985848,11514:2:23014:1003829,720:2:19006:1001675,11565:2:23500:1001386,11003:3:20000:984282,11168:3:21004:983648,11588:2:23504:1000833,11410:3:22501:1000243,63:3:10000:1000119,11587:2:23504:998203,11236:2:21508:997255,375:3:14000:981309,510:2:19505:1004313",
|
||||
ratingNew: "11642:2:24006:1003839,11580:3:24000:972621,11640:2:24006:985702,11633:2:24000:986507,11634:3:24000:985023,10411:2:24000:977957,11624:2:24000:966136,11578:2:24000:963522,11643:2:24006:962392,11629:3:24000:966908,11619:2:24005:939345,11640:3:24006:904054,11641:3:24006:903064,11642:3:24006:875413,11634:2:24000:922194"
|
||||
}
|
||||
|
||||
const multTable = [
|
||||
[100.5, 22.4, "SSSp"],
|
||||
[100, 21.6, "SSS"],
|
||||
[99.5, 21.1, "SSp"],
|
||||
[99, 20.8, "SS"],
|
||||
[98, 20.3, "Sp"],
|
||||
[97, 20, "S"],
|
||||
[94, 16.8, "AAA"],
|
||||
[90, 15.2, "AA"],
|
||||
[80, 13.6, "A"]
|
||||
]
|
||||
|
||||
function getMult(achievement: number) {
|
||||
achievement /= 10000
|
||||
for (let i = 0; i < multTable.length; i++) {
|
||||
if (achievement >= (multTable[i][0] as number)) {
|
||||
return multTable[i]
|
||||
}
|
||||
function parseRatings() {
|
||||
if (!data || !musicInfo) return
|
||||
parsedRatings = {
|
||||
old: parseRating(data.userRating.ratingList),
|
||||
new: parseRating(data.userRating.newRatingList)
|
||||
}
|
||||
return [0, 0, 0]
|
||||
}
|
||||
|
||||
// Parse rating
|
||||
function parseRatings(rating: string, musicInfo: any) {
|
||||
const arr = rating.split(',').map(x => x.split(':').map(x => parseInt(x)))
|
||||
function parseRating(arr: Rating[]) {
|
||||
return arr.map(x => {
|
||||
const music = musicInfo[x[0]]
|
||||
const music = musicInfo[x.musicId]
|
||||
|
||||
if (!music) {
|
||||
console.error(`Music not found: ${x[0]}`)
|
||||
console.error(`Music not found: ${x.musicId}`)
|
||||
return null
|
||||
}
|
||||
|
||||
music.note = music.notes[x[1]]
|
||||
const mult = getMult(x[3])
|
||||
return {
|
||||
music.note = music.notes[x.level]
|
||||
const mult = getMult(x.achievement)
|
||||
return {...x,
|
||||
music: music,
|
||||
musicId: x[0],
|
||||
difficulty: x[1],
|
||||
todo: x[2], // TODO: Figure out what this is
|
||||
achievement: x[3],
|
||||
calc: (mult[1] as number) * music.note.lv,
|
||||
rank: mult[2]
|
||||
}
|
||||
}).filter(x => x)
|
||||
}
|
||||
|
||||
interface ParsedRating {
|
||||
music: {
|
||||
name: string,
|
||||
composer: string,
|
||||
bpm: number,
|
||||
ver: number,
|
||||
note: {
|
||||
lv: number
|
||||
designer: string
|
||||
lv_id: number
|
||||
notes: number
|
||||
}
|
||||
},
|
||||
musicId: number,
|
||||
difficulty: number,
|
||||
achievement: number,
|
||||
calc: number,
|
||||
rank: string
|
||||
}).filter(x => x != null) as ParsedRating[]
|
||||
}
|
||||
|
||||
let parsedRatings: {
|
||||
|
@ -79,14 +35,24 @@
|
|||
new: ParsedRating[]
|
||||
} | null = null
|
||||
|
||||
// Get music information from data server
|
||||
fetch(`${data_host}/maimai/meta/00/all-music.json`).then(it => it.json()).then(musicInfo => {
|
||||
parsedRatings = {
|
||||
old: parseRatings(data.rating, musicInfo),
|
||||
new: parseRatings(data.ratingNew, musicInfo)
|
||||
let data: {
|
||||
userRating: {
|
||||
rating: number,
|
||||
ratingList: Rating[],
|
||||
newRatingList: Rating[]
|
||||
}
|
||||
} | null = null
|
||||
|
||||
console.log(parsedRatings)
|
||||
let musicInfo: any = null
|
||||
|
||||
getMaimai("GetUserRatingApi", {userId: 61702139}).then(it => {
|
||||
data = it
|
||||
parseRatings()
|
||||
})
|
||||
|
||||
fetch(`${data_host}/maimai/meta/00/all-music.json`).then(it => it.json()).then(it => {
|
||||
musicInfo = it
|
||||
parseRatings()
|
||||
})
|
||||
</script>
|
||||
|
||||
|
@ -96,7 +62,7 @@
|
|||
<h2>{section.title}</h2>
|
||||
<div class="rating-cards">
|
||||
{#each section.data as rating}
|
||||
<div class="level-{rating.difficulty}">
|
||||
<div class="level-{rating.level}">
|
||||
<img class="cover" src={`${data_host}/maimai/assetbundle/jacket_s/00${rating.musicId.toString().padStart(6, '0').substring(2)}.png`} alt="">
|
||||
|
||||
<div class="detail">
|
||||
|
|
Loading…
Reference in New Issue