From c22e91eafadc7780ef62aa9d54c78e0b5d0a72ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jannes=20H=C3=B6ke?= Date: Sat, 23 Apr 2016 22:30:21 +0200 Subject: [PATCH] allow leaving game if two or less players are in game --- bot.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/bot.py b/bot.py index 05092d5..533d01c 100644 --- a/bot.py +++ b/bot.py @@ -139,7 +139,11 @@ def leave_game(bot, update): game = gm.chatid_game[chat_id] user = update.message.from_user - if game.current_player.user.id == user.id: + if (game.current_player is game.current_player.next or + game.current_player is game.current_player.next.next): + send_async(bot, chat_id, text="Game ended!") + gm.end_game(chat_id) + elif game.current_player.user.id == user.id: send_async(bot, chat_id, text="You can't leave the game if it's your turn") else: