Exemplo n.º 1
0
    async def __run_list(self):
        coach = Coach.load_coach(str(self.message.author))
        order = False if "bydate" in self.message.content else True

        msg = LongMessage(self.client, self.message.author)
        msg.add(f"**Bank:** {coach.account.cash} coins\n")
        msg.add("**Collection**:\n")
        msg.add("-" * 65 + "")
        msg.add(
            f"{self.__class__.format_pack(coach.collection_with_count(),order)}"
        )
        msg.add("-" * 65 + "\n")
        await msg.send()
        await self.client.send_message(self.message.channel,
                                       "Collection sent to PM")
Exemplo n.º 2
0
 async def __run_newcoach(self):
     name = str(self.message.author)
     if Coach.exists(name):
         msg = LongMessage(self.client, self.message.channel)
         msg.add(
             f"**{self.message.author.mention}** account exists already\n")
         await msg.send()
     else:
         coach = Coach.load_coach(str(self.message.author))
         coach.store_coach()
         # transaction is ok and coach is saved
         msg = LongMessage(self.client, self.message.channel)
         msg.add(f"**{self.message.author.mention}** account created\n")
         msg.add(f"**Bank:** {coach.account.cash} coins")
         msg.add(f"**Rules**: <{RULES_LINK}>")
         await msg.send()
Exemplo n.º 3
0
    async def __run_genpack(self):
        if self.__class__.check_gen_command(self.cmd):
            ptype = self.args[1]
            if ptype == "player":
                team = self.args[2]
                pack = Pack(ptype, team=team)
                pack.generate()
            elif ptype == "training":
                pack = Pack(ptype)
                pack.generate()
            elif ptype == "booster":
                ptype = "booster_budget" if len(
                    self.args) < 3 else f"booster_{self.args[2]}"
                pack = Pack(ptype)
                pack.generate()

            # add error handling eventually
            coach = Coach.load_coach(str(self.message.author))
            t = Transaction(pack, pack.price)
            try:
                coach.make_transaction(t)
            except TransactionError as e:
                await self.transaction_error(e)
                return
            else:
                # transaction is ok and coach is saved
                msg = LongMessage(self.client, self.message.channel)
                msg.add(
                    f"**{pack.description()}** for **{self.message.author}** - **{pack.price}** coins:\n"
                )
                msg.add(f"{self.__class__.format_pack(pack.cards)}\n")
                msg.add(f"**Bank:** {coach.account.cash} coins")
                await msg.send()
                # export
                ImperiumSheet.store_all_cards()
        else:
            await self.client.send_message(self.message.channel,
                                           self.__class__.gen_help())