|
@@ -674,18 +674,14 @@ def chess_game_stats(chess, id):
|
|
|
elif chess.is_check(id):
|
|
|
text = f"Шах!\n{text}"
|
|
|
|
|
|
+ draw = chess.draw(id)
|
|
|
+ if draw:
|
|
|
+ text = f"Ничья: {str(e)}\n{text}"
|
|
|
+
|
|
|
return text
|
|
|
|
|
|
|
|
|
def chess_game_over(chess, id, e):
|
|
|
- if chess.is_draw(id):
|
|
|
- chess.clear(id)
|
|
|
-
|
|
|
- return [
|
|
|
- chess_render(chess, id, False),
|
|
|
- f"Ничья: {str(e)}",
|
|
|
- ]
|
|
|
-
|
|
|
return [
|
|
|
chess_render(chess, id, False),
|
|
|
f"Конец игры: {str(e)}",
|
|
@@ -719,6 +715,10 @@ async def chess_from_handler(chess, id, moves):
|
|
|
if chess.is_check(id):
|
|
|
reply.append("Шах!")
|
|
|
|
|
|
+ draw = chess.draw(id)
|
|
|
+ if draw:
|
|
|
+ reply.append(f"Ничья: {str(draw)}")
|
|
|
+
|
|
|
if isinstance(id, str):
|
|
|
reply.append(f"Ход {'белых' if chess.turn(id) else 'чёрных'}.")
|
|
|
|
|
@@ -756,6 +756,10 @@ async def chess_move_handler(chess, id, move):
|
|
|
if chess.is_check(id):
|
|
|
reply.append("Шах!")
|
|
|
|
|
|
+ draw = chess.draw(id)
|
|
|
+ if draw:
|
|
|
+ reply.append(f"Ничья: {str(draw)}")
|
|
|
+
|
|
|
return reply
|
|
|
|
|
|
|
|
@@ -774,8 +778,16 @@ async def chess_undo_handler(chess, id):
|
|
|
except GameOver as e:
|
|
|
return chess_game_over(chess, id, e)
|
|
|
|
|
|
- return ["Последний ход отменён.", svg2png(chess.svg(id))]
|
|
|
+ reply = ["Последний ход отменён.", svg2png(chess.svg(id))]
|
|
|
+
|
|
|
+ if chess.is_check(id):
|
|
|
+ reply.append("Шах!")
|
|
|
+
|
|
|
+ draw = chess.draw(id)
|
|
|
+ if draw:
|
|
|
+ reply.append(f"Ничья: {str(draw)}")
|
|
|
|
|
|
+ return reply
|
|
|
|
|
|
async def chess_skip_handler(chess, id):
|
|
|
is_group = isinstance(id, str)
|
|
@@ -795,6 +807,10 @@ async def chess_skip_handler(chess, id):
|
|
|
if chess.is_check(id):
|
|
|
reply.append("Шах!")
|
|
|
|
|
|
+ draw = chess.draw(id)
|
|
|
+ if draw:
|
|
|
+ reply.append(f"Ничья: {str(e)}")
|
|
|
+
|
|
|
return reply
|
|
|
|
|
|
|
|
@@ -816,6 +832,10 @@ async def chess_pass_handler(chess, id):
|
|
|
if chess.is_check(id):
|
|
|
reply.append("Шах!")
|
|
|
|
|
|
+ draw = chess.draw(id)
|
|
|
+ if draw:
|
|
|
+ reply.append(f"Ничья: {str(e)}")
|
|
|
+
|
|
|
return reply
|
|
|
|
|
|
|
|
@@ -832,6 +852,10 @@ async def chess_board_handler(chess, id):
|
|
|
if chess.is_check(id):
|
|
|
reply.append("Шах!")
|
|
|
|
|
|
+ draw = chess.draw(id)
|
|
|
+ if draw:
|
|
|
+ reply.append(f"Ничья: {str(e)}")
|
|
|
+
|
|
|
if isinstance(id, str):
|
|
|
reply.append(f"Ход {'белых' if chess.turn(id) else 'чёрных'}.")
|
|
|
|
|
@@ -872,6 +896,10 @@ async def chess_set_handler(chess, id, moves):
|
|
|
if chess.is_check(id):
|
|
|
reply.append("Шах!")
|
|
|
|
|
|
+ draw = chess.draw(id)
|
|
|
+ if draw:
|
|
|
+ reply.append(f"Ничья: {str(e)}")
|
|
|
+
|
|
|
if isinstance(id, str):
|
|
|
reply.append(f"Ход {'белых' if chess.turn(id) else 'чёрных'}.")
|
|
|
|