allow leaving game if two or less players are in game

This commit is contained in:
Jannes Höke 2016-04-23 22:30:21 +02:00
parent ded3c7684b
commit c22e91eafa

6
bot.py
View file

@ -139,7 +139,11 @@ def leave_game(bot, update):
game = gm.chatid_game[chat_id] game = gm.chatid_game[chat_id]
user = update.message.from_user 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, send_async(bot, chat_id,
text="You can't leave the game if it's your turn") text="You can't leave the game if it's your turn")
else: else: