Cleaned up pp multiplier and add No Obstacles
This commit is contained in:
parent
2e06ac16ac
commit
158f22b832
@ -9,6 +9,6 @@ export function getBeatLeaderPP(acc, stars) {
|
|||||||
if (stars === undefined || acc === undefined) {
|
if (stars === undefined || acc === undefined) {
|
||||||
return 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;
|
return Number.isNaN(pp) ? undefined : pp;
|
||||||
}
|
}
|
||||||
|
@ -25,7 +25,7 @@ export async function isValidSteamId(steamId) {
|
|||||||
const before = Date.now();
|
const before = Date.now();
|
||||||
let valid = false;
|
let valid = false;
|
||||||
for (const url of TO_CHECK) {
|
for (const url of TO_CHECK) {
|
||||||
const isValid = await Utils.checkLeaderboard(url, steamId);
|
const isValid = await Utils.isLeaderboardValid(url, steamId);
|
||||||
if (isValid) {
|
if (isValid) {
|
||||||
valid = true;
|
valid = true;
|
||||||
break;
|
break;
|
||||||
|
@ -136,10 +136,10 @@ const handlers: any = {
|
|||||||
if (finalScore == 0) {
|
if (finalScore == 0) {
|
||||||
finalScore = state.currentScore;
|
finalScore = state.currentScore;
|
||||||
}
|
}
|
||||||
const percent = relativeScore * 100;
|
const percent = relativeScore;
|
||||||
|
|
||||||
state.setCurrentScore(finalScore);
|
state.setCurrentScore(finalScore);
|
||||||
state.setPercent(percent);
|
state.setPercent(percent * 100);
|
||||||
state.setCombo(data.status.performance.combo);
|
state.setCombo(data.status.performance.combo);
|
||||||
state.setPp(percent);
|
state.setPp(percent);
|
||||||
},
|
},
|
||||||
|
@ -105,7 +105,6 @@ export const useSongDataStore = create<SongDataState>()((set) => ({
|
|||||||
const mapLeaderboardData = await Utils.getWebsiteApi(
|
const mapLeaderboardData = await Utils.getWebsiteApi(
|
||||||
leaderboardType
|
leaderboardType
|
||||||
).getMapLeaderboardData(mapHash, mapDiff, characteristic);
|
).getMapLeaderboardData(mapHash, mapDiff, characteristic);
|
||||||
console.log(mapLeaderboardData);
|
|
||||||
|
|
||||||
const mapData = await axios.get(
|
const mapData = await axios.get(
|
||||||
`${env("SITE_URL")}/api/beatsaver/map?hash=${mapHash}`
|
`${env("SITE_URL")}/api/beatsaver/map?hash=${mapHash}`
|
||||||
@ -118,7 +117,10 @@ export const useSongDataStore = create<SongDataState>()((set) => ({
|
|||||||
set({
|
set({
|
||||||
isLoading: false,
|
isLoading: false,
|
||||||
hasError: hasError,
|
hasError: hasError,
|
||||||
mapLeaderboardData: mapLeaderboardData,
|
mapLeaderboardData: {
|
||||||
|
stars: mapLeaderboardData.stars,
|
||||||
|
modifiers: mapLeaderboardData.modifiers,
|
||||||
|
},
|
||||||
bsr: bsr,
|
bsr: bsr,
|
||||||
mapArt: mapArt,
|
mapArt: mapArt,
|
||||||
songDifficulty: mapDiff,
|
songDifficulty: mapDiff,
|
||||||
|
@ -18,7 +18,7 @@ export default class Utils {
|
|||||||
window.open(url, "_blank");
|
window.open(url, "_blank");
|
||||||
}
|
}
|
||||||
|
|
||||||
static async checkLeaderboard(url, steamId) {
|
static async isLeaderboardValid(url, steamId) {
|
||||||
const data = await fetch(url.replace("%s", steamId), {
|
const data = await fetch(url.replace("%s", steamId), {
|
||||||
headers: {
|
headers: {
|
||||||
"X-Requested-With": "BeatSaber Overlay",
|
"X-Requested-With": "BeatSaber Overlay",
|
||||||
@ -50,6 +50,7 @@ export default class Utils {
|
|||||||
useSongDataStore.getState().mapLeaderboardData.modifiers;
|
useSongDataStore.getState().mapLeaderboardData.modifiers;
|
||||||
let bonus = 0;
|
let bonus = 0;
|
||||||
|
|
||||||
|
// No Fail
|
||||||
if (
|
if (
|
||||||
songMods.noFail == true &&
|
songMods.noFail == true &&
|
||||||
modifierMulipliers.nf < 0 &&
|
modifierMulipliers.nf < 0 &&
|
||||||
@ -58,8 +59,12 @@ export default class Utils {
|
|||||||
bonus -= modifierMulipliers.nf;
|
bonus -= modifierMulipliers.nf;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Speed Modifiers
|
||||||
if (songMods.songSpeed != "Normal") {
|
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;
|
bonus += modifierMulipliers.fs;
|
||||||
}
|
}
|
||||||
if (songMods.songSpeed == "SuperFast" && modifierMulipliers.sf > 0) {
|
if (songMods.songSpeed == "SuperFast" && modifierMulipliers.sf > 0) {
|
||||||
@ -67,21 +72,31 @@ export default class Utils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Disappearing Arrows
|
||||||
if (songMods.disappearingArrows == true && modifierMulipliers.da > 0) {
|
if (songMods.disappearingArrows == true && modifierMulipliers.da > 0) {
|
||||||
bonus += modifierMulipliers.da;
|
bonus += modifierMulipliers.da;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Ghost Notes
|
||||||
if (songMods.ghostNotes == true && modifierMulipliers.gn > 0) {
|
if (songMods.ghostNotes == true && modifierMulipliers.gn > 0) {
|
||||||
toAdd += modifierMulipliers.gn;
|
toAdd += modifierMulipliers.gn;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// No Arrows
|
||||||
if (songMods.noArrows == true && modifierMulipliers.na < 0) {
|
if (songMods.noArrows == true && modifierMulipliers.na < 0) {
|
||||||
bonus -= modifierMulipliers.na;
|
bonus -= modifierMulipliers.na;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// No Bombs
|
||||||
if (songMods.noBombs == true && modifierMulipliers.nb < 0) {
|
if (songMods.noBombs == true && modifierMulipliers.nb < 0) {
|
||||||
bonus -= modifierMulipliers.nb;
|
bonus -= modifierMulipliers.nb;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// No Obstacles
|
||||||
|
if (songMods.obstacles == false && modifierMulipliers.no < 0) {
|
||||||
|
bonus -= modifierMulipliers.no;
|
||||||
|
}
|
||||||
|
|
||||||
return bonus;
|
return bonus;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user