move score page fetching to the backend
Some checks failed
Deploy Backend / deploy (push) Successful in 2m26s
Deploy Website / deploy (push) Failing after 1m52s

This commit is contained in:
Lee
2024-10-17 15:30:14 +01:00
parent 118dc9d9f1
commit b3c124631a
78 changed files with 1150 additions and 494 deletions

View File

@ -0,0 +1 @@
export type Difficulty = "Easy" | "Normal" | "Hard" | "Expert" | "Expert+" | "Unknown";

View File

@ -0,0 +1,62 @@
import Score from "../score";
import { Modifier } from "../modifier";
import ScoreSaberScoreToken from "../../types/token/scoresaber/score-saber-score-token";
import ScoreSaberLeaderboardPlayerInfoToken from "../../types/token/scoresaber/score-saber-leaderboard-player-info-token";
export default interface ScoreSaberScore extends Score {
/**
* The score's id.
*/
readonly id: string;
/**
* The amount of pp for the score.
* @private
*/
readonly pp: number;
/**
* The weight of the score, or undefined if not ranked.s
* @private
*/
readonly weight?: number;
/**
* The player who set the score
*/
readonly playerInfo: ScoreSaberLeaderboardPlayerInfoToken;
}
/**
* Gets a {@link ScoreSaberScore} from a {@link ScoreSaberScoreToken}.
*
* @param token the token to convert
*/
export function getScoreSaberScoreFromToken(token: ScoreSaberScoreToken): ScoreSaberScore {
const modifiers: Modifier[] =
token.modifiers == undefined || token.modifiers === ""
? []
: token.modifiers.split(",").map(mod => {
mod = mod.toUpperCase();
const modifier = Modifier[mod as keyof typeof Modifier];
if (modifier === undefined) {
throw new Error(`Unknown modifier: ${mod}`);
}
return modifier;
});
return {
leaderboard: "scoresaber",
score: token.baseScore,
rank: token.rank,
modifiers: modifiers,
misses: token.missedNotes,
badCuts: token.badCuts,
fullCombo: token.fullCombo,
timestamp: new Date(token.timeSet),
id: token.id,
pp: token.pp,
weight: token.weight,
playerInfo: token.leaderboardPlayerInfo,
};
}

View File

@ -0,0 +1,20 @@
/**
* The score modifiers.
*/
export enum Modifier {
DA = "Disappearing Arrows",
FS = "Faster Song",
SF = "Super Fast Song",
SS = "Slower Song",
GN = "Ghost Notes",
NA = "No Arrows",
NO = "No Obstacles",
SA = "Strict Angles",
SC = "Small Notes",
PM = "Pro Mode",
CS = "Fail on Saber Clash",
IF = "One Life",
BE = "Battery Energy",
NF = "No Fail",
NB = "No Bombs",
}

View File

@ -0,0 +1,6 @@
export default interface PlayerLeaderboardScore<S> {
/**
* The score that was set.
*/
readonly score: S;
}

View File

@ -0,0 +1,18 @@
import { BeatSaverMap } from "../model/beatsaver/beatsaver-map";
export interface PlayerScore<S, L> {
/**
* The score.
*/
readonly score: S;
/**
* The leaderboard the score was set on.
*/
readonly leaderboard: L;
/**
* The BeatSaver of the song.
*/
readonly beatSaver?: BeatSaverMap;
}

View File

@ -0,0 +1,4 @@
export enum ScoreSort {
top = "top",
recent = "recent",
}

View File

@ -0,0 +1,51 @@
import { Modifier } from "./modifier";
import { Leaderboards } from "../leaderboard";
export default interface Score {
/**
* The leaderboard the score is from.
*/
readonly leaderboard: Leaderboards;
/**
* The base score for the score.
* @private
*/
readonly score: number;
/**
* The rank for the score.
* @private
*/
readonly rank: number;
/**
* The modifiers used on the score.
* @private
*/
readonly modifiers: Modifier[];
/**
* The amount missed notes.
* @private
*/
readonly misses: number;
/**
* The amount of bad cuts.
* @private
*/
readonly badCuts: number;
/**
* Whether every note was hit.
* @private
*/
readonly fullCombo: boolean;
/**
* The time the score was set.
* @private
*/
readonly timestamp: Date;
}