This commit is contained in:
JerryXiao 2019-01-19 17:06:30 +08:00
parent 036550eb42
commit c2b1b81b2b
Signed by: Jerry
GPG key ID: 9D9CE43650FF2BAA

View file

@ -346,21 +346,12 @@ def handle_button_click(bot, update):
board = game.board
if board.state == 0:
mmap = None
board.move((row, col))
if board.state != 1:
game.stopped = True
game.lock.release()
game.save_action(user, (row, col))
update_keyboard_request(bot, bhash, game, chat_id, msg.message_id)
else:
mmap = deepcopy(board.map)
board.move((row, col))
if board.state != 1:
game.stopped = True
game.lock.release()
# if this is the first move, there's no mmap
if mmap is not None:
game.save_action(user, (row, col))
if not array_equal(board.map, mmap):
update_keyboard_request(bot, bhash, game, chat_id, msg.message_id)
@ -399,9 +390,12 @@ def handle_button_click(bot, update):
logger.debug('timeout sending report for game {}'.format(bhash))
if game.stopped:
game_manager.remove(bhash)
elif mmap is not None and (not array_equal(board.map, mmap)):
elif mmap is None or (not array_equal(board.map, mmap)):
game.lock.release()
game.save_action(user, (row, col))
update_keyboard_request(bot, bhash, game, chat_id, msg.message_id)
else:
game.lock.release()