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 60 additions and 36 deletions

@ -17,5 +17,5 @@ jobs:
- name: Push to dokku
uses: dokku/github-action@master
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 }}

48
pnpm-lock.yaml generated

@ -126,7 +126,7 @@ devDependencies:
version: 1.0.10
autoprefixer:
specifier: ^10.4.17
version: 10.4.17(postcss@8.4.38)
version: 10.4.17(postcss@8.4.33)
cross-env:
specifier: ^7.0.3
version: 7.0.3
@ -138,7 +138,7 @@ devDependencies:
version: 14.1.0(eslint@8.56.0)(typescript@5.3.3)
postcss:
specifier: ^8.4.33
version: 8.4.38
version: 8.4.33
prettier:
specifier: ^3.2.4
version: 3.2.4
@ -1611,7 +1611,7 @@ packages:
resolution: {integrity: sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==}
dev: false
/autoprefixer@10.4.17(postcss@8.4.38):
/autoprefixer@10.4.17(postcss@8.4.33):
resolution: {integrity: sha512-/cpVNRLSfhOtcGflT13P2794gVSgmPgTR+erw5ifnMLZb0UnSlkK4tquLmkd3BhA+nLo5tX8Cu0upUsGKvKbmg==}
engines: {node: ^10 || ^12 || >=14}
hasBin: true
@ -1623,7 +1623,7 @@ packages:
fraction.js: 4.3.7
normalize-range: 0.1.2
picocolors: 1.0.0
postcss: 8.4.38
postcss: 8.4.33
postcss-value-parser: 4.2.0
dev: true
@ -1837,7 +1837,7 @@ packages:
dom-serializer: 2.0.0
domhandler: 5.0.3
htmlparser2: 8.0.2
postcss: 8.4.38
postcss: 8.4.33
pretty-bytes: 5.6.0
dev: false
@ -3471,27 +3471,27 @@ packages:
resolution: {integrity: sha512-saLsH7WeYYPiD25LDuLRRY/i+6HaPYr6G1OUlN39otzkSTxKnubR9RTxS3/Kk50s1g2JTgFwWQDQyplC5/SHZg==}
engines: {node: '>= 6'}
/postcss-import@15.1.0(postcss@8.4.38):
/postcss-import@15.1.0(postcss@8.4.33):
resolution: {integrity: sha512-hpr+J05B2FVYUAXHeK1YyI267J/dDDhMU6B6civm8hSY1jYJnBXxzKDKDswzJmtLHryrjhnDjqqp/49t8FALew==}
engines: {node: '>=14.0.0'}
peerDependencies:
postcss: ^8.0.0
dependencies:
postcss: 8.4.38
postcss: 8.4.33
postcss-value-parser: 4.2.0
read-cache: 1.0.0
resolve: 1.22.8
/postcss-js@4.0.1(postcss@8.4.38):
/postcss-js@4.0.1(postcss@8.4.33):
resolution: {integrity: sha512-dDLF8pEO191hJMtlHFPRa8xsizHaM82MLfNkUHdUtVEV3tgTp5oj+8qbEqYM57SLfc74KSbw//4SeJma2LRVIw==}
engines: {node: ^12 || ^14 || >= 16}
peerDependencies:
postcss: ^8.4.21
dependencies:
camelcase-css: 2.0.1
postcss: 8.4.38
postcss: 8.4.33
/postcss-load-config@4.0.2(postcss@8.4.38):
/postcss-load-config@4.0.2(postcss@8.4.33):
resolution: {integrity: sha512-bSVhyJGL00wMVoPUzAVAnbEoWyqRxkjv64tUl427SKnPrENtq6hJwUojroMz2VB+Q1edmi4IfrAPpami5VVgMQ==}
engines: {node: '>= 14'}
peerDependencies:
@ -3504,16 +3504,16 @@ packages:
optional: true
dependencies:
lilconfig: 3.0.0
postcss: 8.4.38
postcss: 8.4.33
yaml: 2.3.4
/postcss-nested@6.0.1(postcss@8.4.38):
/postcss-nested@6.0.1(postcss@8.4.33):
resolution: {integrity: sha512-mEp4xPMi5bSWiMbsgoPfcP74lsWLHkQbZc3sY+jWYd65CUwXrUaTp0fmNpa01ZcETKlIgUdFN/MpS2xZtqL9dQ==}
engines: {node: '>=12.0'}
peerDependencies:
postcss: ^8.2.14
dependencies:
postcss: 8.4.38
postcss: 8.4.33
postcss-selector-parser: 6.0.15
/postcss-selector-parser@6.0.15:
@ -3532,16 +3532,16 @@ packages:
dependencies:
nanoid: 3.3.7
picocolors: 1.0.0
source-map-js: 1.2.0
source-map-js: 1.0.2
dev: false
/postcss@8.4.38:
resolution: {integrity: sha512-Wglpdk03BSfXkHoQa3b/oulrotAkwrlLDRSOb9D0bN86FdRyE9lppSp33aHNPgBa0JKCoB+drFLZkQoRRYae5A==}
/postcss@8.4.33:
resolution: {integrity: sha512-Kkpbhhdjw2qQs2O2DGX+8m5OVqEcbB9HRBvuYM9pgrjEFUg30A9LmXNlTAUj4S9kgtGyrMbTzVjH7E+s5Re2yg==}
engines: {node: ^10 || ^12 || >=14}
dependencies:
nanoid: 3.3.7
picocolors: 1.0.0
source-map-js: 1.2.0
source-map-js: 1.0.2
/prelude-ls@1.2.1:
resolution: {integrity: sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==}
@ -3946,8 +3946,8 @@ packages:
engines: {node: '>=8'}
dev: true
/source-map-js@1.2.0:
resolution: {integrity: sha512-itJW8lvSA0TXEphiRoawsCksnlf8SyvmFzIhltqAHluXd88pkCd+cXJVHTDwdCr0IzwptSm035IHQktUu1QUMg==}
/source-map-js@1.0.2:
resolution: {integrity: sha512-R0XvVJ9WusLiqTCEiGCmICCMplcCkIwwR11mOSD9CR5u+IXYdiseeEuXCVAjS54zqwkLcPNnmU4OeJ6tUrWhDw==}
engines: {node: '>=0.10.0'}
/streamsearch@1.1.0:
@ -4105,11 +4105,11 @@ packages:
normalize-path: 3.0.0
object-hash: 3.0.0
picocolors: 1.0.0
postcss: 8.4.38
postcss-import: 15.1.0(postcss@8.4.38)
postcss-js: 4.0.1(postcss@8.4.38)
postcss-load-config: 4.0.2(postcss@8.4.38)
postcss-nested: 6.0.1(postcss@8.4.38)
postcss: 8.4.33
postcss-import: 15.1.0(postcss@8.4.33)
postcss-js: 4.0.1(postcss@8.4.33)
postcss-load-config: 4.0.2(postcss@8.4.33)
postcss-nested: 6.0.1(postcss@8.4.33)
postcss-selector-parser: 6.0.15
resolve: 1.22.8
sucrase: 3.35.0

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