From 8e5c714dbf959d3c132913065cf3442176b3b98a Mon Sep 17 00:00:00 2001 From: DO97 Date: Sun, 16 Jun 2019 17:49:54 +0200 Subject: [PATCH] Maximum players error (join and start) --- bot.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/bot.py b/bot.py index cdd2ae4..8ef5faf 100644 --- a/bot.py +++ b/bot.py @@ -32,7 +32,7 @@ import simple_commands from actions import do_skip, do_play_card, do_draw, do_call_bluff, start_player_countdown from config import WAITING_TIME, DEFAULT_GAMEMODE, MIN_PLAYERS from errors import (NoGameInChatError, LobbyClosedError, AlreadyJoinedError, - NotEnoughPlayersError, DeckEmptyError) + NotEnoughPlayersError, DeckEmptyError, MaxPlayersError) from internationalization import _, __, user_locale, game_locales from results import (add_call_bluff, add_choose_color, add_draw, add_gameinfo, add_no_game, add_not_started, add_other_cards, add_pass, @@ -163,6 +163,11 @@ def join_game(bot, update): "new players to join."), reply_to_message_id=update.message.message_id) + except MaxPlayersError: + send_async(bot, chat.id, + text=_("You can't join the game due to the maximum players limit"), + reply_to_message_id=update.message.message_id) + else: send_async(bot, chat.id, text=_("Joined the game"), @@ -369,6 +374,10 @@ def start_game(bot, update, args, job_queue): text=__("At least {minplayers} players must /join the game " "before you can start it").format(minplayers=MIN_PLAYERS)) + elif len(game.players) > MAX_PLAYERS: + send_async(bot, chat.id, + text=__("No more than {maxplayers} players can join the game").format(maxplayers=MAX_PLAYERS)) + else: # Starting a game game.start()