From a6ca40b4b7a11ddd20c6433196f7642d50fef508 Mon Sep 17 00:00:00 2001 From: spla Date: Fri, 20 Nov 2020 15:06:14 +0100 Subject: [PATCH] Solve #5 issue --- mastochess.py | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/mastochess.py b/mastochess.py index 50c9ebe..2ebbdfa 100644 --- a/mastochess.py +++ b/mastochess.py @@ -239,6 +239,8 @@ def current_games(): game_link_lst = [] + next_move_lst = [] + try: conn = None @@ -247,7 +249,7 @@ def current_games(): cur = conn.cursor() - cur.execute("select white_user, black_user, chess_status, chess_link from games where not finished") + cur.execute("select white_user, black_user, chess_status, chess_link, next_move from games where not finished") rows = cur.fetchall() @@ -267,9 +269,11 @@ def current_games(): game_link_lst.append(row[3]) + next_move_lst.append(row[4]) + cur.close() - return (player1_name_lst, player2_name_lst, game_status_lst, game_link_lst) + return (player1_name_lst, player2_name_lst, game_status_lst, game_link_lst, next_move_lst) except (Exception, psycopg2.DatabaseError) as error: @@ -1199,7 +1203,7 @@ if __name__ == '__main__': elif query_word == 'jocs': - player1_name_lst, player2_name_lst, game_status_lst, game_link_lst = current_games() + player1_name_lst, player2_name_lst, game_status_lst, game_link_lst, next_move_lst = current_games() if len(player1_name_lst) > 0: @@ -1214,7 +1218,13 @@ if __name__ == '__main__': else: - toot_text += "\n" + player1_name_lst[i] + " / " + player2_name_lst[i] + " (en joc)" + "\n" + if next_move_lst[i] == player1_name_lst[i]: + + toot_text += "\n*" + player1_name_lst[i] + " / " + player2_name_lst[i] + " (en joc)" + "\n" + + else: + + toot_text += "\n" + player1_name_lst[i] + " / *" + player2_name_lst[i] + " (en joc)" + "\n" if game_link_lst[i] != None: