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 2 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
24 changes: 14 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,24 @@ 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 both accuracy and geki/katu/50s/100s.")
cmyui marked this conversation as resolved.
Show resolved Hide resolved

# rosupp ignores NC and requires DT
if score.mods is not None:
Expand Down
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