Skip to content

Commit 8cc3651

Browse files
committed
对「四字记谱法」中,两列存在超过1个「兵」的情况的另一种记谱格式进行兼容
1 parent fc0004c commit 8cc3651

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

cchess/__init__.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2244,7 +2244,18 @@ def get_multiply_pawn_square(board: Board, color, rank_notation, pawn_column=Non
22442244
if multi_pawns_col_number == 0:
22452245
raise ValueError("未找到存在多个兵(卒)的列")
22462246
if multi_pawns_col_number > 1 and pawn_column is None:
2247-
raise ValueError("记号存在歧义(未指明兵(卒)所在列)")
2247+
# 可能是新的兵(卒)记法
2248+
count = ['一', '二', '三', '四', '五'].index(rank_notation)
2249+
for i, num in enumerate(reversed(pawn_nums) if color else pawn_nums):
2250+
if num >= 2:
2251+
if count >= num:
2252+
count -= num
2253+
else:
2254+
pawn_column = 8 - i if color else i
2255+
rank_notation = (['前', '后'] if num == 2 else ['前', '中', '后'])[count]
2256+
break
2257+
else:
2258+
raise ValueError("旧记法:记号存在歧义(未指明兵(卒)所在列) 或 新记法:记号中兵(卒)的数量超出实际兵(卒)的数量")
22482259
if multi_pawns_col_number == 1 and pawn_column is not None:
22492260
raise ValueError("记号不规范(无需指明列号)")
22502261
if rank_notation == '前':

0 commit comments

Comments
 (0)