From 32df4e097df2a158b5993e8297821da8dc8b7511 Mon Sep 17 00:00:00 2001 From: derAnfaenger Date: Tue, 24 Oct 2017 13:03:41 +0200 Subject: [PATCH] tictactoe bot: Store game state in JSON-able format. --- zulip_bots/zulip_bots/bots/tictactoe/tictactoe.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/zulip_bots/zulip_bots/bots/tictactoe/tictactoe.py b/zulip_bots/zulip_bots/bots/tictactoe/tictactoe.py index 886b17c..8a0de94 100644 --- a/zulip_bots/zulip_bots/bots/tictactoe/tictactoe.py +++ b/zulip_bots/zulip_bots/bots/tictactoe/tictactoe.py @@ -282,10 +282,11 @@ class ticTacToeHandler(object): original_sender = message['sender_email'] with bot_handler.storage.state({}) as mydict: - user_game = mydict.get(original_sender) - if (not user_game) and command == "new": - user_game = TicTacToeGame(copy.deepcopy(initial_board)) - mydict[original_sender] = user_game + user_board = mydict.get(original_sender) + if (not user_board) and command == "new": + user_board = copy.deepcopy(initial_board) + mydict[original_sender] = user_board + user_game = TicTacToeGame(user_board) if user_board else None if command == 'new': if user_game and not first_time(user_game.board):