Example #1
0
    async def discard(self, ctx, card:int):
        """Discard a card you want to get rid of with this command. If you want to throw a fake away, make sure it's in the free slots"""
        
        user = User(ctx.author.id)
        try:
            card = Card(card)
        except CardNotFound:
            return await ctx.send('This card does not exist!')

        if not user.has_any_card(card.id):
            return await ctx.send('You are not in possesion of this card!')

        if card.id == 0:
            return await ctx.send("You cannot discard this card!")

        view = ConfirmButton(ctx.author.id, timeout=20)
        msg = await ctx.send(f"Do you really want to throw this card away? (if you want to throw a fake aware, make sure it's in the free slots (unless it's the only copy you own. You can switch cards between free and restricted slots with `{self.client.command_prefix(self.client, ctx.message)[2]}swap <card_id>`)", view=view, allowed_mentions=discord.AllowedMentions.none())
        await view.wait()
        await view.disable(msg)

        if not view.value:
            if view.timed_out:
                return await ctx.send(f'Timed out!')
            else:
                return await ctx.send(f"Successfully canceled!")

        try:
            user.remove_card(card.id, remove_fake=True, restricted_slot=False)
            # essentially here it first looks for fakes in your free slots and tried to remove them. If it doesn't find any fakes in the free slots, it will remove the first match of the card it finds in free or restricted slots
        except NoMatches:
            user.remove_card(card.id)
        await ctx.send(f'Successfully thrown away card No. `{card.id}`')
Example #2
0
File: cards.py Project: Kile/Killua
    async def exec(self, card_id:int) -> None:
        user = User(self.ctx.author.id)

        if not user.has_any_card(card_id, False):
            raise CheckFailure('Seems like you don\'t own this card You already need to own a (non-fake) copy of the card you want to duplicate')

        self._is_maxed_check(card_id)
        user.remove_card(self.id)
        user.add_card(card_id, clone=True)

        await self.ctx.send(f'Successfully added another copy of {card_id} to your book!') 
Example #3
0
    async def cardinfo(self, ctx, card:int):
        """Check card info out about any card you own"""
        try:
            c = Card(card)
        except CardNotFound:
            return await ctx.send("Invalid card")

        author = User(ctx.author.id)
        if not author.has_any_card(c.id):
            return await ctx.send("You don't own a copy of this card so you can't view it's infos")

        embed = c._get_analysis_embed(c.id)
        if c.type == "spell" and c.id not in [*DEF_SPELLS, *VIEW_DEF_SPELLS]:
            card_class = [c for c in Card.__subclasses__() if c.__name__ == f"Card{card}"][0]
            usage = f"`{self.client.command_prefix(self.client, ctx.message)[2]}use {card} " + " ".join([f"[{k}: {v.__name__}]" for k, v in card_class.exec.__annotations__.items() if not str(k) == "return"]) + "`"
            embed.add_field(name="Usage", value=usage, inline=False)

        await ctx.send(embed=embed)
Example #4
0
    async def _check(self, ctx, card_id:int):
        """Lets you see how many copies of the specified card are fakes"""
        try:
            Card(card_id)
        except CardNotFound:
            return await ctx.send("Invalid card")

        author = User(ctx.author.id)

        if not author.has_any_card(card_id, only_allow_fakes=True):
            return await ctx.send("You don't any copies of this card which are fake")

        text = ""

        if len([x for x in author.rs_cards if x[1]["fake"] is True and x[0] == card_id]) > 0:
            text += f"The card in your restricted slots is fake"

        if (fs:= len([x for x in author.fs_cards if x[1]["fake"] is True and x[0] == card_id])) > 0:
            text += (" and " if len(text) > 0 else "") + f"{fs} cop{'ies' if fs > 1 else 'y'} of this card in your free slots {'are' if fs > 1 else 'is'} fake"
Example #5
0
File: cards.py Project: Kile/Killua
 def _has_any_card(self, card_id:int, user:User) -> None:
     if not user.has_any_card(card_id):
         raise CheckFailure("The specified user doesn't have this card")