Compare commits

..

4 Commits

Author SHA1 Message Date
0f24578e06 joe
Some checks failed
deploy / deploy (push) Failing after 43s
2024-08-01 00:35:10 +01:00
Lee
2ac3dbdacd Update src/utils/scoresaber/scores.ts
Some checks failed
deploy / deploy (push) Failing after 35s
2024-07-31 23:32:42 +00:00
Lee
e4f2c69f7e Update .gitea/workflows/deploy.yml
Some checks failed
deploy / deploy (push) Failing after 1m17s
2024-07-31 23:30:06 +00:00
Lee
9e43a72ac9 Update src/utils/scoresaber/scores.ts
Some checks failed
deploy / deploy (push) Failing after 10s
2024-07-31 23:29:10 +00:00
3 changed files with 42 additions and 18 deletions

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

@ -141,10 +141,10 @@ devDependencies:
version: 8.4.33 version: 8.4.33
prettier: prettier:
specifier: ^3.2.4 specifier: ^3.2.4
version: 3.2.5 version: 3.2.4
prettier-plugin-tailwindcss: prettier-plugin-tailwindcss:
specifier: ^0.5.11 specifier: ^0.5.11
version: 0.5.11(prettier@3.2.5) version: 0.5.11(prettier@3.2.4)
tailwindcss: tailwindcss:
specifier: ^3.4.1 specifier: ^3.4.1
version: 3.4.1 version: 3.4.1
@ -3548,7 +3548,7 @@ packages:
engines: {node: '>= 0.8.0'} engines: {node: '>= 0.8.0'}
dev: true dev: true
/prettier-plugin-tailwindcss@0.5.11(prettier@3.2.5): /prettier-plugin-tailwindcss@0.5.11(prettier@3.2.4):
resolution: {integrity: sha512-AvI/DNyMctyyxGOjyePgi/gqj5hJYClZ1avtQvLlqMT3uDZkRbi4HhGUpok3DRzv9z7Lti85Kdj3s3/1CeNI0w==} resolution: {integrity: sha512-AvI/DNyMctyyxGOjyePgi/gqj5hJYClZ1avtQvLlqMT3uDZkRbi4HhGUpok3DRzv9z7Lti85Kdj3s3/1CeNI0w==}
engines: {node: '>=14.21.3'} engines: {node: '>=14.21.3'}
peerDependencies: peerDependencies:
@ -3597,11 +3597,11 @@ packages:
prettier-plugin-twig-melody: prettier-plugin-twig-melody:
optional: true optional: true
dependencies: dependencies:
prettier: 3.2.5 prettier: 3.2.4
dev: true dev: true
/prettier@3.2.5: /prettier@3.2.4:
resolution: {integrity: sha512-3/GWa9aOC0YeD7LUfvOG2NiDyhOWRvt1k+rcKhOuYnMY24iiCphgneUfJDyFXd6rZCAnuLBv6UeAULtrhT/F4A==} resolution: {integrity: sha512-FWu1oLHKCrtpO1ypU6J0SbK2d9Ckwysq6bHj/uaCP26DxrPpppCLQRGVuqAxSTvhF00AcvDRyYrLNW7ocBhFFQ==}
engines: {node: '>=14'} engines: {node: '>=14'}
hasBin: true hasBin: true
dev: true dev: true

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