fix(score): rewrite DB model & API model
This commit is contained in:
@@ -1,11 +1,9 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from enum import Enum, IntEnum
|
||||
from typing import Any, Optional
|
||||
from typing import Any
|
||||
|
||||
from pydantic import BaseModel
|
||||
from datetime import datetime
|
||||
from .user import User
|
||||
|
||||
|
||||
class GameMode(str, Enum):
|
||||
@@ -23,6 +21,18 @@ MODE_TO_INT = {
|
||||
}
|
||||
|
||||
|
||||
class Rank(str, Enum):
|
||||
X = "ss"
|
||||
XH = "ssh"
|
||||
S = "s"
|
||||
SH = "sh"
|
||||
A = "a"
|
||||
B = "b"
|
||||
C = "c"
|
||||
D = "d"
|
||||
F = "f"
|
||||
|
||||
|
||||
class APIMod(BaseModel):
|
||||
acronym: str
|
||||
settings: dict[str, Any] = {}
|
||||
@@ -54,63 +64,3 @@ class HitResult(IntEnum):
|
||||
COMBO_BREAK = 16 # [Order(16)]
|
||||
|
||||
LEGACY_COMBO_INCREASE = 99 # [Order(99)] @deprecated
|
||||
|
||||
class Score(BaseModel):
|
||||
# 基本信息
|
||||
id: int
|
||||
user_id: int
|
||||
mode: GameMode
|
||||
mode_int: int
|
||||
beatmap_id: int
|
||||
best_id: int
|
||||
build_id: int
|
||||
|
||||
# 分数和准确度
|
||||
score: int
|
||||
accuracy: float
|
||||
mods: list[APIMod]
|
||||
total_score: int
|
||||
|
||||
# 命中统计
|
||||
statistics: dict[HitResult, int]
|
||||
maximum_statistics: dict[HitResult, int]
|
||||
|
||||
# 排名相关
|
||||
rank: str # 等级 (SS, S, A, B, C, D, F)
|
||||
ranked: bool
|
||||
rank_country: Optional[int] = None
|
||||
rank_global: Optional[int] = None
|
||||
|
||||
# PP值
|
||||
pp: Optional[float] = None
|
||||
pp_exp: Optional[float] = None
|
||||
|
||||
# 连击
|
||||
maximum_combo: int
|
||||
combo: int
|
||||
|
||||
# 游戏设置
|
||||
is_perfect_combo: bool
|
||||
passed: bool # 是否通过谱面
|
||||
|
||||
# 时间信息
|
||||
started_at: datetime
|
||||
ended_at: datetime
|
||||
|
||||
# 最佳成绩相关
|
||||
best_id: Optional[int] = None
|
||||
is_best: bool = False
|
||||
|
||||
# 额外信息
|
||||
has_replay: bool # 是否有回放
|
||||
preserve: bool # 是否保留
|
||||
processed: bool # 是否已处理
|
||||
|
||||
# Legacy字段
|
||||
legacy_score_id: Optional[int] = None
|
||||
legacy_total_score: int
|
||||
legacy_perfect: bool
|
||||
|
||||
# mp字段
|
||||
playlist_item_id: Optional[int] = None
|
||||
room_id: Optional[int] = None
|
||||
Reference in New Issue
Block a user