diff --git a/common/osu/difficultycalculator.py b/common/osu/difficultycalculator.py index fb24d8e..8224f0e 100644 --- a/common/osu/difficultycalculator.py +++ b/common/osu/difficultycalculator.py @@ -36,11 +36,7 @@ class Score(NamedTuple): beatmap_id: str mods: int | None = None is_classic: bool = True - count_katu: int | None = None # mania: goods - count_300: int | None = None # mania: greats (ignored for others) - count_100: int | None = None # oks, catch: large droplets - count_50: int | None = None # mehs, catch: small droplets - count_miss: int | None = None + statistics: dict[str, int] = {} combo: int | None = None @@ -151,9 +147,9 @@ def _difficalcy_score_from_score(self, score: Score) -> dict: score.mods if score.mods is not None else 0, score.is_classic ), "Combo": score.combo, - "Misses": score.count_miss, - "Mehs": score.count_50, - "Oks": score.count_100, + "Misses": score.statistics.get("miss", 0), + "Mehs": score.statistics.get("meh", 0), + "Oks": score.statistics.get("ok", 0), }.items() if v is not None } @@ -184,8 +180,8 @@ def _difficalcy_score_from_score(self, score: Score) -> dict: score.mods if score.mods is not None else 0, score.is_classic ), "Combo": score.combo, - "Misses": score.count_miss, - "Oks": score.count_100, + "Misses": score.statistics.get("miss", 0), + "Oks": score.statistics.get("ok", 0), }.items() if v is not None } @@ -216,9 +212,9 @@ def _difficalcy_score_from_score(self, score: Score) -> dict: score.mods if score.mods is not None else 0, score.is_classic ), "Combo": score.combo, - "Misses": score.count_miss, - "SmallDroplets": score.count_50, - "LargeDroplets": score.count_100, + "Misses": score.statistics.get("miss", 0), + "SmallDroplets": score.statistics.get("small_tick_hit", 0), + "LargeDroplets": score.statistics.get("large_tick_hit", 0), }.items() if v is not None } @@ -249,11 +245,11 @@ def _difficalcy_score_from_score(self, score: Score) -> dict: score.mods if score.mods is not None else 0, score.is_classic ), "Combo": score.combo, - "Misses": score.count_miss, - "Mehs": score.count_50, - "Oks": score.count_100, - "Goods": score.count_katu, - "Greats": score.count_300, + "Misses": score.statistics.get("miss", 0), + "Mehs": score.statistics.get("meh", 0), + "Oks": score.statistics.get("ok", 0), + "Goods": score.statistics.get("good", 0), + "Greats": score.statistics.get("great", 0), }.items() if v is not None } @@ -286,9 +282,9 @@ def _difficalcy_score_from_score(self, score: Score) -> dict: score.mods if score.mods is not None else 0, score.is_classic ), "Combo": score.combo, - "Misses": score.count_miss, - "Mehs": score.count_50, - "Oks": score.count_100, + "Misses": score.statistics.get("miss", 0), + "Mehs": score.statistics.get("meh", 0), + "Oks": score.statistics.get("ok", 0), }.items() if v is not None } diff --git a/common/osu/test_difficultycalculator.py b/common/osu/test_difficultycalculator.py index e78537a..e71074e 100644 --- a/common/osu/test_difficultycalculator.py +++ b/common/osu/test_difficultycalculator.py @@ -45,17 +45,21 @@ def test_calculate_scores(self): Score( "307618", mods=int(Mods.DOUBLETIME + Mods.HIDDEN), - count_100=14, - count_50=1, - count_miss=1, + statistics={ + "ok": 14, + "meh": 1, + "miss": 1, + }, combo=2000, ), Score( "307618", mods=int(Mods.DOUBLETIME + Mods.HIDDEN + Mods.HARDROCK), - count_100=14, - count_50=1, - count_miss=1, + statistics={ + "ok": 14, + "meh": 1, + "miss": 1, + }, combo=2000, ), Score( @@ -124,9 +128,11 @@ def test_calculate_scores(self): score = Score( "307618", mods=int(Mods.DOUBLETIME + Mods.HIDDEN), - count_100=14, - count_50=1, - count_miss=1, + statistics={ + "ok": 14, + "meh": 1, + "miss": 1, + }, combo=2000, ) assert calc.calculate_scores([score]) == [ @@ -160,8 +166,10 @@ def test_calculate_scores(self): score = Score( "2", mods=int(Mods.DOUBLETIME + Mods.HARDROCK), - count_100=3, - count_miss=5, + statistics={ + "ok": 3, + "miss": 5, + }, combo=150, ) assert calc.calculate_scores([score]) == [ @@ -193,9 +201,11 @@ def test_calculate_scores(self): score = Score( "3", mods=int(Mods.DOUBLETIME + Mods.HARDROCK), - count_100=18, - count_50=200, - count_miss=5, + statistics={ + "large_tick_hit": 18, + "small_tick_hit": 200, + "miss": 5, + }, combo=100, ) assert calc.calculate_scores([score]) == [ @@ -222,11 +232,13 @@ def test_calculate_scores(self): score = Score( "4", mods=int(Mods.DOUBLETIME + Mods.EASY), - count_300=1, - count_katu=2, - count_100=3, - count_50=4, - count_miss=5, + statistics={ + "great": 1, + "good": 2, + "ok": 3, + "meh": 4, + "miss": 5, + }, ) assert calc.calculate_scores([score]) == [ Calculation( @@ -259,9 +271,11 @@ def test_calculate_scores(self): score = Score( "307618", mods=int(Mods.DOUBLETIME + Mods.HIDDEN), - count_100=14, - count_50=1, - count_miss=1, + statistics={ + "ok": 14, + "meh": 1, + "miss": 1, + }, combo=2000, ) assert calc.calculate_scores([score]) == [ diff --git a/profiles/models.py b/profiles/models.py index 54cbfd7..5ee6aa0 100644 --- a/profiles/models.py +++ b/profiles/models.py @@ -559,6 +559,7 @@ def get_nochoke_mutation(self): score.count_100 = self.count_100 score.count_50 = self.count_50 score.count_miss = 0 + # TODO: update to handle lazer statistics score.statistics = { "great": score.count_300, "ok": score.count_100, diff --git a/profiles/services.py b/profiles/services.py index 56927a3..71aac2c 100644 --- a/profiles/services.py +++ b/profiles/services.py @@ -587,11 +587,7 @@ def calculate_performance_values( beatmap_id=str(performance_calculation.score.beatmap_id), mods=performance_calculation.score.mods, is_classic=performance_calculation.score.is_classic, - count_300=performance_calculation.score.count_300, - count_katu=performance_calculation.score.count_katu, - count_100=performance_calculation.score.count_100, - count_50=performance_calculation.score.count_50, - count_miss=performance_calculation.score.count_miss, + statistics=performance_calculation.score.statistics, combo=performance_calculation.score.best_combo, ) for performance_calculation in performance_calculations