diff --git a/.tasks/2025-10-28_1_gomoku.md b/.tasks/2025-10-28_1_gomoku.md index fa19b4b..9fad4f1 100644 --- a/.tasks/2025-10-28_1_gomoku.md +++ b/.tasks/2025-10-28_1_gomoku.md @@ -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代码块中正确对齐 +- 原因:修复用户反馈的棋盘文本对齐问题 +- 阻碍因素:无 - 状态:未确认 # 最终审查 diff --git a/games/gomoku_logic.py b/games/gomoku_logic.py index f20e547..26fa27c 100644 --- a/games/gomoku_logic.py +++ b/games/gomoku_logic.py @@ -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)