Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: catch pp wrong due to both acc and judgements specified #627

Merged
merged 7 commits into from
Feb 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions app/objects/score.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
26 changes: 16 additions & 10 deletions app/usecases/performance.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/domains/osu_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
1 change: 0 additions & 1 deletion tools/recalc.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ async def recalculate_score(
calculator = Calculator(
cmyui marked this conversation as resolved.
Show resolved Hide resolved
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"],
Expand Down
Loading