Exemplo n.º 1
0
    async def add(self, user: Member, author: Optional[Member] = None) -> None:
        if author is not None:
            if not self.has_joined(Player(author)):
                raise UsageException.adder_must_join(self.channel)

            # Other players cannot add you to the lobby
            # if you left on your own. (until lobby reset)
            if self.has_left_before(Player(user)):
                raise UsageException.leaver_not_added(self.channel)

        player = Player(user)
        if self.has_joined(player):
            raise UsageException.already_joined(self.channel, author
                                                is not None)

        if not self.has_open_spots():
            raise UsageException.no_overflow(self.channel)

        self.players.append(player)

        await self.show(desc=f"{player.get_name()} has Joined!")
Exemplo n.º 2
0
    async def add(self, user: Member, author: Optional[Member] = None) -> None:
        if author is not None:
            if not self.has_joined(Player(author)):
                raise UsageException.adder_must_join(self.channel)

            # Other players cannot add you to the lobby
            # if you left on your own. (until lobby reset)
            if self.has_left_before(Player(user)):
                raise UsageException.leaver_not_added(self.channel)

        player = Player(user)
        if self.has_joined(player):
            raise UsageException.already_joined(self.channel, author
                                                is not None)

        self.players.append(player)

        if self.ready_count() == 7:
            await self.broadcast_game_almost_full()

        await self.show(title=f"{player.get_name()} has joined the game!")