mirror of
https://github.com/Lost-MSth/Arcaea-server.git
synced 2026-02-10 18:07:28 +08:00
[Enhance] [Refactor] Add API about characters
- Add API endpoints about characters - Some small changes in refactoring
This commit is contained in:
@@ -14,6 +14,8 @@ from .world import WorldPlay
|
||||
|
||||
class Score:
|
||||
def __init__(self) -> None:
|
||||
self.c = None
|
||||
|
||||
self.song: 'Chart' = Chart()
|
||||
self.score: int = None
|
||||
self.shiny_perfect_count: int = None
|
||||
@@ -45,18 +47,17 @@ class Score:
|
||||
'''分数转换为评级'''
|
||||
if score >= 9900000: # EX+
|
||||
return 6
|
||||
elif 9800000 <= score < 9900000: # EX
|
||||
if score >= 9800000: # EX
|
||||
return 5
|
||||
elif 9500000 <= score < 9800000: # AA
|
||||
if score >= 9500000: # AA
|
||||
return 4
|
||||
elif 9200000 <= score < 9500000: # A
|
||||
if score >= 9200000: # A
|
||||
return 3
|
||||
elif 8900000 <= score < 9200000: # B
|
||||
if score >= 8900000: # B
|
||||
return 2
|
||||
elif 8600000 <= score < 8900000: # C
|
||||
if score >= 8600000: # C
|
||||
return 1
|
||||
else:
|
||||
return 0
|
||||
return 0
|
||||
|
||||
@property
|
||||
def song_grade(self) -> int:
|
||||
@@ -67,16 +68,15 @@ class Score:
|
||||
'''clear_type转换为成绩状态,用数字大小标识便于比较'''
|
||||
if clear_type == 3: # PM
|
||||
return 5
|
||||
elif clear_type == 2: # FC
|
||||
if clear_type == 2: # FC
|
||||
return 4
|
||||
elif clear_type == 5: # Hard Clear
|
||||
if clear_type == 5: # Hard Clear
|
||||
return 3
|
||||
elif clear_type == 1: # Clear
|
||||
if clear_type == 1: # Clear
|
||||
return 2
|
||||
elif clear_type == 4: # Easy Clear
|
||||
if clear_type == 4: # Easy Clear
|
||||
return 1
|
||||
else: # Track Lost
|
||||
return 0
|
||||
return 0 # Track Lost
|
||||
|
||||
@property
|
||||
def song_state(self) -> int:
|
||||
@@ -112,8 +112,7 @@ class Score:
|
||||
ptt = defnum + 2
|
||||
elif score < 9800000:
|
||||
ptt = defnum + (score-9500000) / 300000
|
||||
if ptt < 0:
|
||||
ptt = 0
|
||||
ptt = max(ptt, 0)
|
||||
else:
|
||||
ptt = defnum + 1 + (score-9800000) / 200000
|
||||
|
||||
@@ -218,6 +217,7 @@ class UserPlay(UserScore):
|
||||
self.course_play: 'CoursePlay' = None
|
||||
|
||||
def to_dict(self) -> dict:
|
||||
# 不能super
|
||||
if self.is_world_mode is None or self.course_play_state is None:
|
||||
return {}
|
||||
if self.course_play_state == 4:
|
||||
@@ -302,7 +302,7 @@ class UserPlay(UserScore):
|
||||
x = self.c.fetchone()
|
||||
if x:
|
||||
self.prog_boost_multiply = 300 if x[0] == 300 else 0
|
||||
if x[1] < self.beyond_boost_gauge_usage or (self.beyond_boost_gauge_usage != 100 and self.beyond_boost_gauge_usage != 200):
|
||||
if x[1] < self.beyond_boost_gauge_usage or self.beyond_boost_gauge_usage not in (100, 200):
|
||||
# 注意:偷懒了,没判断是否是beyond图
|
||||
self.beyond_boost_gauge_usage = 0
|
||||
|
||||
@@ -374,8 +374,8 @@ class UserPlay(UserScore):
|
||||
'''更新此分数对应用户的recent30'''
|
||||
old_recent_10 = self.ptt.recent_10
|
||||
if self.is_protected:
|
||||
old_r30 = [x for x in self.ptt.r30]
|
||||
old_s30 = [x for x in self.ptt.s30]
|
||||
old_r30 = self.ptt.r30.copy()
|
||||
old_s30 = self.ptt.s30.copy()
|
||||
|
||||
# 寻找pop位置
|
||||
songs = list(set(self.ptt.s30))
|
||||
@@ -479,7 +479,8 @@ class UserPlay(UserScore):
|
||||
|
||||
class Potential:
|
||||
'''
|
||||
用户潜力值计算处理类\
|
||||
用户潜力值计算处理类
|
||||
|
||||
property: `user` - `User`类或子类的实例
|
||||
'''
|
||||
|
||||
@@ -487,8 +488,8 @@ class Potential:
|
||||
self.c = c
|
||||
self.user = user
|
||||
|
||||
self.r30: list = None
|
||||
self.s30: list = None
|
||||
self.r30: 'list[float]' = None
|
||||
self.s30: 'list[str]' = None
|
||||
self.songs_selected: list = None
|
||||
|
||||
self.b30: list = None
|
||||
@@ -503,7 +504,7 @@ class Potential:
|
||||
'''获取用户best30的总潜力值'''
|
||||
self.c.execute('''select rating from best_score where user_id = :a order by rating DESC limit 30''', {
|
||||
'a': self.user.user_id})
|
||||
return sum([x[0] for x in self.c.fetchall()])
|
||||
return sum(x[0] for x in self.c.fetchall())
|
||||
|
||||
def select_recent_30(self) -> None:
|
||||
'''获取用户recent30数据'''
|
||||
@@ -578,7 +579,8 @@ class Potential:
|
||||
|
||||
class UserScoreList:
|
||||
'''
|
||||
用户分数查询类\
|
||||
用户分数查询类
|
||||
|
||||
properties: `user` - `User`类或子类的实例
|
||||
'''
|
||||
|
||||
|
||||
Reference in New Issue
Block a user