Cleaned up pp multiplier and add No Obstacles

This commit is contained in:
Lee 2022-12-11 10:03:39 +00:00
parent 2e06ac16ac
commit 158f22b832
No known key found for this signature in database
GPG Key ID: 6EA25896ECCB3121
5 changed files with 25 additions and 8 deletions

@ -9,6 +9,6 @@ export function getBeatLeaderPP(acc, stars) {
if (stars === undefined || acc === undefined) {
return undefined;
}
const pp = curve(acc / 100, stars - 0.5) * (stars + 0.5) * 42;
const pp = curve(acc, stars - 0.5) * (stars + 0.5) * 42;
return Number.isNaN(pp) ? undefined : pp;
}

@ -25,7 +25,7 @@ export async function isValidSteamId(steamId) {
const before = Date.now();
let valid = false;
for (const url of TO_CHECK) {
const isValid = await Utils.checkLeaderboard(url, steamId);
const isValid = await Utils.isLeaderboardValid(url, steamId);
if (isValid) {
valid = true;
break;

@ -136,10 +136,10 @@ const handlers: any = {
if (finalScore == 0) {
finalScore = state.currentScore;
}
const percent = relativeScore * 100;
const percent = relativeScore;
state.setCurrentScore(finalScore);
state.setPercent(percent);
state.setPercent(percent * 100);
state.setCombo(data.status.performance.combo);
state.setPp(percent);
},

@ -105,7 +105,6 @@ export const useSongDataStore = create<SongDataState>()((set) => ({
const mapLeaderboardData = await Utils.getWebsiteApi(
leaderboardType
).getMapLeaderboardData(mapHash, mapDiff, characteristic);
console.log(mapLeaderboardData);
const mapData = await axios.get(
`${env("SITE_URL")}/api/beatsaver/map?hash=${mapHash}`
@ -118,7 +117,10 @@ export const useSongDataStore = create<SongDataState>()((set) => ({
set({
isLoading: false,
hasError: hasError,
mapLeaderboardData: mapLeaderboardData,
mapLeaderboardData: {
stars: mapLeaderboardData.stars,
modifiers: mapLeaderboardData.modifiers,
},
bsr: bsr,
mapArt: mapArt,
songDifficulty: mapDiff,

@ -18,7 +18,7 @@ export default class Utils {
window.open(url, "_blank");
}
static async checkLeaderboard(url, steamId) {
static async isLeaderboardValid(url, steamId) {
const data = await fetch(url.replace("%s", steamId), {
headers: {
"X-Requested-With": "BeatSaber Overlay",
@ -50,6 +50,7 @@ export default class Utils {
useSongDataStore.getState().mapLeaderboardData.modifiers;
let bonus = 0;
// No Fail
if (
songMods.noFail == true &&
modifierMulipliers.nf < 0 &&
@ -58,8 +59,12 @@ export default class Utils {
bonus -= modifierMulipliers.nf;
}
// Speed Modifiers
if (songMods.songSpeed != "Normal") {
if (songMods.songSpeed == "FasterSong" && modifierMulipliers.fs > 0) {
if (songMods.songSpeed == "SuperSlow" && modifierMulipliers.ss > 0) {
bonus -= modifierMulipliers.ss;
}
if (songMods.songSpeed == "Faster" && modifierMulipliers.fs > 0) {
bonus += modifierMulipliers.fs;
}
if (songMods.songSpeed == "SuperFast" && modifierMulipliers.sf > 0) {
@ -67,21 +72,31 @@ export default class Utils {
}
}
// Disappearing Arrows
if (songMods.disappearingArrows == true && modifierMulipliers.da > 0) {
bonus += modifierMulipliers.da;
}
// Ghost Notes
if (songMods.ghostNotes == true && modifierMulipliers.gn > 0) {
toAdd += modifierMulipliers.gn;
}
// No Arrows
if (songMods.noArrows == true && modifierMulipliers.na < 0) {
bonus -= modifierMulipliers.na;
}
// No Bombs
if (songMods.noBombs == true && modifierMulipliers.nb < 0) {
bonus -= modifierMulipliers.nb;
}
// No Obstacles
if (songMods.obstacles == false && modifierMulipliers.no < 0) {
bonus -= modifierMulipliers.no;
}
return bonus;
}