fix win logic

master
Drew Bednar 4 years ago
parent cfd635145f
commit 51f31106ba

@ -156,10 +156,13 @@ def check_rows():
def check_columns(): def check_columns():
global GAME_GOING
column_1 = board[0] == board[3] == board[6] != '-' column_1 = board[0] == board[3] == board[6] != '-'
column_2 = board[1] == board[4] == board[7] != '-' column_2 = board[1] == board[4] == board[7] != '-'
column_3 = board[2] == board[5] == board[8] != '-' column_3 = board[2] == board[5] == board[8] != '-'
# display the winner # display the winner
if any((column_1, column_2, column_3)):
GAME_GOING = False
if column_1: if column_1:
return board[0] return board[0]
if column_2: if column_2:
@ -170,9 +173,12 @@ def check_columns():
def check_diagonal(): def check_diagonal():
global GAME_GOING
diagonal_1 = board[0] == board[4] == board[8] != '-' diagonal_1 = board[0] == board[4] == board[8] != '-'
diagonal_2 = board[2] == board[4] == board[6] != '-' diagonal_2 = board[2] == board[4] == board[6] != '-'
# display the winner # display the winner
if diagonal_1 or diagonal_2:
GAME_GOING = False
if diagonal_1: if diagonal_1:
return board[0] return board[0]
if diagonal_2: if diagonal_2:

Loading…
Cancel
Save