diff --git a/konabot/plugins/idiomgame/__init__.py b/konabot/plugins/idiomgame/__init__.py index 8a2ab08..2b1b9b0 100644 --- a/konabot/plugins/idiomgame/__init__.py +++ b/konabot/plugins/idiomgame/__init__.py @@ -203,10 +203,12 @@ class IdiomGame: return TryVerifyState.VERIFIED_BUT_NO_NEXT 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: 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): if user_id not in self.score_board: @@ -377,7 +379,7 @@ async def end_game(event: BaseEvent, group_id: str): result_text += ( f"{i + 1}. " + 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()) instance.clear_score_board()