This commit is contained in:
parent
2fedf0e6ff
commit
9e43a72ac9
@ -63,16 +63,20 @@ function lerp(v0: number, v1: number, t: number) {
|
|||||||
return v0 + t * (v1 - v0);
|
return v0 + t * (v1 - v0);
|
||||||
}
|
}
|
||||||
|
|
||||||
function calculatePPModifier(c1: Array<any>, c2: Array<any>, acc: number) {
|
function calculatePPModifier(c1, c2, acc) {
|
||||||
const distance = (c2[0] - acc) / (c2[0] - c1[0]);
|
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<any>) {
|
function findPPModifier(acc, curve) {
|
||||||
acc = clamp(acc, 0, 100) / 100;
|
acc = clamp(acc, 0, 100) / 100;
|
||||||
|
console.log("Clamped Accuracy:", acc);
|
||||||
|
|
||||||
let prev = curve[1];
|
let prev = curve[1];
|
||||||
for (const item of curve) {
|
for (const item of curve) {
|
||||||
|
console.log("Curve Point:", item[0], item[1]);
|
||||||
if (item[0] <= acc) {
|
if (item[0] <= acc) {
|
||||||
return calculatePPModifier(item, prev, acc);
|
return calculatePPModifier(item, prev, acc);
|
||||||
}
|
}
|
||||||
@ -80,12 +84,19 @@ function findPPModifier(acc: number, curve: Array<any>) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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 ppValue = stars * starMultiplier;
|
||||||
const modifier = findPPModifier(acc * 100, ppCurve);
|
const modifier = findPPModifier(acc * 100, ppCurve);
|
||||||
|
console.log("Modifier:", modifier);
|
||||||
|
|
||||||
if (!modifier) return undefined;
|
if (!modifier) return undefined;
|
||||||
|
|
||||||
const finalPP = modifier * ppValue;
|
const finalPP = modifier * ppValue;
|
||||||
|
console.log("Final PP:", finalPP);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
pp: Number.isNaN(finalPP) ? undefined : finalPP,
|
pp: Number.isNaN(finalPP) ? undefined : finalPP,
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user