release the lock at the right time

This commit is contained in:
JerryXiao 2019-01-19 15:11:12 +08:00
parent 9d3aa65154
commit 036550eb42
Signed by: Jerry
GPG key ID: 9D9CE43650FF2BAA

View file

@ -347,15 +347,18 @@ def handle_button_click(bot, update):
if board.state == 0: if board.state == 0:
mmap = None mmap = None
board.move((row, col)) board.move((row, col))
if board.state != 1:
game.stopped = True
game.lock.release() 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: else:
mmap = deepcopy(board.map) mmap = deepcopy(board.map)
board.move((row, col)) board.move((row, col))
if board.state != 1:
game.stopped = True
game.lock.release() game.lock.release()
if board.state != 1:
game.stopped = True
# if this is the first move, there's no mmap # if this is the first move, there's no mmap
if mmap is not None: if mmap is not None:
game.save_action(user, (row, col)) game.save_action(user, (row, col))