This commit is contained in:
@ -203,10 +203,12 @@ class IdiomGame:
|
|||||||
return TryVerifyState.VERIFIED_BUT_NO_NEXT
|
return TryVerifyState.VERIFIED_BUT_NO_NEXT
|
||||||
return TryVerifyState.VERIFIED
|
return TryVerifyState.VERIFIED
|
||||||
|
|
||||||
def get_user_score(self, user_id: str) -> int:
|
def get_user_score(self, user_id: str) -> float:
|
||||||
if user_id not in self.score_board:
|
if user_id not in self.score_board:
|
||||||
return 0
|
return 0
|
||||||
return self.score_board[user_id]["score"]
|
# 避免浮点数精度问题导致过长
|
||||||
|
handled_score = round(self.score_board[user_id]["score"], 1)
|
||||||
|
return handled_score
|
||||||
|
|
||||||
def add_score(self, user_id: str, score: int):
|
def add_score(self, user_id: str, score: int):
|
||||||
if user_id not in self.score_board:
|
if user_id not in self.score_board:
|
||||||
@ -377,7 +379,7 @@ async def end_game(event: BaseEvent, group_id: str):
|
|||||||
result_text += (
|
result_text += (
|
||||||
f"{i + 1}. "
|
f"{i + 1}. "
|
||||||
+ UniMessage().at(user_id)
|
+ UniMessage().at(user_id)
|
||||||
+ f": {info['score'] + instance.get_all_buff_score()} 分\n"
|
+ f": {round(info['score'] + instance.get_all_buff_score(), 1)} 分\n"
|
||||||
)
|
)
|
||||||
await evt.send(await result_text.export())
|
await evt.send(await result_text.export())
|
||||||
instance.clear_score_board()
|
instance.clear_score_board()
|
||||||
|
|||||||
Reference in New Issue
Block a user