diff --git a/app/objects/score.py b/app/objects/score.py index 1051e18d..c9c72601 100644 --- a/app/objects/score.py +++ b/app/objects/score.py @@ -324,8 +324,6 @@ def calculate_performance(self, beatmap_id: int) -> tuple[float, float]: mode=mode_vn, mods=int(self.mods), combo=self.max_combo, - # prefer to use the score's specific params that add up to the acc - acc=self.acc, ngeki=self.ngeki, n300=self.n300, nkatu=self.nkatu, diff --git a/app/usecases/performance.py b/app/usecases/performance.py index 5db4f029..2c2ed101 100644 --- a/app/usecases/performance.py +++ b/app/usecases/performance.py @@ -18,6 +18,7 @@ class ScoreParams: combo: int | None = None # caller may pass either acc OR 300/100/50/geki/katu/miss + # passing both will result in a value error being raised acc: float | None = None n300: int | None = None @@ -60,21 +61,26 @@ def calculate_performances( osu_file_path: str, scores: Iterable[ScoreParams], ) -> list[PerformanceResult]: + """\ + Calculate performance for multiple scores on a single beatmap. + + Typically most useful for mass-recalculation situations. + + TODO: Some level of error handling & returning to caller should be + implemented here to handle cases where e.g. the beatmap file is invalid + or there an issue during calculation. + """ calc_bmap = Beatmap(path=osu_file_path) results: list[PerformanceResult] = [] for score in scores: - # assert either acc OR 300/100/50/geki/katu/miss is present, but not both - # if (score.acc is None) == ( - # score.n300 is None - # and score.n100 is None - # and score.n50 is None - # and score.ngeki is None - # and score.nkatu is None - # and score.nmiss is None - # ): - # raise ValueError("Either acc OR 300/100/50/geki/katu/miss must be present") + if score.acc and ( + score.n300 or score.n100 or score.n50 or score.ngeki or score.nkatu + ): + raise ValueError( + "Must not specify accuracy AND 300/100/50/geki/katu. Only one or the other.", + ) # rosupp ignores NC and requires DT if score.mods is not None: diff --git a/tests/integration/domains/osu_test.py b/tests/integration/domains/osu_test.py index 49adc7ef..30c6f086 100644 --- a/tests/integration/domains/osu_test.py +++ b/tests/integration/domains/osu_test.py @@ -239,5 +239,5 @@ async def test_score_submission( assert response.status_code == status.HTTP_200_OK assert ( response.read() - == b"beatmapId:315|beatmapSetId:141|beatmapPlaycount:1|beatmapPasscount:1|approvedDate:2014-05-18 15:41:48|\n|chartId:beatmap|chartUrl:https://osu.cmyui.xyz/s/141|chartName:Beatmap Ranking|rankBefore:|rankAfter:1|rankedScoreBefore:|rankedScoreAfter:26810|totalScoreBefore:|totalScoreAfter:26810|maxComboBefore:|maxComboAfter:52|accuracyBefore:|accuracyAfter:81.94|ppBefore:|ppAfter:10.041|onlineScoreId:1|\n|chartId:overall|chartUrl:https://cmyui.xyz/u/3|chartName:Overall Ranking|rankBefore:|rankAfter:1|rankedScoreBefore:|rankedScoreAfter:26810|totalScoreBefore:|totalScoreAfter:26810|maxComboBefore:|maxComboAfter:52|accuracyBefore:|accuracyAfter:81.94|ppBefore:|ppAfter:10|achievements-new:osu-skill-pass-4+Insanity Approaches+You're not twitching, you're just ready./all-intro-hidden+Blindsight+I can see just perfectly" + == b"beatmapId:315|beatmapSetId:141|beatmapPlaycount:1|beatmapPasscount:1|approvedDate:2014-05-18 15:41:48|\n|chartId:beatmap|chartUrl:https://osu.cmyui.xyz/s/141|chartName:Beatmap Ranking|rankBefore:|rankAfter:1|rankedScoreBefore:|rankedScoreAfter:26810|totalScoreBefore:|totalScoreAfter:26810|maxComboBefore:|maxComboAfter:52|accuracyBefore:|accuracyAfter:81.94|ppBefore:|ppAfter:10.313|onlineScoreId:1|\n|chartId:overall|chartUrl:https://cmyui.xyz/u/3|chartName:Overall Ranking|rankBefore:|rankAfter:1|rankedScoreBefore:|rankedScoreAfter:26810|totalScoreBefore:|totalScoreAfter:26810|maxComboBefore:|maxComboAfter:52|accuracyBefore:|accuracyAfter:81.94|ppBefore:|ppAfter:11|achievements-new:osu-skill-pass-4+Insanity Approaches+You're not twitching, you're just ready./all-intro-hidden+Blindsight+I can see just perfectly" ) diff --git a/tools/recalc.py b/tools/recalc.py index 172a5053..d7c019d3 100644 --- a/tools/recalc.py +++ b/tools/recalc.py @@ -66,7 +66,6 @@ async def recalculate_score( calculator = Calculator( mode=GameMode(score["mode"]).as_vanilla, mods=score["mods"], - acc=score["acc"], combo=score["max_combo"], n_geki=score["ngeki"], # Mania 320s n300=score["n300"],