From 324c08f6f60c50da0949852049acbae24c5f968e Mon Sep 17 00:00:00 2001 From: Fascinated Date: Sun, 26 Mar 2023 22:17:05 +0100 Subject: [PATCH] e --- -ignore .gitea/workflows/publish.yaml | 15 +++++++++ .gitea/workflows/publish.yaml | 14 ++++---- src/components/ScoreStats.js | 38 +++++++++++++++++----- src/curve/BeatLeaderCurve.js | 7 +++- src/curve/ScoreSaberCurve.js | 4 ++- src/store/songDataStore.ts | 46 ++++++++++++++++++++------- src/utils/utils.js | 8 +++-- 7 files changed, 102 insertions(+), 30 deletions(-) create mode 100644 -ignore .gitea/workflows/publish.yaml diff --git a/-ignore .gitea/workflows/publish.yaml b/-ignore .gitea/workflows/publish.yaml new file mode 100644 index 0000000..38c5044 --- /dev/null +++ b/-ignore .gitea/workflows/publish.yaml @@ -0,0 +1,15 @@ +name: Gitea Actions Demo +run-name: ${{ github.actor }} is testing out Gitea Actions +on: [push] +jobs: + Explore-Gitea-Actions: + runs-on: ubuntu-20.04 + steps: + - run: echo "The job was automatically triggered by a ${{ github.event_name }} event." + - run: echo "This job is now running on a ${{ runner.os }} server hosted by Gitea!" + - run: echo "The name of your branch is ${{ github.ref }} and your repository is ${{ github.repository }}." + - name: Check out repository code + uses: actions/checkout@v3 + - run: echo "The ${{ github.repository }} repository has been cloned to the runner." + - run: echo "The workflow is now ready to test your code on the runner." + - run: echo "This job's status is ${{ job.status }}." diff --git a/.gitea/workflows/publish.yaml b/.gitea/workflows/publish.yaml index 520838b..38c5044 100644 --- a/.gitea/workflows/publish.yaml +++ b/.gitea/workflows/publish.yaml @@ -1,15 +1,15 @@ name: Gitea Actions Demo -run-name: ${{ github.actor }} is testing out Gitea Actions 🚀 +run-name: ${{ github.actor }} is testing out Gitea Actions on: [push] jobs: Explore-Gitea-Actions: runs-on: ubuntu-20.04 steps: - - run: echo "🎉 The job was automatically triggered by a ${{ github.event_name }} event." - - run: echo "🐧 This job is now running on a ${{ runner.os }} server hosted by Gitea!" - - run: echo "🔎 The name of your branch is ${{ github.ref }} and your repository is ${{ github.repository }}." + - run: echo "The job was automatically triggered by a ${{ github.event_name }} event." + - run: echo "This job is now running on a ${{ runner.os }} server hosted by Gitea!" + - run: echo "The name of your branch is ${{ github.ref }} and your repository is ${{ github.repository }}." - name: Check out repository code uses: actions/checkout@v3 - - run: echo "💡 The ${{ github.repository }} repository has been cloned to the runner." - - run: echo "🖥️ The workflow is now ready to test your code on the runner." - - run: echo "🍏 This job's status is ${{ job.status }}." + - run: echo "The ${{ github.repository }} repository has been cloned to the runner." + - run: echo "The workflow is now ready to test your code on the runner." + - run: echo "This job's status is ${{ job.status }}." diff --git a/src/components/ScoreStats.js b/src/components/ScoreStats.js index 6cf6de3..6fa66b6 100644 --- a/src/components/ScoreStats.js +++ b/src/components/ScoreStats.js @@ -3,6 +3,7 @@ import { getFormattedScorePercent } from "../helpers/map/mapHelpers"; import { useSettingsStore } from "../store/overlaySettingsStore"; import { useSongDataStore } from "../store/songDataStore"; import styles from "../styles/scoreStats.module.css"; +import Utils from "../utils/utils"; export default function ScoreStats() { const [showScoreInfo, showPp] = useSettingsStore((store) => [ @@ -47,7 +48,9 @@ export default function ScoreStats() {

{getFormattedScorePercent(percentage)} {percentage.toFixed(2)}%

- {scoreSaberPP !== undefined && showPp ? ( + {scoreSaberPP !== undefined && + scoreSaberPP.pp !== undefined && + showPp ? (
-

- {beatLeaderPP.toFixed(0)}pp -

+
+ {Object.entries(beatLeaderPP).map((value, i) => { + let name = value[0]; + const pp = value[1]; + + name = name.split("PP")[0]; + if (name == "pp") { + name = undefined; + } + if (name !== undefined) { + name = Utils.capitalizeFirstLetter(name); + } + + return ( +

+ {name} {pp.toFixed(0)}pp +

+ ); + })} +
) : null} diff --git a/src/curve/BeatLeaderCurve.js b/src/curve/BeatLeaderCurve.js index c68117c..dd3894d 100644 --- a/src/curve/BeatLeaderCurve.js +++ b/src/curve/BeatLeaderCurve.js @@ -57,7 +57,12 @@ export function getBeatLeaderPP(accuracy, accRating, passRating, techRating) { techRating * modifierBonus ); const pp = inflate(ppValues.passPP + ppValues.accPP + ppValues.techPP); - return isNaN(pp) ? 1024 : pp; + return { + pp: pp, + passPP: ppValues.passPP, + accPP: ppValues.accPP, + techPP: ppValues.techPP, + }; } /** diff --git a/src/curve/ScoreSaberCurve.js b/src/curve/ScoreSaberCurve.js index 92a2d0a..de12e4a 100644 --- a/src/curve/ScoreSaberCurve.js +++ b/src/curve/ScoreSaberCurve.js @@ -75,5 +75,7 @@ export function getScoreSaberPP(acc, stars) { const modifier = findPPModifier(acc * 100, ppCurve); const finalPP = modifier * ppValue; - return Number.isNaN(finalPP) ? undefined : finalPP; + return { + pp: Number.isNaN(finalPP) ? undefined : finalPP, + }; } diff --git a/src/store/songDataStore.ts b/src/store/songDataStore.ts index 51077e6..27cc351 100644 --- a/src/store/songDataStore.ts +++ b/src/store/songDataStore.ts @@ -17,7 +17,7 @@ interface SongDataState { stars: Number | undefined; modifiers: Object; }; - beatleader: { + beatLeader: { stars: Number | undefined; modifiers: Object; passRating: number | undefined; @@ -35,8 +35,15 @@ interface SongDataState { percentage: number; combo: number; currentPP: { - scoreSaber: number | undefined; - beatLeader: number | undefined; + beatLeader: { + pp: number | undefined; + passPP: number | undefined; + accPP: number | undefined; + techPP: number | undefined; + }; + scoreSaber: { + pp: number | undefined; + }; }; saberA: { cutDistanceScore: number; @@ -82,7 +89,7 @@ export const useSongDataStore = create()((set) => ({ stars: 0, modifiers: {}, }, - beatleader: { + beatLeader: { stars: 0, modifiers: {}, passRating: undefined, @@ -100,8 +107,15 @@ export const useSongDataStore = create()((set) => ({ percentage: 100, combo: 0, currentPP: { - beatLeader: undefined, - scoreSaber: undefined, + beatLeader: { + pp: undefined, + passPP: undefined, + accPP: undefined, + techPP: undefined, + }, + scoreSaber: { + pp: undefined, + }, }, saberA: { cutDistanceScore: 0.0, @@ -144,7 +158,7 @@ export const useSongDataStore = create()((set) => ({ isLoading: false, hasError: hasError, mapLeaderboardData: { - beatleader: { + beatLeader: { stars: beatLeaderLeaderboardData.stars, modifiers: beatLeaderLeaderboardData.modifiers, passRating: beatLeaderLeaderboardData.passRating, @@ -211,8 +225,8 @@ export const useSongDataStore = create()((set) => ({ "ScoreSaber" ); - const beatLeaderMapStarCount = leaderboardData.beatleader.stars; - let beatLeaderPP = Utils.calculatePP( + const beatLeaderMapStarCount = leaderboardData.beatLeader.stars; + let beatLeaderPP: any = Utils.calculatePP( beatLeaderMapStarCount, percent, "BeatLeader" @@ -250,7 +264,7 @@ export const useSongDataStore = create()((set) => ({ stars: undefined, modifiers: {}, }, - beatleader: { + beatLeader: { stars: undefined, modifiers: {}, passRating: undefined, @@ -267,7 +281,17 @@ export const useSongDataStore = create()((set) => ({ currentScore: 0, percentage: 100, combo: 0, - currentPP: undefined, + currentPP: { + beatLeader: { + pp: undefined, + passPP: undefined, + accPP: undefined, + techPP: undefined, + }, + scoreSaber: { + pp: undefined, + }, + }, saberA: { cutDistanceScore: 0.0, averagePreSwing: 0.0, diff --git a/src/utils/utils.js b/src/utils/utils.js index df0a94e..01f6adc 100644 --- a/src/utils/utils.js +++ b/src/utils/utils.js @@ -38,7 +38,7 @@ export default class Utils { } if (type === "BeatLeader") { const leaderboardData = - useSongDataStore.getState().mapLeaderboardData.beatleader; + useSongDataStore.getState().mapLeaderboardData.beatLeader; return getBeatLeaderPP( acc, @@ -56,7 +56,7 @@ export default class Utils { static calculateModifierBonus() { const songMods = useSongDataStore.getState().songModifiers; const modifierMulipliers = - useSongDataStore.getState().mapLeaderboardData.beatleader.modifiers; + useSongDataStore.getState().mapLeaderboardData.beatLeader.modifiers; let bonus = 1; // No Fail @@ -131,4 +131,8 @@ export default class Utils { return JSON.parse(stringValue); } }; + + static capitalizeFirstLetter(string) { + return string.charAt(0).toUpperCase() + string.slice(1); + } }