This repository has been archived on 2023-11-06. You can view files and clone it, but cannot push or open issues or pull requests.
beatsaber-overlay/src/curve/BeatLeaderCurve.js

19 lines
486 B
JavaScript
Raw Normal View History

export default class BeatLeaderCurve {
static curve(acc, stars) {
var l = 1 - (0.03 * (stars - 3.0)) / 11.0;
var a = 0.96 * l;
var f = 1.2 - (0.6 * stars) / 14.0;
return Math.pow(Math.log10(l / (l - acc)) / Math.log10(l / (l - a)), f);
}
static getPP(acc, stars) {
if (stars === undefined || acc === undefined) {
return undefined;
}
const pp =
BeatLeaderCurve.curve(acc / 100, stars - 0.5) * (stars + 0.5) * 42;
return Number.isNaN(pp) ? undefined : pp;
}
}