feat(pp-calculator): support other pp calculators (#57)

New configurations:

- CALCULATOR="rosu": specific pp calculator
- CALCULATOR_CONFIG='{}': argument passed through into calculator
This commit is contained in:
MingxuanGame
2025-10-18 19:10:53 +08:00
committed by GitHub
parent 563a30d28f
commit 8790ccad64
16 changed files with 496 additions and 189 deletions

View File

@@ -1,5 +1,5 @@
from enum import Enum
from typing import TYPE_CHECKING, Literal, TypedDict, cast
from typing import Literal, TypedDict, cast
from app.config import settings
@@ -7,9 +7,6 @@ from .mods import API_MODS, APIMod
from pydantic import BaseModel, Field, ValidationInfo, field_serializer, field_validator
if TYPE_CHECKING:
import rosu_pp_py as rosu
class GameMode(str, Enum):
OSU = "osu"
@@ -21,20 +18,6 @@ class GameMode(str, Enum):
TAIKORX = "taikorx"
FRUITSRX = "fruitsrx"
def to_rosu(self) -> "rosu.GameMode":
import rosu_pp_py as rosu
return {
GameMode.OSU: rosu.GameMode.Osu,
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,
GameMode.TAIKORX: rosu.GameMode.Taiko,
GameMode.FRUITSRX: rosu.GameMode.Catch,
}[self]
def __int__(self) -> int:
return {
GameMode.OSU: 0,