fix qualified status for leaderboards
This commit is contained in:
parent
af8c87f5af
commit
5933074569
@ -3,6 +3,7 @@ import LeaderboardDifficulty from "../leaderboard-difficulty";
|
|||||||
import ScoreSaberLeaderboardToken from "../../types/token/scoresaber/score-saber-leaderboard-token";
|
import ScoreSaberLeaderboardToken from "../../types/token/scoresaber/score-saber-leaderboard-token";
|
||||||
import { getDifficultyFromScoreSaberDifficulty } from "../../utils/scoresaber-utils";
|
import { getDifficultyFromScoreSaberDifficulty } from "../../utils/scoresaber-utils";
|
||||||
import { parseDate } from "../../utils/time-utils";
|
import { parseDate } from "../../utils/time-utils";
|
||||||
|
import { LeaderboardStatus } from "../leaderboard-status";
|
||||||
|
|
||||||
export default interface ScoreSaberLeaderboard extends Leaderboard {
|
export default interface ScoreSaberLeaderboard extends Leaderboard {
|
||||||
/**
|
/**
|
||||||
@ -19,6 +20,16 @@ export default interface ScoreSaberLeaderboard extends Leaderboard {
|
|||||||
* The amount of plays today.
|
* The amount of plays today.
|
||||||
*/
|
*/
|
||||||
readonly dailyPlays: number;
|
readonly dailyPlays: number;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether this leaderboard is qualified to be ranked.
|
||||||
|
*/
|
||||||
|
readonly qualified: boolean;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The status of the map.
|
||||||
|
*/
|
||||||
|
readonly status: LeaderboardStatus;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -33,6 +44,14 @@ export function getScoreSaberLeaderboardFromToken(token: ScoreSaberLeaderboardTo
|
|||||||
gameMode: token.difficulty.gameMode,
|
gameMode: token.difficulty.gameMode,
|
||||||
difficultyRaw: token.difficulty.difficultyRaw,
|
difficultyRaw: token.difficulty.difficultyRaw,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let status: LeaderboardStatus = "Unranked";
|
||||||
|
if (token.qualified) {
|
||||||
|
status = "Qualified";
|
||||||
|
} else if (token.ranked) {
|
||||||
|
status = "Ranked";
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
id: token.id,
|
id: token.id,
|
||||||
songHash: token.songHash,
|
songHash: token.songHash,
|
||||||
@ -59,5 +78,7 @@ export function getScoreSaberLeaderboardFromToken(token: ScoreSaberLeaderboardTo
|
|||||||
stars: token.stars,
|
stars: token.stars,
|
||||||
plays: token.plays,
|
plays: token.plays,
|
||||||
dailyPlays: token.dailyPlays,
|
dailyPlays: token.dailyPlays,
|
||||||
|
qualified: token.qualified,
|
||||||
|
status: status,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
1
projects/common/src/leaderboard/leaderboard-status.ts
Normal file
1
projects/common/src/leaderboard/leaderboard-status.ts
Normal file
@ -0,0 +1 @@
|
|||||||
|
export type LeaderboardStatus = "Unranked" | "Ranked" | "Qualified";
|
@ -55,7 +55,7 @@ export function LeaderboardInfo({ leaderboard, beatSaverMap }: LeaderboardInfoPr
|
|||||||
{formatNumber(leaderboard.dailyPlays)} today)
|
{formatNumber(leaderboard.dailyPlays)} today)
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
Status: <span className="font-semibold">{leaderboard.stars > 0 ? "Ranked" : "Unranked"}</span>
|
Status: <span className="font-semibold">{leaderboard.status}</span>
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
Reference in New Issue
Block a user