diff --git a/src/utils/scoresaber/scores.ts b/src/utils/scoresaber/scores.ts index 07e1a84..8440ba4 100644 --- a/src/utils/scoresaber/scores.ts +++ b/src/utils/scoresaber/scores.ts @@ -63,16 +63,20 @@ function lerp(v0: number, v1: number, t: number) { return v0 + t * (v1 - v0); } -function calculatePPModifier(c1: Array, c2: Array, acc: number) { +function calculatePPModifier(c1, c2, acc) { const distance = (c2[0] - acc) / (c2[0] - c1[0]); - return lerp(c2[1], c1[1], distance); + const interpolated = lerp(c2[1], c1[1], distance); + console.log(`Acc: ${acc}, c1: ${c1}, c2: ${c2}, Distance: ${distance}, Interpolated: ${interpolated}`); + return interpolated; } -function findPPModifier(acc: number, curve: Array) { +function findPPModifier(acc, curve) { acc = clamp(acc, 0, 100) / 100; + console.log("Clamped Accuracy:", acc); let prev = curve[1]; for (const item of curve) { + console.log("Curve Point:", item[0], item[1]); if (item[0] <= acc) { return calculatePPModifier(item, prev, acc); } @@ -80,12 +84,19 @@ function findPPModifier(acc: number, curve: Array) { } } -export function getScoreSaberPP(acc: number, stars: number) { +export function getScoreSaberPP(acc, stars) { + console.log("Input Stars:", stars); + console.log("Input Accuracy:", acc); + const ppValue = stars * starMultiplier; const modifier = findPPModifier(acc * 100, ppCurve); + console.log("Modifier:", modifier); + if (!modifier) return undefined; - + const finalPP = modifier * ppValue; + console.log("Final PP:", finalPP); + return { pp: Number.isNaN(finalPP) ? undefined : finalPP, };