fix bugs
This commit is contained in:
parent
036550eb42
commit
c2b1b81b2b
1 changed files with 10 additions and 16 deletions
14
tgmsbot.py
14
tgmsbot.py
|
@ -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()
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue