changed show score pp to show both leaderboards
This commit is contained in:
parent
1c0b71dad7
commit
0ebc808413
@ -1,3 +1,4 @@
|
|||||||
|
import Image from "next/image";
|
||||||
import { getFormattedScorePercent } from "../helpers/map/mapHelpers";
|
import { getFormattedScorePercent } from "../helpers/map/mapHelpers";
|
||||||
import { useSettingsStore } from "../store/overlaySettingsStore";
|
import { useSettingsStore } from "../store/overlaySettingsStore";
|
||||||
import { useSongDataStore } from "../store/songDataStore";
|
import { useSongDataStore } from "../store/songDataStore";
|
||||||
@ -25,6 +26,9 @@ export default function ScoreStats() {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const scoreSaberPP = currentPP?.scoreSaber;
|
||||||
|
const beatLeaderPP = currentPP?.beatLeader;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={styles.scoreStats}>
|
<div className={styles.scoreStats}>
|
||||||
<p
|
<p
|
||||||
@ -43,8 +47,47 @@ export default function ScoreStats() {
|
|||||||
<p>
|
<p>
|
||||||
{getFormattedScorePercent(percentage)} {percentage.toFixed(2)}%
|
{getFormattedScorePercent(percentage)} {percentage.toFixed(2)}%
|
||||||
</p>
|
</p>
|
||||||
{currentPP !== undefined && showPp ? (
|
{scoreSaberPP !== undefined && showPp ? (
|
||||||
<p>{currentPP.toFixed(0)}pp</p>
|
<div
|
||||||
|
style={{
|
||||||
|
display: "flex",
|
||||||
|
flexDirection: "row",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Image
|
||||||
|
width={30}
|
||||||
|
height={30}
|
||||||
|
src="https://cdn.fascinated.cc/Hc1eD7QY.png"
|
||||||
|
></Image>
|
||||||
|
<p
|
||||||
|
style={{
|
||||||
|
marginLeft: "5px",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{scoreSaberPP.toFixed(0)}pp
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
) : null}
|
||||||
|
{beatLeaderPP !== undefined && showPp ? (
|
||||||
|
<div
|
||||||
|
style={{
|
||||||
|
display: "flex",
|
||||||
|
flexDirection: "row",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Image
|
||||||
|
width={30}
|
||||||
|
height={30}
|
||||||
|
src="https://cdn.fascinated.cc/Wo9JRAfD.png"
|
||||||
|
></Image>
|
||||||
|
<p
|
||||||
|
style={{
|
||||||
|
marginLeft: "8px",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{beatLeaderPP.toFixed(0)}pp
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
) : null}
|
) : null}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -2,7 +2,6 @@ import env from "@beam-australia/react-env";
|
|||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
import { create } from "zustand";
|
import { create } from "zustand";
|
||||||
import Utils from "../utils/utils";
|
import Utils from "../utils/utils";
|
||||||
import { useSettingsStore } from "./overlaySettingsStore";
|
|
||||||
|
|
||||||
interface SongDataState {
|
interface SongDataState {
|
||||||
isLoading: boolean;
|
isLoading: boolean;
|
||||||
@ -14,8 +13,14 @@ interface SongDataState {
|
|||||||
songDifficulty: string;
|
songDifficulty: string;
|
||||||
songModifiers: Object;
|
songModifiers: Object;
|
||||||
mapLeaderboardData: {
|
mapLeaderboardData: {
|
||||||
stars: Number;
|
scoresaber: {
|
||||||
modifiers: Object;
|
stars: Number | undefined;
|
||||||
|
modifiers: Object;
|
||||||
|
};
|
||||||
|
beatleader: {
|
||||||
|
stars: Number | undefined;
|
||||||
|
modifiers: Object;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
mapArt: string;
|
mapArt: string;
|
||||||
bsr: string;
|
bsr: string;
|
||||||
@ -26,7 +31,10 @@ interface SongDataState {
|
|||||||
currentScore: number;
|
currentScore: number;
|
||||||
percentage: number;
|
percentage: number;
|
||||||
combo: number;
|
combo: number;
|
||||||
currentPP: number | undefined;
|
currentPP: {
|
||||||
|
scoreSaber: number | undefined;
|
||||||
|
beatLeader: number | undefined;
|
||||||
|
};
|
||||||
saberA: {
|
saberA: {
|
||||||
cutDistanceScore: number;
|
cutDistanceScore: number;
|
||||||
averagePreSwing: number;
|
averagePreSwing: number;
|
||||||
@ -67,8 +75,14 @@ export const useSongDataStore = create<SongDataState>()((set) => ({
|
|||||||
songDifficulty: "",
|
songDifficulty: "",
|
||||||
songModifiers: {},
|
songModifiers: {},
|
||||||
mapLeaderboardData: {
|
mapLeaderboardData: {
|
||||||
stars: 0,
|
scoresaber: {
|
||||||
modifiers: {},
|
stars: 0,
|
||||||
|
modifiers: {},
|
||||||
|
},
|
||||||
|
beatleader: {
|
||||||
|
stars: 0,
|
||||||
|
modifiers: {},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
mapArt: "",
|
mapArt: "",
|
||||||
bsr: "",
|
bsr: "",
|
||||||
@ -79,7 +93,10 @@ export const useSongDataStore = create<SongDataState>()((set) => ({
|
|||||||
currentScore: 0,
|
currentScore: 0,
|
||||||
percentage: 100,
|
percentage: 100,
|
||||||
combo: 0,
|
combo: 0,
|
||||||
currentPP: undefined,
|
currentPP: {
|
||||||
|
beatLeader: undefined,
|
||||||
|
scoreSaber: undefined,
|
||||||
|
},
|
||||||
saberA: {
|
saberA: {
|
||||||
cutDistanceScore: 0.0,
|
cutDistanceScore: 0.0,
|
||||||
averagePreSwing: 0.0,
|
averagePreSwing: 0.0,
|
||||||
@ -100,26 +117,35 @@ export const useSongDataStore = create<SongDataState>()((set) => ({
|
|||||||
songLength: number
|
songLength: number
|
||||||
) => {
|
) => {
|
||||||
let hasError = false;
|
let hasError = false;
|
||||||
const leaderboardType = useSettingsStore.getState().leaderboardType;
|
//const leaderboardType = useSettingsStore.getState().leaderboardType;
|
||||||
|
const beatLeaderLeaderboardData = await Utils.getWebsiteApi(
|
||||||
const mapLeaderboardData = await Utils.getWebsiteApi(
|
"BeatLeader"
|
||||||
leaderboardType
|
|
||||||
).getMapLeaderboardData(mapHash, mapDiff, characteristic);
|
).getMapLeaderboardData(mapHash, mapDiff, characteristic);
|
||||||
|
|
||||||
const response = await axios.get(
|
const scoreSaberLeaderboardData = await Utils.getWebsiteApi(
|
||||||
|
"ScoreSaber"
|
||||||
|
).getMapLeaderboardData(mapHash, mapDiff, characteristic);
|
||||||
|
|
||||||
|
const mapDataresponse = await axios.get(
|
||||||
`${env("SITE_URL")}/api/beatsaver/map?hash=${mapHash}`
|
`${env("SITE_URL")}/api/beatsaver/map?hash=${mapHash}`
|
||||||
);
|
);
|
||||||
if (response.status !== 200) {
|
if (mapDataresponse.status !== 200) {
|
||||||
return set({ isLoading: false, hasError: hasError });
|
return set({ isLoading: false, hasError: hasError });
|
||||||
}
|
}
|
||||||
const { bsr, mapArt } = response.data.data;
|
const { bsr, mapArt } = mapDataresponse.data.data;
|
||||||
|
|
||||||
set({
|
set({
|
||||||
isLoading: false,
|
isLoading: false,
|
||||||
hasError: hasError,
|
hasError: hasError,
|
||||||
mapLeaderboardData: {
|
mapLeaderboardData: {
|
||||||
stars: mapLeaderboardData.stars,
|
beatleader: {
|
||||||
modifiers: mapLeaderboardData.modifiers,
|
stars: beatLeaderLeaderboardData.stars,
|
||||||
|
modifiers: beatLeaderLeaderboardData.modifiers,
|
||||||
|
},
|
||||||
|
scoresaber: {
|
||||||
|
stars: scoreSaberLeaderboardData.stars,
|
||||||
|
modifiers: scoreSaberLeaderboardData.modifiers,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
bsr: bsr,
|
bsr: bsr,
|
||||||
mapArt: mapArt,
|
mapArt: mapArt,
|
||||||
@ -159,14 +185,32 @@ export const useSongDataStore = create<SongDataState>()((set) => ({
|
|||||||
},
|
},
|
||||||
|
|
||||||
setPp: (percent: number) => {
|
setPp: (percent: number) => {
|
||||||
const leaderboardType = useSettingsStore.getState().leaderboardType;
|
const scoreSaberMapStarCount =
|
||||||
const mapStarCount = useSongDataStore.getState().mapLeaderboardData.stars;
|
useSongDataStore.getState().mapLeaderboardData.scoresaber.stars;
|
||||||
|
let scoreSaberPP = Utils.calculatePP(
|
||||||
|
scoreSaberMapStarCount,
|
||||||
|
percent,
|
||||||
|
"ScoreSaber"
|
||||||
|
);
|
||||||
|
|
||||||
let pp = Utils.calculatePP(mapStarCount, percent, leaderboardType);
|
const beatLeaderMapStarCount =
|
||||||
if (pp === undefined) {
|
useSongDataStore.getState().mapLeaderboardData.beatleader.stars;
|
||||||
return;
|
let beatLeaderPP = Utils.calculatePP(
|
||||||
}
|
beatLeaderMapStarCount,
|
||||||
set({ currentPP: pp });
|
percent,
|
||||||
|
"BeatLeader"
|
||||||
|
);
|
||||||
|
|
||||||
|
const lastSSPP = useSongDataStore.getState().currentPP?.scoreSaber;
|
||||||
|
const lastBLPP = useSongDataStore.getState().currentPP?.beatLeader;
|
||||||
|
|
||||||
|
// undefined is returned if the curve ate shit (BL one does that if the current % is too high).
|
||||||
|
set({
|
||||||
|
currentPP: {
|
||||||
|
beatLeader: beatLeaderPP == undefined ? lastBLPP : beatLeaderPP,
|
||||||
|
scoreSaber: scoreSaberPP == undefined ? lastSSPP : scoreSaberPP,
|
||||||
|
},
|
||||||
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
setInSong: (isInSong: boolean) => {
|
setInSong: (isInSong: boolean) => {
|
||||||
@ -186,8 +230,14 @@ export const useSongDataStore = create<SongDataState>()((set) => ({
|
|||||||
songDifficulty: "",
|
songDifficulty: "",
|
||||||
songModifiers: {},
|
songModifiers: {},
|
||||||
mapLeaderboardData: {
|
mapLeaderboardData: {
|
||||||
stars: 0,
|
scoresaber: {
|
||||||
modifiers: {},
|
stars: undefined,
|
||||||
|
modifiers: {},
|
||||||
|
},
|
||||||
|
beatleader: {
|
||||||
|
stars: undefined,
|
||||||
|
modifiers: {},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
mapArt: "",
|
mapArt: "",
|
||||||
bsr: "",
|
bsr: "",
|
||||||
|
Reference in New Issue
Block a user