コード例 #1
0
    async def card(self, ctx, item: int):
        """Buy a card from the shop with this command"""

        shop_data = shop.find_one({'_id': 'daily_offers'})
        shop_items = shop_data['offers']
        user = User(ctx.author.id)

        try:
            card = Card(item)
        except CardNotFound:
            return await ctx.send(
                f'This card is not for sale at the moment! Find what cards are in the shop with `{self.client.command_prefix(self.client, ctx.message)[2]}shop`',
                allowed_mentions=discord.AllowedMentions.none())

        if not item in shop_items:
            return await ctx.send(
                f'This card is not for sale at the moment! Find what cards are in the shop with `{self.client.command_prefix(self.client, ctx.message)[2]}shop`',
                allowed_mentions=discord.AllowedMentions.none())

        if not shop_data['reduced'] is None:
            if shop_items.index(
                    card.id) == shop_data['reduced']['reduced_item']:
                price = int(PRICES[card.rank] -
                            int(PRICES[card.rank] *
                                (shop_data['reduced']['reduced_by'] / 100)))
            else:
                price = PRICES[card.rank]
        else:
            price = PRICES[card.rank]

        if len(card.owners) >= (card.limit * ALLOWED_AMOUNT_MULTIPLE):
            return await ctx.send(
                'Unfortunately the global maximal limit of this card is reached! Someone needs to sell their card for you to buy one or trade/give it to you'
            )

        if len(user.fs_cards) >= FREE_SLOTS:
            return await ctx.send(
                f'Looks like your free slots are filled! Get rid of some with `{self.client.command_prefix(self.client, ctx.message)[2]}sell`',
                allowed_mentions=discord.AllowedMentions.none())

        if user.jenny < price:
            return await ctx.send(
                f'I\'m afraid you don\'t have enough Jenny to buy this card. Your balance is {user.jenny} while the card costs {price} Jenny'
            )
        try:
            user.add_card(item)
        except Exception as e:
            if isinstance(e, CardLimitReached):
                return await ctx.send(
                    f'Free slots card limit reached (`{FREE_SLOTS}`)! Get rid of one card in your free slots to add more cards with `{self.client.command_prefix(self.client, ctx.message)[2]}sell <card>`',
                    allowed_mentions=discord.AllowedMentions.none())
            else:
                print(e)

        user.remove_jenny(
            price
        )  #Always putting substracting points before giving the item so if the payment errors no item is given
        return await ctx.send(
            f'Successfully bought card number `{card.id}` {card.emoji} for {price} Jenny. Check it out in your inventory with `{self.client.command_prefix(self.client, ctx.message)[2]}book`!',
            allowed_mentions=discord.AllowedMentions.none())
コード例 #2
0
ファイル: cards.py プロジェクト: Kile/Killua
    async def exec(self) -> None:
        author = User(self.ctx.author.id)
        self._is_full_check(author)

        target = random.choice([x['_id'] for x in items.find({'type': 'normal', "available": True}) if x['rank'] != 'SS' and x["_id"] != 0]) # random card for lottery
        author.remove_card(self.id)
        self._is_maxed_check(target)
        author.add_card(target)

        await self.ctx.send(f'Successfully added card No. {target} to your inventory')
コード例 #3
0
ファイル: cards.py プロジェクト: Kile/Killua
    async def exec(self, card_id:int) -> None:
        self._is_valid_card_check(card_id)

        if card_id > 99 or card_id < 1:
            raise CheckFailure(f"You can only use \"{self.name}\" on a card with id between 1 and 99!")

        author = User(self.ctx.author.id)

        author.remove_card(self.id)
        author.add_card(card_id, True)
        await self.ctx.send(f'Created a fake of card No. {card_id}! Make sure to remember that it\'s a fake, fakes don\'t count towards completion of the album')
コード例 #4
0
ファイル: cards.py プロジェクト: Kile/Killua
    async def exec(self, member:discord.Member) -> None:
        author = User(self.ctx.author.id)
        other = User(member.id)
        author.remove_card(self.id)

        self._has_cards_check(other.rs_cards, f" in their restricted slots!", uses_up=True)
        card = random.choice([x for x in other.rs_cards if x[0] != 0])
        self._is_maxed_check(card[0])

        author.add_card(card[0], card[1]["fake"], True)
        await self.ctx.send(f'Successfully added another copy of card No. {card[0]} to your book! This card is {"not" if card[1]["fake"] is False else ""} a fake!')
