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
1 changed files with 5 additions and 2 deletions

View File

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