Now check's square is marked with red color!

This commit is contained in:
spla 2020-11-18 12:54:49 +01:00
pare 7e8bfbdb63
commit efbe4c8f46

Veure arxiu

@ -883,6 +883,8 @@ if __name__ == '__main__':
else: else:
check = False
playing_user = next_move(username) playing_user = next_move(username)
board.push(chess.Move.from_uci(moving)) board.push(chess.Move.from_uci(moving))
@ -891,6 +893,16 @@ if __name__ == '__main__':
toot_text = "@"+username + " t'ha fet escac!" 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: if board.is_game_over() == True:
toot_text += "\nEscac i mat! \nEl guanyador és: " + "@"+username + '\n' toot_text += "\nEscac i mat! \nEl guanyador és: " + "@"+username + '\n'
@ -907,11 +919,23 @@ if __name__ == '__main__':
if username == white_user: 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: 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' board_file = 'games/' + str(game_id) + '_board.png'