fix(赛马插件): 修复进度条对齐并显示积分余额
修复赛马进度条显示时中文字符宽度计算问题,使用全角空格进行对齐 在积分结算时异步获取并显示用户当前积分余额
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user