From f7afe48680c10f236a7c8503c9d6722405054173 Mon Sep 17 00:00:00 2001 From: MixBadGun <1059129006@qq.com> Date: Sun, 19 Oct 2025 18:36:27 +0800 Subject: [PATCH] =?UTF-8?q?=E7=B2=BE=E5=BA=A6=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- konabot/plugins/idiomgame/__init__.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) 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()