Skip to content

Commit

Permalink
Merge pull request #170 from Syriiin/use-statistics-diffcalc
Browse files Browse the repository at this point in the history
Use json statistics for diffcalc
  • Loading branch information
Syriiin authored Nov 29, 2024
2 parents f326c3f + f2dd80a commit 6df1cc8
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 48 deletions.
38 changes: 17 additions & 21 deletions common/osu/difficultycalculator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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
}
Expand Down
58 changes: 36 additions & 22 deletions common/osu/test_difficultycalculator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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]) == [
Expand Down Expand Up @@ -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]) == [
Expand Down Expand Up @@ -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]) == [
Expand All @@ -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(
Expand Down Expand Up @@ -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]) == [
Expand Down
1 change: 1 addition & 0 deletions profiles/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
6 changes: 1 addition & 5 deletions profiles/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 6df1cc8

Please sign in to comment.