From 51f31106ba7a04672387dcf06cf084726980fe4c Mon Sep 17 00:00:00 2001 From: Drew Bednar Date: Sun, 2 May 2021 22:18:18 -0400 Subject: [PATCH] fix win logic --- python_game.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/python_game.py b/python_game.py index 1665b4e..bafa086 100644 --- a/python_game.py +++ b/python_game.py @@ -156,10 +156,13 @@ def check_rows(): def check_columns(): + global GAME_GOING column_1 = board[0] == board[3] == board[6] != '-' column_2 = board[1] == board[4] == board[7] != '-' column_3 = board[2] == board[5] == board[8] != '-' # display the winner + if any((column_1, column_2, column_3)): + GAME_GOING = False if column_1: return board[0] if column_2: @@ -170,9 +173,12 @@ def check_columns(): def check_diagonal(): + global GAME_GOING diagonal_1 = board[0] == board[4] == board[8] != '-' diagonal_2 = board[2] == board[4] == board[6] != '-' # display the winner + if diagonal_1 or diagonal_2: + GAME_GOING = False if diagonal_1: return board[0] if diagonal_2: