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,24 +346,15 @@ def handle_button_click(bot, update):
board = game.board board = game.board
if board.state == 0: if board.state == 0:
mmap = None 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: else:
mmap = deepcopy(board.map) mmap = deepcopy(board.map)
board.move((row, col)) board.move((row, col))
if board.state != 1: if board.state != 1:
game.stopped = True game.stopped = True
game.lock.release() game.lock.release()
game.save_action(user, (row, col))
# if this is the first move, there's no mmap if not array_equal(board.map, mmap):
if mmap is not None: update_keyboard_request(bot, bhash, game, chat_id, msg.message_id)
game.save_action(user, (row, col))
if not array_equal(board.map, mmap):
update_keyboard_request(bot, bhash, game, chat_id, msg.message_id)
(s_op, s_is, s_3bv) = board.gen_statistics() (s_op, s_is, s_3bv) = board.gen_statistics()
ops_count = game.actions_sum() ops_count = game.actions_sum()
ops_list = game.get_actions() ops_list = game.get_actions()
@ -399,9 +390,12 @@ def handle_button_click(bot, update):
logger.debug('timeout sending report for game {}'.format(bhash)) logger.debug('timeout sending report for game {}'.format(bhash))
if game.stopped: if game.stopped:
game_manager.remove(bhash) 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)) game.save_action(user, (row, col))
update_keyboard_request(bot, bhash, game, chat_id, msg.message_id) update_keyboard_request(bot, bhash, game, chat_id, msg.message_id)
else:
game.lock.release()