mirror of
https://github.com/A-Minos/nonebot-plugin-tetris-stats.git
synced 2026-03-05 05:36:54 +08:00
✨ 适配 TETR.IO record 模板
This commit is contained in:
@@ -7,6 +7,7 @@ from ..templates import templates_dir
|
||||
from .schemas.bind import Bind
|
||||
from .schemas.tetrio_info import Info as TETRIOInfo
|
||||
from .schemas.tetrio_info_v2 import Info as TETRIOInfoV2
|
||||
from .schemas.tetrio_record_blitz import Record as TETRIORecordBlitz
|
||||
from .schemas.tetrio_record_sprint import Record as TETRIORecordSprint
|
||||
from .schemas.top_info import Info as TOPInfo
|
||||
from .schemas.tos_info import Info as TOSInfo
|
||||
@@ -24,6 +25,14 @@ async def render(render_type: Literal['v1/binding'], data: Bind) -> str: ...
|
||||
async def render(render_type: Literal['v1/tetrio/info'], data: TETRIOInfo) -> str: ...
|
||||
|
||||
|
||||
@overload
|
||||
async def render(render_type: Literal['v1/top/info'], data: TOPInfo) -> str: ...
|
||||
|
||||
|
||||
@overload
|
||||
async def render(render_type: Literal['v1/tos/info'], data: TOSInfo) -> str: ...
|
||||
|
||||
|
||||
@overload
|
||||
async def render(render_type: Literal['v2/tetrio/info'], data: TETRIOInfoV2) -> str: ...
|
||||
|
||||
@@ -33,23 +42,20 @@ async def render(render_type: Literal['v2/tetrio/record/40l'], data: TETRIORecor
|
||||
|
||||
|
||||
@overload
|
||||
async def render(render_type: Literal['v1/top/info'], data: TOPInfo) -> str: ...
|
||||
|
||||
|
||||
@overload
|
||||
async def render(render_type: Literal['v1/tos/info'], data: TOSInfo) -> str: ...
|
||||
async def render(render_type: Literal['v2/tetrio/record/blitz'], data: TETRIORecordBlitz) -> str: ...
|
||||
|
||||
|
||||
async def render(
|
||||
render_type: Literal[
|
||||
'v1/binding',
|
||||
'v1/tetrio/info',
|
||||
'v2/tetrio/info',
|
||||
'v1/top/info',
|
||||
'v1/tos/info',
|
||||
'v2/tetrio/info',
|
||||
'v2/tetrio/record/40l',
|
||||
'v2/tetrio/record/blitz',
|
||||
],
|
||||
data: Bind | TETRIOInfo | TETRIOInfoV2 | TETRIORecordSprint | TOPInfo | TOSInfo,
|
||||
data: Bind | TETRIOInfo | TOPInfo | TOSInfo | TETRIOInfoV2 | TETRIORecordSprint | TETRIORecordBlitz,
|
||||
) -> str:
|
||||
if PYDANTIC_V2:
|
||||
return await env.get_template('index.html').render_async(
|
||||
@@ -58,4 +64,4 @@ async def render(
|
||||
return await env.get_template('index.html').render_async(path=render_type, data=data.json(by_alias=True))
|
||||
|
||||
|
||||
__all__ = ['render', 'Bind']
|
||||
__all__ = ['render']
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
from pydantic import BaseModel
|
||||
|
||||
from .base import People
|
||||
|
||||
|
||||
class User(People):
|
||||
id: str
|
||||
|
||||
|
||||
class Max(BaseModel):
|
||||
combo: int
|
||||
btb: int
|
||||
|
||||
|
||||
class Mini(BaseModel):
|
||||
total: int
|
||||
single: int
|
||||
double: int
|
||||
|
||||
|
||||
class Tspins(BaseModel):
|
||||
total: int
|
||||
single: int
|
||||
double: int
|
||||
triple: int
|
||||
|
||||
mini: Mini
|
||||
|
||||
|
||||
class Finesse(BaseModel):
|
||||
faults: int
|
||||
accuracy: float
|
||||
|
||||
|
||||
class RecordStatistic(BaseModel):
|
||||
keys: int
|
||||
kpp: float
|
||||
kps: float
|
||||
|
||||
max: Max
|
||||
|
||||
pieces: int
|
||||
pps: float
|
||||
lines: int
|
||||
lpm: float
|
||||
holds: int | None
|
||||
score: int
|
||||
|
||||
single: int
|
||||
double: int
|
||||
triple: int
|
||||
quad: int
|
||||
|
||||
tspins: Tspins
|
||||
|
||||
all_clear: int
|
||||
|
||||
finesse: Finesse
|
||||
@@ -0,0 +1,22 @@
|
||||
from datetime import datetime
|
||||
|
||||
from pydantic import BaseModel
|
||||
|
||||
from .tetrio_record_base import RecordStatistic, User
|
||||
|
||||
|
||||
class Statistic(RecordStatistic):
|
||||
spp: float
|
||||
|
||||
level: int
|
||||
|
||||
|
||||
class Record(BaseModel):
|
||||
user: User
|
||||
|
||||
replay_id: str
|
||||
rank: int | None
|
||||
|
||||
statistic: Statistic
|
||||
|
||||
play_at: datetime
|
||||
@@ -2,77 +2,15 @@ from datetime import datetime
|
||||
|
||||
from pydantic import BaseModel
|
||||
|
||||
from ....games.tetrio.api.typing import Rank
|
||||
from .base import Avatar
|
||||
|
||||
|
||||
class TetraLeague(BaseModel):
|
||||
rank: Rank
|
||||
tr: float
|
||||
|
||||
|
||||
class User(BaseModel):
|
||||
id: str
|
||||
name: str
|
||||
avatar: Avatar | str
|
||||
tetra_league: TetraLeague | None
|
||||
|
||||
|
||||
class Max(BaseModel):
|
||||
combo: int
|
||||
btb: int
|
||||
|
||||
|
||||
class Mini(BaseModel):
|
||||
total: int
|
||||
single: int
|
||||
double: int
|
||||
|
||||
|
||||
class Tspins(BaseModel):
|
||||
total: int
|
||||
single: int
|
||||
double: int
|
||||
triple: int
|
||||
|
||||
mini: Mini
|
||||
|
||||
|
||||
class Finesse(BaseModel):
|
||||
faults: int
|
||||
accuracy: float
|
||||
|
||||
|
||||
class Statistic(BaseModel):
|
||||
keys: int
|
||||
kpp: float
|
||||
kps: float
|
||||
|
||||
max: Max
|
||||
|
||||
pieces: int
|
||||
pps: float
|
||||
lines: int
|
||||
lpm: float
|
||||
holds: int | None
|
||||
score: int
|
||||
|
||||
single: int
|
||||
double: int
|
||||
triple: int
|
||||
quad: int
|
||||
|
||||
tspins: Tspins
|
||||
|
||||
all_clear: int
|
||||
|
||||
finesse: Finesse
|
||||
from .tetrio_record_base import RecordStatistic as Statistic
|
||||
from .tetrio_record_base import User
|
||||
|
||||
|
||||
class Record(BaseModel):
|
||||
user: User
|
||||
|
||||
time: str
|
||||
replay_id: str
|
||||
rank: int | None
|
||||
|
||||
statistic: Statistic
|
||||
|
||||
Reference in New Issue
Block a user