Compare commits

..

1 Commits

3 changed files with 21 additions and 42 deletions

View File

@ -17,5 +17,5 @@ jobs:
- name: Push to dokku
uses: dokku/github-action@master
with:
git_remote_url: "ssh://dokku@10.0.50.65:22/scoresaber-reloadedv2"
git_remote_url: "ssh://dokku@10.0.3.39:22/scoresaber-reloadedv2"
ssh_private_key: ${{ secrets.SSH_PRIVATE_KEY }}

15
pnpm-lock.yaml generated
View File

@ -144,7 +144,7 @@ devDependencies:
version: 3.2.4
prettier-plugin-tailwindcss:
specifier: ^0.5.11
version: 0.5.11(prettier@3.2.4)
version: 0.5.13(prettier@3.2.4)
tailwindcss:
specifier: ^3.4.1
version: 3.4.1
@ -3548,14 +3548,15 @@ packages:
engines: {node: '>= 0.8.0'}
dev: true
/prettier-plugin-tailwindcss@0.5.11(prettier@3.2.4):
resolution: {integrity: sha512-AvI/DNyMctyyxGOjyePgi/gqj5hJYClZ1avtQvLlqMT3uDZkRbi4HhGUpok3DRzv9z7Lti85Kdj3s3/1CeNI0w==}
/prettier-plugin-tailwindcss@0.5.13(prettier@3.2.4):
resolution: {integrity: sha512-2tPWHCFNC+WRjAC4SIWQNSOdcL1NNkydXim8w7TDqlZi+/ulZYz2OouAI6qMtkggnPt7lGamboj6LcTMwcCvoQ==}
engines: {node: '>=14.21.3'}
peerDependencies:
'@ianvs/prettier-plugin-sort-imports': '*'
'@prettier/plugin-pug': '*'
'@shopify/prettier-plugin-liquid': '*'
'@trivago/prettier-plugin-sort-imports': '*'
'@zackad/prettier-plugin-twig-melody': '*'
prettier: ^3.0
prettier-plugin-astro: '*'
prettier-plugin-css-order: '*'
@ -3564,9 +3565,9 @@ packages:
prettier-plugin-marko: '*'
prettier-plugin-organize-attributes: '*'
prettier-plugin-organize-imports: '*'
prettier-plugin-sort-imports: '*'
prettier-plugin-style-order: '*'
prettier-plugin-svelte: '*'
prettier-plugin-twig-melody: '*'
peerDependenciesMeta:
'@ianvs/prettier-plugin-sort-imports':
optional: true
@ -3576,6 +3577,8 @@ packages:
optional: true
'@trivago/prettier-plugin-sort-imports':
optional: true
'@zackad/prettier-plugin-twig-melody':
optional: true
prettier-plugin-astro:
optional: true
prettier-plugin-css-order:
@ -3590,12 +3593,12 @@ packages:
optional: true
prettier-plugin-organize-imports:
optional: true
prettier-plugin-sort-imports:
optional: true
prettier-plugin-style-order:
optional: true
prettier-plugin-svelte:
optional: true
prettier-plugin-twig-melody:
optional: true
dependencies:
prettier: 3.2.4
dev: true

View File

@ -7,7 +7,7 @@ import { useScoresaberScoresStore } from "@/store/scoresaberScoresStore";
export const WEIGHT_COEFFICIENT = 0.965;
const starMultiplier = 42.11;
const ppCurve: [number, number][] = [
const ppCurve = [
[1, 5.367394282890631],
[0.9995, 5.019543595874787],
[0.999, 4.715470646416203],
@ -63,53 +63,29 @@ function lerp(v0: number, v1: number, t: number) {
return v0 + t * (v1 - v0);
}
function calculatePPModifier(
c1: [number, number],
c2: [number, number],
acc: number,
): number {
const distance: number = (c2[0] - acc) / (c2[0] - c1[0]);
const interpolated: number = lerp(c2[1], c1[1], distance);
console.log(
`Acc: ${acc}, c1: ${c1}, c2: ${c2}, Distance: ${distance}, Interpolated: ${interpolated}`,
);
return interpolated;
function calculatePPModifier(c1: Array<any>, c2: Array<any>, acc: number) {
const distance = (c2[0] - acc) / (c2[0] - c1[0]);
return lerp(c2[1], c1[1], distance);
}
function findPPModifier(
acc: number,
curve: [number, number][],
): number | undefined {
function findPPModifier(acc: number, curve: Array<any>) {
acc = clamp(acc, 0, 100) / 100;
console.log("Clamped Accuracy:", acc);
let prev: [number, number] = curve[1];
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);
}
prev = item;
}
return undefined;
}
export function getScoreSaberPP(
acc: number,
stars: number,
): { pp: number | undefined } {
console.log("Input Stars:", stars);
console.log("Input Accuracy:", acc);
const ppValue: number = stars * starMultiplier;
const modifier: number | undefined = findPPModifier(acc * 100, ppCurve);
console.log("Modifier:", modifier);
if (!modifier) return { pp: undefined };
const finalPP: number = modifier * ppValue;
console.log("Final PP:", finalPP);
export function getScoreSaberPP(acc: number, stars: number) {
const ppValue = stars * starMultiplier;
const modifier = findPPModifier(acc * 100, ppCurve);
if (!modifier) return undefined;
const finalPP = modifier * ppValue;
return {
pp: Number.isNaN(finalPP) ? undefined : finalPP,
};