コード例 #5
0
ファイル: cards.py プロジェクト: 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!') 
コード例 #6
0
ファイル: cards.py プロジェクト: Kile/Killua
    async def exec(self, member:discord.Member):
        self._permission_check(self.ctx, member)

        author = User(self.ctx.author.id)
        other = User(member.id)

        self._has_cards_check(other.rs_cards, " in their restricted slots")

        target_card = random.choice([x[0] for x in other.rs_cards if x[0] != 0])
        author.remove_card(self.id)
        await self._attack_defense_check(self.ctx, other, target_card)

        removed_card = other.remove_card(target_card, restricted_slot=True)
        author.add_card(target_card, removed_card[1]["fake"])
        await self.ctx.send(f'Successfully stole card number `{target_card}` from `{member}`!')
コード例 #7
0
ファイル: cards.py プロジェクト: Kile/Killua
    async def exec(self, member:discord.Member, card_id:int) -> None:
        self._permission_check(self.ctx, member)

        if card_id == 0:
            raise CheckFailure("You cannot steal card 0")

        author = User(self.ctx.author.id)
        other = User(member.id)

        self._has_any_card(card_id, other)
        author.remove_card(self.id)
        await self._attack_defense_check(self.ctx, other, card_id)

        stolen = other.remove_card(card_id)
        author.add_card(stolen[0], stolen[1]["fake"])
        await self.ctx.send(f"Stole card number {card_id} successfully!")
コード例 #8
0
ファイル: cards.py プロジェクト: Kile/Killua
    async def exec(self, member:discord.Member) -> None:
        self._permission_check(self.ctx, member)

        author = User(self.ctx.author.id)
        other = User(member.id)

        self._has_cards_check(other.all_cards)
        self._has_other_card_check(author.all_cards)

        target_card = random.choice([x[0] for x in other.all_cards if x[0] != 1008 and x[0] != 0])
        await self._attack_defense_check(self.ctx, other, target_card)

        author.remove_card(self.id)
        removed_card_other = other.remove_card(target_card)
        removed_card_author = author.remove_card(random.choice([x[0] for x in author.all_cards if x[0] != 0]))
        other.add_card(removed_card_author[0], removed_card_author[1]["fake"])
        author.add_card(removed_card_other[0], removed_card_other[1]["fake"])

        await self.ctx.send(f'Successfully swapped cards! Gave {member} the card `{removed_card_author[0]}` and took card number `{removed_card_other[0]}` from them!')
コード例 #9
0
    async def gain(self, ctx, t:str, item:str):
        """An owner restricted command allowing the user to obtain any card or amount of jenny or any lootbox"""
        user = User(ctx.author.id)
        if not t.lower() in ["jenny", "card", "lootbox"]:
            return await ctx.send(f'You need to provide a valid type! `{self.client.command_prefix(self.client, ctx.message)[2]}gain <jenny/card/lootbox> <amount/id>`', allowed_mentions=discord.AllowedMentions.none())
        if t.lower() == 'card':
            try:
                item = int(item)
                card = Card(item)
            except CardNotFound:
                return await ctx.send('Invalid card id')
            if card.id == 0:
                return await ctx.send("No")
            if len(card.owners) >= card.limit * ALLOWED_AMOUNT_MULTIPLE:
                return await ctx.send('Sorry! Global card limit reached!')
            if len(user.fs_cards) >= FREE_SLOTS and (item > 99 or item in [x[0] for x in user.rs_cards]):
                return await ctx.send('Seems like you have no space left in your free slots!')
            user.add_card(item)
            return await ctx.send(f'Added card "{card.name}" to your inventory')

        if t.lower() == 'jenny':
            if not item.isdigit():
                return await ctx.send('Please provide a valid amount of jenny!')
            item = int(item)
            if item < 1:
                return await ctx.send('Please provide a valid amount of jenny!')
            if item > 69420:
                return await ctx.send('Be reasonable.')
            user.add_jenny(item)
            return await ctx.send(f'Added {item} Jenny to your account')

        if t.lower() == "lootbox":
            if not item.isdigit() or not int(item) in list(LOOTBOXES.keys()):
                return await ctx.send("Invalid lootbox!")
            user.add_lootbox(int(item))
            return await ctx.send(f"Done! Added lootbox \"{LOOTBOXES[int(item)]['name']}\" to your inventory")