TicTacToe: Use simple comparison instead of overly-complex first_time().

This commit is contained in:
neiljp (Neil Pilgrim) 2017-12-09 21:34:26 -08:00 committed by showell
parent d10601b554
commit 6d4b205595

View file

@ -253,11 +253,6 @@ class TicTacToeGame(object):
return ("next_turn", return_string) return ("next_turn", return_string)
# ------------------------------------- # -------------------------------------
flat_initial = sum(initial_board, [])
def first_time(board):
flat = sum(board, [])
return flat == flat_initial
class ticTacToeHandler(object): class ticTacToeHandler(object):
''' '''
You can play tic-tac-toe in a private message with You can play tic-tac-toe in a private message with
@ -291,7 +286,7 @@ class ticTacToeHandler(object):
user_board = copy.deepcopy(initial_board) user_board = copy.deepcopy(initial_board)
user_game = TicTacToeGame(user_board) user_game = TicTacToeGame(user_board)
move = "new" move = "new"
if not first_time(user_game.board): if user_game.board != initial_board:
return_content = "You're already playing a game! Type **@tictactoe help** or **@ttt help** to see valid inputs." return_content = "You're already playing a game! Type **@tictactoe help** or **@ttt help** to see valid inputs."
else: else:
return_content = "Welcome to tic-tac-toe! You'll be x's and I'll be o's. Your move first!\n" return_content = "Welcome to tic-tac-toe! You'll be x's and I'll be o's. Your move first!\n"