diff --git a/danding_bot/plugins/group_horse_racing/commands.py b/danding_bot/plugins/group_horse_racing/commands.py index f4e24ef..ec07346 100644 --- a/danding_bot/plugins/group_horse_racing/commands.py +++ b/danding_bot/plugins/group_horse_racing/commands.py @@ -190,7 +190,7 @@ def _build_point_changes(room: Room, odds: dict[str, float]) -> tuple[dict[str, return point_changes, point_summaries -def _format_point_change_lines(room: Room, point_changes: dict[str, int], point_summaries: dict[str, str], name_map: dict[str, str]) -> list[str]: +async def _format_point_change_lines(room: Room, point_changes: dict[str, int], point_summaries: dict[str, str], name_map: dict[str, str]) -> list[str]: ordered_user_ids: list[str] = [] for horse in _get_horses_in_order(room): if horse.owner_id not in ordered_user_ids: @@ -204,7 +204,8 @@ def _format_point_change_lines(room: Room, point_changes: dict[str, int], point_ delta = point_changes.get(user_id, 0) summary = point_summaries.get(user_id, _describe_points_delta(delta)) display_name = name_map.get(user_id, user_id) - lines.append(f" {display_name} {delta:+d} 积分 · {summary}") + balance = await points_service.get_balance(user_id) + lines.append(f" {display_name} {delta:+d} 积分 · {summary}(余额: {balance})") return lines @@ -324,7 +325,7 @@ async def run_race_with_settlement(bot: Bot, room: Room, scope: str): bettor_name = name_map.get(b.user_id, b.user_id) result_lines.append(f" {bettor_name} 下注 {b.amount} -> 获得 {payout}") if result: - result_lines.extend(_format_point_change_lines(room, result.point_changes, result.point_change_summaries, name_map)) + result_lines.extend(await _format_point_change_lines(room, result.point_changes, result.point_change_summaries, name_map)) await _send_to_scope(bot, scope, "\n".join(result_lines)) diff --git a/danding_bot/plugins/group_horse_racing/race_engine.py b/danding_bot/plugins/group_horse_racing/race_engine.py index 9b8f67d..bf20a63 100644 --- a/danding_bot/plugins/group_horse_racing/race_engine.py +++ b/danding_bot/plugins/group_horse_racing/race_engine.py @@ -72,7 +72,9 @@ class RaceEngine: progress = min(horse.position / distance, 1.0) filled = int(progress * bar_width) bar = "█" * filled + "░" * (bar_width - filled) - pad = " " * (max_name_width - _display_width(horse.name)) + # Pad with fullwidth spaces (1 fullwidth space = 2 columns = 1 CJK char width) + diff = max_name_width - _display_width(horse.name) + pad = "\u3000" * (diff // 2) + (" " if diff % 2 else "") lines.append(f" {horse.index:02d}号 {horse.name}{pad} |{bar}| {horse.position:.1f}m") return "\n".join(lines)