From efbe4c8f468d5724cd921c02540f5fc0c9f675ea Mon Sep 17 00:00:00 2001 From: spla Date: Wed, 18 Nov 2020 12:54:49 +0100 Subject: [PATCH] Now check's square is marked with red color! --- mastochess.py | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/mastochess.py b/mastochess.py index 6a23fc3..e9cea49 100644 --- a/mastochess.py +++ b/mastochess.py @@ -883,6 +883,8 @@ if __name__ == '__main__': else: + check = False + playing_user = next_move(username) board.push(chess.Move.from_uci(moving)) @@ -891,6 +893,16 @@ if __name__ == '__main__': toot_text = "@"+username + " t'ha fet escac!" + if username == white_user: + + king_square = board.king(chess.BLACK) + check = True + + else: + + king_square = board.king(chess.WHITE) + check = True + if board.is_game_over() == True: toot_text += "\nEscac i mat! \nEl guanyador és: " + "@"+username + '\n' @@ -907,11 +919,23 @@ if __name__ == '__main__': if username == white_user: - svgfile = chess.svg.board(board=board, orientation=chess.BLACK, lastmove=chess.Move.from_uci(moving)) + if check == True: + + svgfile = chess.svg.board(board=board, orientation=chess.BLACK, lastmove=chess.Move.from_uci(moving), check=board.king(chess.BLACK)) + + else: + + svgfile = chess.svg.board(board=board, orientation=chess.BLACK, lastmove=chess.Move.from_uci(moving)) else: - svgfile = chess.svg.board(board=board, orientation=chess.WHITE, lastmove=chess.Move.from_uci(moving)) + if check == True: + + svgfile = chess.svg.board(board=board, orientation=chess.WHITE, lastmove=chess.Move.from_uci(moving), check=board.king(chess.WHITE)) + + else: + + svgfile = chess.svg.board(board=board, orientation=chess.WHITE, lastmove=chess.Move.from_uci(moving)) board_file = 'games/' + str(game_id) + '_board.png'