tictactoe bot: Store game state in JSON-able format.
This commit is contained in:
parent
8761e47893
commit
32df4e097d
|
@ -282,10 +282,11 @@ class ticTacToeHandler(object):
|
||||||
original_sender = message['sender_email']
|
original_sender = message['sender_email']
|
||||||
|
|
||||||
with bot_handler.storage.state({}) as mydict:
|
with bot_handler.storage.state({}) as mydict:
|
||||||
user_game = mydict.get(original_sender)
|
user_board = mydict.get(original_sender)
|
||||||
if (not user_game) and command == "new":
|
if (not user_board) and command == "new":
|
||||||
user_game = TicTacToeGame(copy.deepcopy(initial_board))
|
user_board = copy.deepcopy(initial_board)
|
||||||
mydict[original_sender] = user_game
|
mydict[original_sender] = user_board
|
||||||
|
user_game = TicTacToeGame(user_board) if user_board else None
|
||||||
|
|
||||||
if command == 'new':
|
if command == 'new':
|
||||||
if user_game and not first_time(user_game.board):
|
if user_game and not first_time(user_game.board):
|
||||||
|
|
Loading…
Reference in a new issue