Ejemplo n.º 1
0
    async def creategame(self, ctx: CustomContext):
        """
        Creates a game of mafia in this channel.
        To join an existing game, use the `join` command.
        Hosts may delete running games using the `delete` command.
        """
        if ctx.channel.id in self.bot.games:
            return await ctx.send('A game of mafia is already running '
                                  'in this channel.')

        # prevent the user from joining if they are already in a different game
        other_games = list(
            filter(lambda game: ctx.author in game.players,
                   self.bot.games.values()))
        if len(other_games) > 0:
            other_game = other_games[0]
            return await ctx.send(
                'You are already playing another game in the channel {} ({})'.
                format(other_game.channel.mention,
                       other_game.channel.guild.name))

        new_game = Game.create(ctx, self.bot)
        self.bot.games[ctx.channel.id] = new_game
        return await ctx.send('Started a game of mafia in '
                              f'{ctx.message.channel.mention}, '
                              f'hosted by **{ctx.message.author}**')
Ejemplo n.º 2
0
 async def creategame(self, ctx: CustomContext):
     """
     Creates a game of mafia in this server.
     To join an existing game, use the `join` command.
     Hosts may delete running games using the `delete` command.
     """
     if ctx.guild.id in self.bot.games:
         return await ctx.send('A game of mafia is already running '
                               'in this server.')
     new_game = Game.create(ctx, self.bot)
     self.bot.games[ctx.guild.id] = new_game
     return await ctx.send('Started a game of mafia in '
                           f'{ctx.message.channel.mention}, '
                           f'hosted by **{ctx.message.author}**')