修改棋盘格式用于对齐

This commit is contained in:
2025-10-28 17:57:02 +08:00
parent 7d28e2e2aa
commit 57f955f837
2 changed files with 18 additions and 4 deletions

View File

@@ -251,6 +251,19 @@ if game_type == 'gomoku':
- `.gomoku cancel` - 取消挑战
- 原因WPS callback消息内容中@用户只是文本形式(如"@揭英飙"不包含user_id无法实现@用户发起对战
- 阻碍因素:无
- 状态:成功
## [2025-10-28 17:56:03]
- 已修改:
- games/gomoku_logic.py - 修复棋盘对齐问题
- 更改:
- 优化 `render_board()` 函数的格式化逻辑
- 列标题:每个字母后面加一个空格,确保与棋子列对齐
- 行号:调整前导空格,从 " {row_num} " 改为 "{row_num} "
- 棋子每个emoji后面加一个空格行尾去除多余空格
- 整体对齐确保列标题、行号、棋子三者在Markdown代码块中正确对齐
- 原因:修复用户反馈的棋盘文本对齐问题
- 阻碍因素:无
- 状态:未确认
# 最终审查

View File

@@ -252,9 +252,9 @@ def render_board(board: List[List[int]], last_move: Optional[Tuple[int, int]] =
"""
lines = []
# 列标题
col_labels = " " + " ".join([chr(ord('A') + i) for i in range(15)])
lines.append(col_labels)
# 列标题 - 使用全角空格确保对齐
col_labels = " " + "".join([chr(ord('A') + i) + " " for i in range(15)])
lines.append(col_labels.rstrip())
# 绘制棋盘
for row in range(15):
@@ -280,7 +280,8 @@ def render_board(board: List[List[int]], last_move: Optional[Tuple[int, int]] =
elif cell == 2:
row_cells.append("")
lines.append(f" {row_num} {' '.join(row_cells)}")
# 每个emoji后面加一个空格
lines.append(f"{row_num} " + "".join([cell + " " for cell in row_cells]).rstrip())
return "\n".join(lines)