def new_game(game: Game, message: discord.Message) -> List[str]: if game.state == GameState.NO_GAME: game.new_game() game.add_player(message.author) game.state = GameState.WAITING return [f"A new game has been started by {message.author.name}!", "Message `.p join` to join the game."] else: messages = ["There is already a game in progress, " "you can't start a new game."] if game.state == GameState.WAITING: messages.append("It still hasn't started yet, so you can still " "message `.p join` to join that game.") return messages
def join_game(game: Game, message: discord.Message) -> List[str]: if game.state == GameState.NO_GAME: return ["No game has been started yet for you to join.", "Message `.p newgame` to start a new game."] elif game.state != GameState.WAITING and game.options["tournament"]: return ["You're not allowed to join a tournament in progress."] elif game.add_player(message.author): return [ f"{message.author.name} has joined the game!", "Message `.p join` to join the game, " "or `.p start` to start the game.", ] else: return [f"You've already joined the game {message.author.name}!"]