implement scoresaber score tracking (for previous scores)
This commit is contained in:
@ -1,76 +0,0 @@
|
||||
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";
|
||||
import ScoreSaberLeaderboardToken from "../../types/token/scoresaber/score-saber-leaderboard-token";
|
||||
import ScoreSaberLeaderboard from "../../leaderboard/impl/scoresaber-leaderboard";
|
||||
|
||||
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 max combo of the score.
|
||||
*/
|
||||
readonly maxCombo: number;
|
||||
|
||||
/**
|
||||
* The player who set the score
|
||||
*/
|
||||
readonly playerInfo: ScoreSaberLeaderboardPlayerInfoToken;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a {@link ScoreSaberScore} from a {@link ScoreSaberScoreToken}.
|
||||
*
|
||||
* @param token the token to convert
|
||||
* @param leaderboard the leaderboard the score was set on
|
||||
*/
|
||||
export function getScoreSaberScoreFromToken(
|
||||
token: ScoreSaberScoreToken,
|
||||
leaderboard?: ScoreSaberLeaderboardToken | ScoreSaberLeaderboard
|
||||
): 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,
|
||||
accuracy: leaderboard ? (token.baseScore / leaderboard.maxScore) * 100 : Infinity,
|
||||
rank: token.rank,
|
||||
modifiers: modifiers,
|
||||
misses: token.missedNotes + token.badCuts,
|
||||
missedNotes: token.missedNotes,
|
||||
badCuts: token.badCuts,
|
||||
fullCombo: token.fullCombo,
|
||||
timestamp: new Date(token.timeSet),
|
||||
id: token.id,
|
||||
pp: token.pp,
|
||||
weight: token.weight,
|
||||
maxCombo: token.maxCombo,
|
||||
playerInfo: token.leaderboardPlayerInfo,
|
||||
};
|
||||
}
|
@ -1,67 +0,0 @@
|
||||
import { Modifier } from "./modifier";
|
||||
import { Leaderboards } from "../leaderboard";
|
||||
import { AdditionalScoreData } from "../model/additional-score-data/additional-score-data";
|
||||
|
||||
export default interface Score {
|
||||
/**
|
||||
* The leaderboard the score is from.
|
||||
*/
|
||||
readonly leaderboard: Leaderboards;
|
||||
|
||||
/**
|
||||
* The base score for the score.
|
||||
* @private
|
||||
*/
|
||||
readonly score: number;
|
||||
|
||||
/**
|
||||
* The accuracy of the score.
|
||||
*/
|
||||
readonly accuracy: number;
|
||||
|
||||
/**
|
||||
* The rank for the score.
|
||||
* @private
|
||||
*/
|
||||
readonly rank: number;
|
||||
|
||||
/**
|
||||
* The modifiers used on the score.
|
||||
* @private
|
||||
*/
|
||||
readonly modifiers: Modifier[];
|
||||
|
||||
/**
|
||||
* The amount total amount of misses.
|
||||
* @private
|
||||
*/
|
||||
readonly misses: number;
|
||||
|
||||
/**
|
||||
* The amount of missed notes.
|
||||
*/
|
||||
readonly missedNotes: number;
|
||||
|
||||
/**
|
||||
* The amount of bad cuts.
|
||||
* @private
|
||||
*/
|
||||
readonly badCuts: number;
|
||||
|
||||
/**
|
||||
* Whether every note was hit.
|
||||
* @private
|
||||
*/
|
||||
readonly fullCombo: boolean;
|
||||
|
||||
/**
|
||||
* The additional data for the score.
|
||||
*/
|
||||
additionalData?: AdditionalScoreData;
|
||||
|
||||
/**
|
||||
* The time the score was set.
|
||||
* @private
|
||||
*/
|
||||
readonly timestamp: Date;
|
||||
}
|
Reference in New Issue
Block a user