feat(score): support osu-rx & osu-ap & all beatmap leaderboard like osu.ppy.sb

This commit is contained in:
MingxuanGame
2025-08-10 07:02:55 +00:00
parent f165ae5dc3
commit efc784d903
14 changed files with 262 additions and 19 deletions

View File

@@ -14,6 +14,20 @@ class BeatmapRankStatus(IntEnum):
QUALIFIED = 3
LOVED = 4
def has_leaderboard(self) -> bool:
return self in {
BeatmapRankStatus.RANKED,
BeatmapRankStatus.APPROVED,
BeatmapRankStatus.QUALIFIED,
BeatmapRankStatus.LOVED,
}
def has_pp(self) -> bool:
return self in {
BeatmapRankStatus.RANKED,
BeatmapRankStatus.APPROVED,
}
class Genre(IntEnum):
ANY = 0

View File

@@ -4,6 +4,7 @@ from copy import deepcopy
import json
from typing import Literal, NotRequired, TypedDict
from app.config import settings as app_settings
from app.path import STATIC_DIR
@@ -155,8 +156,15 @@ for i in range(4, 10):
def mods_can_get_pp(ruleset_id: int, mods: list[APIMod]) -> bool:
if app_settings.enable_all_mods_pp:
return True
ranked_mods = RANKED_MODS[ruleset_id]
for mod in mods:
if app_settings.enable_osu_rx and mod["acronym"] == "RX" and ruleset_id == 0:
continue
if app_settings.enable_osu_ap and mod["acronym"] == "AP" and ruleset_id == 0:
continue
mod["settings"] = mod.get("settings", {})
if (settings := ranked_mods.get(mod["acronym"])) is None:
return False

View File

@@ -16,6 +16,8 @@ class GameMode(str, Enum):
TAIKO = "taiko"
FRUITS = "fruits"
MANIA = "mania"
OSURX = "osurx"
OSUAP = "osuap"
def to_rosu(self) -> "rosu.GameMode":
import rosu_pp_py as rosu
@@ -25,6 +27,8 @@ class GameMode(str, Enum):
GameMode.TAIKO: rosu.GameMode.Taiko,
GameMode.FRUITS: rosu.GameMode.Catch,
GameMode.MANIA: rosu.GameMode.Mania,
GameMode.OSURX: rosu.GameMode.Osu,
GameMode.OSUAP: rosu.GameMode.Osu,
}[self]
@@ -33,8 +37,11 @@ MODE_TO_INT = {
GameMode.TAIKO: 1,
GameMode.FRUITS: 2,
GameMode.MANIA: 3,
GameMode.OSURX: 0,
GameMode.OSUAP: 0,
}
INT_TO_MODE = {v: k for k, v in MODE_TO_INT.items()}
INT_TO_MODE[0] = GameMode.OSU
class Rank(str, Enum):