Ejemplo n.º 1
0
    async def ban(self, arg, captain):
        if self.order[self.index] != "ban":
            await captain.user.send(
                "This is a picking phase; please type !pick to pick a champion,"
                " or !exit to exit the draft.")
        else:
            champ = await self.vChampBans(arg, captain)
            if champ is None:
                return

            async def x(string):
                await captain.user.delete()
                await captain.user.send(string,
                                        embed=self.createDraftMessage(
                                            captain,
                                            self.otherCaptain(captain)),
                                        deletionInterval="command")

            if not captain.hasPBThisPhase:
                captain.bans.append(champ)
                captain.hasPBThisPhase = True
                if not await self.tryAdvance():
                    await x("Banned " + helpers.fullCapitalize(champ) + "!")
            else:
                captain.bans[-1] = champ
                await x("Changed ban to " + helpers.fullCapitalize(champ) +
                        "!")
Ejemplo n.º 2
0
    def createDraftMessage(self,
                           lclCOne,
                           lclCTwo,
                           nameBothCaptains=False,
                           includeIDFooter=False):
        embed = discord.Embed(color=discord.Colour.from_rgb(122, 27, 68))
        lcls = (lclCOne, lclCTwo)
        remMaps = self.remainingMaps

        field1Value = "Bans\n"
        field2And3Values = ["", ""]

        field1Value, field2And3Values = self.draftMsgIter(
            int(self.totalMaps / 2), lcls, "bans", field1Value,
            field2And3Values)
        self.draftMsgNames(embed, lcls, field1Value, field2And3Values,
                           nameBothCaptains)

        bottomFieldName = "Remaining Maps" if len(
            remMaps) > 1 else "Chosen Map"
        remainingMapsString = ""
        for _map in remMaps:
            if len(remainingMapsString) > 35:
                if len(remainingMapsString.splitlines()[-1]) > 35:
                    remainingMapsString += "\n"
            remainingMapsString += helpers.fullCapitalize(_map) + ", "
        if len(remMaps) == 1: remainingMapsString = remainingMapsString[:-2]
        embed.add_field(name=bottomFieldName,
                        value=remainingMapsString,
                        inline=False)
        if self.id is not None and includeIDFooter:
            embed.set_footer(text="Match ID " + str(self.id))
        return embed
Ejemplo n.º 3
0
 async def ban(self, arg, captain):
     # check if captain the currently active captain
     if captain != self.currentCaptain:
         await captain.user.send(
             "You are not the currently active captain; "
             "please wait for the other captain to ban a map.")
         return
     # check if ban is valid
     brMap = await self.vMapBan(arg, captain)
     if brMap is None:
         return
     captain.bans.append(brMap)
     await captain.user.send("Banned " + helpers.fullCapitalize(brMap) +
                             "!")
     await self.advance()
Ejemplo n.º 4
0
    def draftMsgIter(self, totalPB, lcls, listType, fieldOneValue,
                     field2And3Values):
        for i in range(totalPB):
            fieldOneValue += "\n"
            for n, lclCaptain in enumerate(lcls):
                localList = None
                if listType == "picks": localList = lclCaptain.picks
                if listType == "bans": localList = lclCaptain.bans
                if listType == "globalBans":
                    localList = lclCaptain.globalBans  # there has to be a better way todo this

                if len(localList) > i:
                    field2And3Values[n] += helpers.fullCapitalize(
                        localList[i]) + "\n"
                else:
                    field2And3Values[n] += "-----\n"
        return fieldOneValue, field2And3Values