Exemple #1
0
 async def merchall(self,
                    ctx,
                    maxstat: IntFromTo(0, 60) = 60,
                    minstat: IntFromTo(0, 60) = 0):
     _("""Sells all your non-equipped items for their value.""")
     async with self.bot.pool.acquire() as conn:
         money, count = await conn.fetchval(
             "SELECT (sum(value), count(value)) FROM inventory i JOIN allitems ai ON (i.item=ai.id) WHERE ai.owner=$1 AND i.equipped IS FALSE AND ai.armor+ai.damage BETWEEN $2 AND $3;",
             ctx.author.id,
             minstat,
             maxstat,
         )
         if count == 0:
             return await ctx.send(_("Nothing to merch."))
         if not await ctx.confirm(
                 _("You are about to sell **{count} items!**\nAre you sure you want to do this?"
                   ).format(count=count)):
             return
         async with conn.transaction():
             await conn.execute(
                 "DELETE FROM allitems ai USING inventory i WHERE ai.id=i.item AND ai.owner=$1 AND i.equipped IS FALSE AND ai.armor+ai.damage BETWEEN $2 AND $3;",
                 ctx.author.id,
                 minstat,
                 maxstat,
             )
             await conn.execute(
                 'UPDATE profile SET "money"="money"+$1 WHERE "user"=$2;',
                 money,
                 ctx.author.id,
             )
         await ctx.send(
             _("Merched **{count}** items for **${money}**.").format(
                 count=count, money=money))
Exemple #2
0
    async def inventory(
        self,
        ctx,
        itemtype: Optional[str.title] = "All",
        lowest: IntFromTo(0, 101) = 0,
        highest: IntFromTo(0, 101) = 101,
    ):
        _("""`[itemtype]` - The type of item to show; defaults to all items
            `[lowest]` - The lower boundary of items to show; defaults to 0
            `[highest]` - The upper boundary of items to show; defaults to 101

            Show your gear items. Items that are in the market will not be shown.

            Gear items can be equipped, sold and given away, or upgraded and merged to make them stronger.
            You can gain gear items by completing adventures, opening crates, or having your pet hunt for them, if you are a ranger.

            To sell unused items for their value, use `{prefix}merch`. To put them up on the global player market, use `{prefix}sell`."""
          )
        if highest < lowest:
            return await ctx.send(
                _("Make sure that the `highest` value is greater than `lowest`."
                  ))
        itemtype_cls = ItemType.from_string(itemtype)
        if itemtype != "All" and itemtype_cls is None:
            return await ctx.send(
                _("Please select a valid item type or `all`. Available types:"
                  " `{all_types}`").format(
                      all_types=", ".join([t.name for t in ALL_ITEM_TYPES])))
        if itemtype == "All":
            ret = await self.bot.pool.fetch(
                "SELECT ai.*, i.equipped FROM profile p JOIN allitems ai ON"
                " (p.user=ai.owner) JOIN inventory i ON (ai.id=i.item) WHERE"
                ' p."user"=$1 AND ((ai."damage"+ai."armor" BETWEEN $2 AND $3) OR'
                ' i."equipped") ORDER BY i."equipped" DESC, ai."damage"+ai."armor"'
                " DESC;",
                ctx.author.id,
                lowest,
                highest,
            )
        else:
            ret = await self.bot.pool.fetch(
                "SELECT ai.*, i.equipped FROM profile p JOIN allitems ai ON"
                " (p.user=ai.owner) JOIN inventory i ON (ai.id=i.item) WHERE"
                ' p."user"=$1 AND ((ai."damage"+ai."armor" BETWEEN $2 AND $3 AND'
                ' ai."type"=$4)  OR i."equipped") ORDER BY i."equipped" DESC,'
                ' ai."damage"+ai."armor" DESC;',
                ctx.author.id,
                lowest,
                highest,
                itemtype,
            )
        if not ret:
            return await ctx.send(_("Your inventory is empty."))
        allitems = list(chunks(ret, 5))
        maxpage = len(allitems) - 1
        embeds = [
            self.invembed(ctx, chunk, idx, maxpage)
            for idx, chunk in enumerate(allitems)
        ]
        await self.bot.paginator.Paginator(extras=embeds).paginate(ctx)
Exemple #3
0
 async def merchall(self,
                    ctx,
                    maxstat: IntFromTo(0, 60) = 60,
                    minstat: IntFromTo(0, 60) = 0):
     _("""Sells all your non-equipped items for their value.""")
     async with self.bot.pool.acquire() as conn:
         money, count = await conn.fetchval(
             "SELECT (sum(value), count(value)) FROM inventory i JOIN allitems ai ON (i.item=ai.id) WHERE ai.owner=$1 AND i.equipped IS FALSE AND ai.armor+ai.damage BETWEEN $2 AND $3;",
             ctx.author.id,
             minstat,
             maxstat,
         )
         if count == 0:
             await self.bot.reset_cooldown(ctx)
             return await ctx.send(_("Nothing to merch."))
         if (buildings := await
                 self.bot.get_city_buildings(ctx.character_data["guild"])):
             money = int(money * (1 + buildings["trade_building"] / 2))
         if not await ctx.confirm(
                 _("You are about to sell **{count} items for ${money}!**\nAre you sure you want to do this?"
                   ).format(count=count, money=money)):
             return
         newcount = await self.bot.pool.fetchval(
             "SELECT count(value) FROM inventory i JOIN allitems ai ON (i.item=ai.id) WHERE ai.owner=$1 AND i.equipped IS FALSE AND ai.armor+ai.damage BETWEEN $2 AND $3;",
             ctx.author.id,
             minstat,
             maxstat,
         )
         if newcount != count:
             await ctx.send(
                 _("Looks like you got more or less items in that range in the meantime. Please try again."
                   ))
             return await self.bot.reset_cooldown(ctx)
         async with conn.transaction():
             await conn.execute(
                 "DELETE FROM allitems ai USING inventory i WHERE ai.id=i.item AND ai.owner=$1 AND i.equipped IS FALSE AND ai.armor+ai.damage BETWEEN $2 AND $3;",
                 ctx.author.id,
                 minstat,
                 maxstat,
             )
             await conn.execute(
                 'UPDATE profile SET "money"="money"+$1 WHERE "user"=$2;',
                 money,
                 ctx.author.id,
             )
         await ctx.send(
             _("Merched **{count}** items for **${money}**.").format(
                 count=count, money=money))
Exemple #4
0
    async def blackjack(self, ctx, amount: IntFromTo(0, 1000) = 0):
        _("""`[amount]` - The amount of money you bet, must be between 0 and 1000; defaults to 0

            Play a round of blackjack against the bot, controlled by reactions.
            The objective is to have a card value as close to 21 as possible, without exceeding it (known as bust).
            Having a card value of exactly 21 is known as a blackjack.

            \U00002934 Hit: Pick up another card
            \U00002935 Stand: stay at your current card value
            \U00002194 Split (if dealt two cards with the same value): Split your two cards into separate hands
            \U0001F501 Switch (if split): Change the focussed hand
            \U000023EC Double down: double the amount you bet in exchange for only one more card

            If a player wins, they will get the amount in cash. If they lose, they will lose that amount.
            If they win with a natural blackjack (first two dealt card get to a value of 21), the player wins 1.5 times the amount.

            (This command has a cooldown of 5 seconds.)""")
        if ctx.character_data["money"] < amount:
            return await ctx.send(_("You're too poor."))
        await self.bot.pool.execute(
            'UPDATE profile SET "money"="money"-$1 WHERE "user"=$2;',
            amount,
            ctx.author.id,
        )
        if amount > 0:
            await self.bot.log_transaction(
                ctx,
                from_=ctx.author.id,
                to=2,
                subject="gambling",
                data={"Amount": amount},
            )
        bj = BlackJack(ctx, amount)
        await bj.run()
Exemple #5
0
    async def adminitem(
            self,
            ctx,
            stat: int,
            owner: UserWithCharacter,
            item_type: str.title,
            value: IntFromTo(0, 100000000),
            *,
            name: str,
    ):
        _("""[Bot Admin only] Create an item.""")
        if item_type not in ("Sword", "Shield"):
            return await ctx.send(_("Invalid item type."))
        if not 0 <= stat <= 100:
            return await ctx.send(_("Invalid stat."))
        await self.bot.create_item(
            name=name,
            value=value,
            type_=item_type,
            damage=stat if item_type == "Sword" else 0,
            armor=stat if item_type == "Shield" else 0,
            owner=owner,
        )

        message = (
            f"{ctx.author} created a {item_type} with name {name} and stat {stat}."
        )

        await ctx.send(_("Done."))
        await self.bot.http.send_message(self.bot.config.admin_log_channel,
                                         message)
        for user in self.bot.owner_ids:
            user = await self.bot.get_user_global(user)
            await user.send(message)
Exemple #6
0
    async def clear(self,
                    ctx,
                    num: IntFromTo(1, 1000),
                    target: MemberConverter = None):
        _("""`<num>` - A whole number from 1 to 1000
            `[target]` - The user whose messages to delete; defaults to everyone

            Deletes an amount of messages in the channel, optionally only by one member.
            If no target is given, all messages are cleared.

            Note that this will *scan* `<num>` messages and will only delete them, if they are from the target, if one is given.
            If the target sent 30 messages, other people sent 70 messages and you cleared 100 messages by the target, only those 30 will be deleted.

            Only users with the Manage Messages permission can use this command."""
          )

        def msgcheck(amsg):
            if target:
                return amsg.author.id == target.id
            return True

        num = len(await ctx.channel.purge(limit=num + 1, check=msgcheck))
        await ctx.send(
            _("👍 Deleted **{num}** messages for you.").format(num=num),
            delete_after=10)
Exemple #7
0
    async def adventure(self, ctx, adventure_number: IntFromTo(1, 30)):
        _(
            """`<adventure_number>` - a whole number from 1 to 30

            Send your character on an adventure with the difficulty `<adventure_number>`.
            The adventure will take `<adventure_number>` hours if no time booster is used, and half as long if a time booster is used.

            If you are in an alliance which owns a city with adventure buildings, your adventure time will be reduced by the adventure building level in %.
            Donators' time will also be reduced:
              - 5% reduction for Silver Donators
              - 10% reduction for Gold Donators
              - 25% reduction for Emerald Donators and above

            Be sure to check `{prefix}status` to check how much time is left, or to check if you survived or died."""
        )
        if adventure_number > rpgtools.xptolevel(ctx.character_data["xp"]):
            return await ctx.send(
                _("You must be on level **{level}** to do this adventure.").format(
                    level=adventure_number
                )
            )
        time = timedelta(hours=adventure_number)

        if buildings := await self.bot.get_city_buildings(ctx.character_data["guild"]):
            time -= time * (buildings["adventure_building"] / 100)
Exemple #8
0
    async def roulette(self, ctx, money: IntFromTo(0, 100), *, bid: str):
        _("""Play a game of French Roulette.
Possible simple bets:
    - noir    (all black numbers)
    - rouge   (all red numbers)
    - pair    (all even numbers)
    - impair  (all odd numbers)
    - manque  (1-18)
    - passe   (19-36)
    - premier (1-12)
    - milieu  (13-24)
    - dernier (25-36)
Complicated bets:
    - colonne (34/35/36) (all numbers in a row on the betting table, either 1, 4, ..., 34 or 2, 5, ..., 35 or 3, 6, ... 36)
    - transversale (vertical low)-(vertical high)    This includes simple and pleine (a vertical row on the betting table, e.g. 19-21. can also be two rows, e.g. 4-9)
        - les trois premiers (numbers 0, 1, 2)
    - carre (low)-(high) (a section of four numbers in a square on the betting table, e.g. 23-27)
        - les quatre premiers (numbers 0, 1, 2, 3)
    - cheval (number 1) (number 2) (a simple bet on two numbers)
    - plein (number) (a simple bet on one number)

To visualize the rows and columns, use the command: roulette table""")
        if ctx.character_data["money"] < money:
            return await ctx.send(_("You're too poor."))
        try:
            game = RouletteGame(money, bid)
        except Exception:
            return await ctx.send(
                _("Your bid input was invalid. Try the help on this command to view examples."
                  ))
        await game.run(ctx)
Exemple #9
0
 async def inventory(
     self,
     ctx,
     itemtype: Optional[str.title] = "All",
     lowest: IntFromTo(0, 101) = 0,
     highest: IntFromTo(0, 101) = 101,
 ):
     _("""Shows your current inventory.""")
     if highest < lowest:
         return await ctx.send(
             _("Make sure that the `highest` value is greater than `lowest`.")
         )
     if itemtype not in self.bot.config.item_types + ["All"]:
         return await ctx.send(
             _(
                 "Please select a valid item type or `all`. Available types: `{all_types}`"
             ).format(all_types=", ".join(self.bot.config.item_types))
         )
     if itemtype == "All":
         ret = await self.bot.pool.fetch(
             'SELECT ai.*, i.equipped FROM profile p JOIN allitems ai ON (p.user=ai.owner) JOIN inventory i ON (ai.id=i.item) WHERE p."user"=$1 AND ((ai."damage"+ai."armor" BETWEEN $2 AND $3) OR i."equipped") ORDER BY i."equipped" DESC, ai."damage"+ai."armor" DESC;',
             ctx.author.id,
             lowest,
             highest,
         )
     else:
         ret = await self.bot.pool.fetch(
             'SELECT ai.*, i.equipped FROM profile p JOIN allitems ai ON (p.user=ai.owner) JOIN inventory i ON (ai.id=i.item) WHERE p."user"=$1 AND ((ai."damage"+ai."armor" BETWEEN $2 AND $3 AND ai."type"=$4)  OR i."equipped") ORDER BY i."equipped" DESC, ai."damage"+ai."armor" DESC;',
             ctx.author.id,
             lowest,
             highest,
             itemtype,
         )
     if not ret:
         return await ctx.send(_("Your inventory is empty."))
     allitems = list(chunks(ret, 5))
     maxpage = len(allitems) - 1
     embeds = [
         self.invembed(ctx, chunk, idx, maxpage)
         for idx, chunk in enumerate(allitems)
     ]
     await self.bot.paginator.Paginator(extras=embeds).paginate(ctx)
Exemple #10
0
 async def blackjack(self, ctx, amount: IntFromTo(0, 1000) = 0):
     _("""[Alpha] Play blackjack against the dealer.""")
     if ctx.character_data["money"] < amount:
         return await ctx.send(_("You're too poor."))
     await self.bot.pool.execute(
         'UPDATE profile SET "money"="money"-$1 WHERE "user"=$2;',
         amount,
         ctx.author.id,
     )
     bj = BlackJack(ctx, amount)
     await bj.run()
Exemple #11
0
    async def gmitem(
        self,
        ctx,
        stat: int,
        owner: UserWithCharacter,
        item_type: str.title,
        value: IntFromTo(0, 100000000),
        *,
        name: str,
    ):
        _(
            """`<stat>` - the generated item's stat, must be between 0 and 100
            `<owner>` - a discord User with character
            `<item_type>` - the generated item's type, must be either Sword, Shield, Axe, Wand, Dagger, Knife, Spear, Bow, Hammer, Scythe or Howlet
            `<value>` - the generated item's value, a whole number from 0 to 100,000,000
            `<name>` - the generated item's name

            Generate a custom item for a user.

            Only Game Masters can use this command."""
        )
        if item_type not in self.bot.config.item_types:
            return await ctx.send(_("Invalid item type."))
        if not 0 <= stat <= 100:
            return await ctx.send(_("Invalid stat."))
        if item_type in ["Scythe", "Bow", "Howlet"]:
            hand = "both"
        elif item_type in ["Spear", "Wand"]:
            hand = "right"
        elif item_type == "Shield":
            hand = "left"
        else:
            hand = "any"
        await self.bot.create_item(
            name=name,
            value=value,
            type_=item_type,
            damage=stat if item_type != "Shield" else 0,
            armor=stat if item_type == "Shield" else 0,
            hand=hand,
            owner=owner,
        )

        message = (
            f"{ctx.author} created a {item_type} with name {name} and stat {stat}."
        )

        await ctx.send(_("Done."))
        await self.bot.http.send_message(self.bot.config.gm_log_channel, message)
        for user in self.bot.owner_ids:
            user = await self.bot.get_user_global(user)
            await user.send(message)
Exemple #12
0
    async def gmitem(
        self,
        ctx,
        stat: int,
        owner: UserWithCharacter,
        item_type: str.title,
        value: IntFromTo(0, 100000000),
        name: str,
        *,
        reason: str = None,
    ):
        _(
            """`<stat>` - the generated item's stat, must be between 0 and 100
            `<owner>` - a discord User with character
            `<item_type>` - the generated item's type, must be either Sword, Shield, Axe, Wand, Dagger, Knife, Spear, Bow, Hammer, Scythe or Howlet
            `<value>` - the generated item's value, a whole number from 0 to 100,000,000
            `<name>` - the generated item's name, should be in double quotes if the name has multiple words
            `[reason]` - The reason this action was done, defaults to the command message link

            Generate a custom item for a user.

            Only Game Masters can use this command."""
        )
        item_type = ItemType.from_string(item_type)
        if item_type is None:
            return await ctx.send(_("Invalid item type."))
        if not 0 <= stat <= 100:
            return await ctx.send(_("Invalid stat."))
        hand = item_type.get_hand().value
        await self.bot.create_item(
            name=name,
            value=value,
            type_=item_type.value,
            damage=stat if item_type != ItemType.Shield else 0,
            armor=stat if item_type == ItemType.Shield else 0,
            hand=hand,
            owner=owner,
        )

        message = "{gm} created a {item_type} with name {name} and stat {stat}.\n\nReason: *{reason}*".format(
            gm=ctx.author,
            item_type=item_type.value,
            name=name,
            stat=stat,
            reason=reason or f"<{ctx.message.jump_url}>",
        )

        await ctx.send(_("Done."))
        await self.bot.http.send_message(self.bot.config.game.gm_log_channel, message)
        for user in self.bot.owner_ids:
            user = await self.bot.get_user_global(user)
            await user.send(message)
Exemple #13
0
    async def adventure(self, ctx, dungeonnumber: IntFromTo(1, 30)):
        _("""Sends your character on an adventure.""")
        if dungeonnumber > int(rpgtools.xptolevel(ctx.character_data["xp"])):
            return await ctx.send(
                _("You must be on level **{level}** to do this adventure.").
                format(level=dungeonnumber))
        time_booster = await self.bot.get_booster(ctx.author, "time")
        time = self.bot.config.adventure_times[dungeonnumber]
        if time_booster:
            time = time / 2

        if (buildings := await
                self.bot.get_city_buildings(ctx.character_data["guild"])):
            time -= time * (buildings["adventure_building"] / 100)
Exemple #14
0
 async def inventory(
     self, ctx, lowest: IntFromTo(0, 60) = 0, highest: IntFromTo(0, 60) = 60
 ):
     _("""Shows your current inventory.""")
     if highest <= lowest:
         return await ctx.send(
             _("Make sure that the `highest` value is greater than `lowest`.")
         )
     ret = await self.bot.pool.fetch(
         'SELECT ai.*, i.equipped FROM profile p JOIN allitems ai ON (p.user=ai.owner) JOIN inventory i ON (ai.id=i.item) WHERE p."user"=$1 AND ((ai."damage"+ai."armor" BETWEEN $2 AND $3) OR i."equipped") ORDER BY i."equipped" DESC, ai."damage"+ai."armor" DESC;',
         ctx.author.id,
         lowest,
         highest,
     )
     if not ret:
         return await ctx.send(_("Your inventory is empty."))
     allitems = list(chunks(ret, 5))
     maxpage = len(allitems) - 1
     embeds = [
         self.invembed(ctx, chunk, idx, maxpage)
         for idx, chunk in enumerate(allitems)
     ]
     await self.bot.paginator.Paginator(extras=embeds).paginate(ctx)
    async def clear(self, ctx, num: IntFromTo(1, 1000), target: discord.Member = None):
        _(
            """Deletes an amount of messages from the history, optionally only by one member."""
        )

        def msgcheck(amsg):
            if target:
                return amsg.author.id == target.id
            return True

        num = len(await ctx.channel.purge(limit=num + 1, check=msgcheck))
        await ctx.send(
            _("👍 Deleted **{num}** messages for you.").format(num=num), delete_after=10
        )
Exemple #16
0
 async def adventure(self, ctx, dungeonnumber: IntFromTo(1, 20)):
     _("""Sends your character on an adventure.""")
     if dungeonnumber > int(rpgtools.xptolevel(ctx.character_data["xp"])):
         return await ctx.send(
             _("You must be on level **{level}** to do this adventure.").
             format(level=dungeonnumber))
     time_booster = await self.bot.get_booster(ctx.author, "time")
     time = self.bot.config.adventure_times[dungeonnumber]
     if time_booster:
         time = time / 2
     await self.bot.start_adventure(ctx.author, dungeonnumber, time)
     await ctx.send(
         _("Successfully sent your character out on an adventure. Use `{prefix}status` to see the current status of the mission."
           ).format(prefix=ctx.prefix))
Exemple #17
0
    async def sell(self, ctx, itemid: int, price: IntFromTo(1, 100000000)):
        _(
            # xgettext: no-python-format
            """`<itemid>` - The ID of the item to sell
            `<price>` - The price to sell the item for, can be 0 or above

            Puts your item into the market. Tax for selling items is 5% of the price.

            You may not sell modified items, items with a price lower than their value, or items below 4 stat.
            If you are in an alliance with owns a city with a trade building, you do not have to pay the tax.

            Please note that you won't get the money right away, another player has to buy the item first.
            With that being said, please choose a reasonable price.  Acceptable price range is 1 to 100 Million.

            If your item has not been bought for 14 days, it will be removed from the market and put back into your inventory."""
        )
        async with self.bot.pool.acquire() as conn:
            item = await conn.fetchrow(
                "SELECT * FROM inventory i JOIN allitems ai ON (i.item=ai.id) WHERE"
                " ai.id=$1 AND ai.owner=$2;",
                itemid,
                ctx.author.id,
            )
            if not item:
                return await ctx.send(
                    _("You don't own an item with the ID: {itemid}").format(
                        itemid=itemid
                    )
                )
            if item["original_name"] or item["original_type"]:
                return await ctx.send(_("You may not sell donator-modified items."))
            if item["value"] > price:
                return await ctx.send(
                    _(
                        "Selling an item below its value is a bad idea. You can always"
                        " do `{prefix}merchant {itemid}` to get more money."
                    ).format(prefix=ctx.prefix, itemid=itemid)
                )
            elif item["damage"] < 4 and item["armor"] < 4:
                return await ctx.send(
                    _(
                        "Your item is either equal to a Starter Item or worse. Noone"
                        " would buy it."
                    )
                )
            if (
                builds := await self.bot.get_city_buildings(ctx.character_data["guild"])
            ) and builds["trade_building"] != 0:
                tax = 0
            else:
Exemple #18
0
 async def volume(self, ctx, volume: IntFromTo(0, 100)):
     _("""Changes the playback's volume""")
     if volume > ctx.player.volume:
         vol_warn = await ctx.send(
             _(":warning:`Playback volume is going to change to {volume} in 5 seconds. To avoid the sudden earrape, control the volume on client side!`"
               ).format(volume=volume))
         await asyncio.sleep(5)
         await ctx.player.set_volume(volume)
         await vol_warn.delete()
     else:
         await ctx.player.set_volume(volume)
     await ctx.send(
         _(":white_check_mark:` Volume successfully changed to {volume}!`").
         format(volume=volume),
         delete_after=5,
     )
Exemple #19
0
    async def roulette(self, ctx, money: IntFromTo(0, 100), *, bid: str):
        _(
            """`<money>` - A whole number from 0 to 100
`<bid>` - What to bid on, see below for details

Play a game of French Roulette.

Possible simple bets:
    - noir    (all black numbers) (1:1 payout)
    - rouge   (all red numbers) (1:1 payout)
    - pair    (all even numbers) (1:1 payout)
    - impair  (all odd numbers) (1:1 payout)
    - manque  (1-18) (1:1 payout)
    - passe   (19-36) (1:1 payout)
    - premier (1-12) (2:1 payout)
    - milieu  (13-24) (2:1 payout)
    - dernier (25-36) (2:1 payout)

Complicated bets:
    - colonne (34/35/36) (all numbers in a row on the betting table, either 1, 4, ..., 34 or 2, 5, ..., 35 or 3, 6, ... 36) (2:1 payout)
    - transversale (vertical low)-(vertical high)    This includes simple and pleine (a vertical row on the betting table, e.g. 19-21. can also be two rows, e.g. 4-9) (11:1 payout for pleine, 5:1 for simple)
        - les trois premiers (numbers 0, 1, 2) (11:1 payout)
    - carre (low)-(high) (a section of four numbers in a square on the betting table, e.g. 23-27) (8:1 payout)
        - les quatre premiers (numbers 0, 1, 2, 3) (8:1 payout)
    - cheval (number 1) (number 2) (a simple bet on two numbers) (17:1 payout)
    - plein (number) (a simple bet on one number) (35:1 payout)

To visualize the rows and columns, use the command: roulette table

This command is in an alpha-stage, which means bugs are likely to happen. Play at your own risk.
(This command has a cooldown of 15 seconds.)"""
        )
        if ctx.character_data["money"] < money:
            return await ctx.send(_("You're too poor."))
        try:
            game = RouletteGame(money, bid)
        except Exception:
            return await ctx.send(
                _(
                    "Your bid input was invalid. Try the help on this command to view"
                    " examples."
                )
            )
        await game.run(ctx)
Exemple #20
0
 async def blackjack(self, ctx, amount: IntFromTo(0, 1000) = 0):
     _("""[Alpha] Play blackjack against the dealer.""")
     if ctx.character_data["money"] < amount:
         return await ctx.send(_("You're too poor."))
     await self.bot.pool.execute(
         'UPDATE profile SET "money"="money"-$1 WHERE "user"=$2;',
         amount,
         ctx.author.id,
     )
     if amount > 0:
         await self.bot.log_transaction(
             ctx,
             from_=ctx.author.id,
             to=2,
             subject="gambling",
             data={"Amount": amount},
         )
     bj = BlackJack(ctx, amount)
     await bj.run()
Exemple #21
0
    async def volume(self, ctx, volume: IntFromTo(0, 100)):
        _("""Changes the playback's volume.

            If there are more than one person in the session and a non-DJ uses this command, a vote has to pass first."""
          )
        if volume > ctx.player.volume:
            vol_warn = await ctx.send(
                _("⚠`Playback volume is going to change to {volume} in 5"
                  " seconds. To avoid the sudden earrape, control the volume on"
                  " client side!`").format(volume=volume))
            await asyncio.sleep(5)
            await ctx.player.set_volume(volume)
            await vol_warn.delete()
        else:
            await ctx.player.set_volume(volume)
        await ctx.send(
            _(":white_check_mark:` Volume successfully changed to {volume}!`").
            format(volume=volume),
            delete_after=5,
        )
Exemple #22
0
 async def adventure(self, ctx, dungeonnumber: IntFromTo(1, 20)):
     _("""Sends your character on an adventure.""")
     if dungeonnumber > int(rpgtools.xptolevel(ctx.character_data["xp"])):
         return await ctx.send(
             _("You must be on level **{level}** to do this adventure.").
             format(level=dungeonnumber))
     time_booster = await self.bot.get_booster(ctx.author, "time")
     time = self.bot.config.adventure_times[dungeonnumber]
     if time_booster:
         time = time / 2
     # Silver = -5%, Gold = -10%, Emerald = -25%
     # TODO: Maybe make a func to get the actual rank
     if await user_is_patron(self.bot,
                             ctx.author):  # save calls for normal people :)
         if await user_is_patron(self.bot, ctx.author, "Emerald Donators"):
             time = time * 0.75
         elif await user_is_patron(self.bot, ctx.author, "Gold Donators"):
             time = time * 0.9
         elif await user_is_patron(self.bot, ctx.author, "Silver Donators"):
             time = time * 0.95
     await self.bot.start_adventure(ctx.author, dungeonnumber, time)
     await ctx.send(
         _("Successfully sent your character out on an adventure. Use `{prefix}status` to see the current status of the mission."
           ).format(prefix=ctx.prefix))
Exemple #23
0
    async def snowballfight(
        self, ctx, enemy: MemberConverter, players: IntFromTo(2, 10) = 10
    ):
        _("""Make a snowball fights against another guild.""")
        if enemy is ctx.author:
            return await ctx.send(_("You may not fight yourself."))

        msg = await ctx.send(
            _(
                "{enemy}, {author} has challenged you for an epic snowball fight! If"
                " you want to accept, react ⚔\n**IMPORTANT: This is very spammy, make"
                " sure you are using a dedicated channel!**"
            ).format(enemy=enemy.mention, author=ctx.author.mention)
        )

        def check(r, u):
            return (
                r.message.id == msg.id and u == enemy and str(r.emoji) == "\U00002744"
            )

        await msg.add_reaction("\U00002744")

        try:
            await self.bot.wait_for("reaction_add", check=check, timeout=60)
        except asyncio.TimeoutError:
            return await ctx.send(_("Timed out..."))
        team1 = [ctx.author]
        team2 = [enemy]

        def check1(msg):
            return msg.author == ctx.author and any(
                [i not in team1 for i in msg.mentions]
            )

        def check2(msg):
            return msg.author == enemy and any([i not in team2 for i in msg.mentions])

        await ctx.send(
            _(
                "{author}, `@mention` one at once to add guild mates"
                " to the fight. You need {num} total!"
            ).format(author=ctx.author.mention, num=players)
        )
        while len(team1) < players:
            try:
                msg = await self.bot.wait_for("message", check=check1, timeout=60)
            except asyncio.TimeoutError:
                return await ctx.send(_("Timed out..."))
            for u in msg.mentions:
                if u not in team1:
                    team1.append(u)
                    await ctx.send(
                        _("{user} has been added to your team, {user2}.").format(
                            user=u.mention, user2=ctx.author.mention
                        )
                    )
        await ctx.send(
            _(
                "{enemy}, `@mention` one at once to add guild mates"
                " to the fight. You need {num} total!"
            ).format(enemy=enemy.mention, num=players)
        )
        while len(team2) < players:
            try:
                msg = await self.bot.wait_for("message", check=check2, timeout=30)
            except asyncio.TimeoutError:
                return await ctx.send(_("Timed out..."))
            for u in msg.mentions:
                if u not in team2:
                    team2.append(u)
                    await ctx.send(
                        _("{user} has been added to your team, {user2}.").format(
                            user=u.mention, user2=enemy.mention
                        )
                    )

        points1 = 1
        points2 = 1
        while points1 < 10 and points2 < 10:
            t1 = (
                ":black_large_square:" * (points1 - 1)
                + ":snowflake:"
                + ":black_large_square:" * (10 - points1)
            )
            t2 = (
                ":black_large_square:" * (points2 - 1)
                + ":snowflake:"
                + ":black_large_square:" * (10 - points2)
            )
            await ctx.send(
                _(
                    """
{author.mention}'s team vs {enemy.mention}'s team
{t1} - {author}
{t2} - {enemy}
Next round starts in 5 seconds!
"""
                ).format(author=ctx.author, enemy=enemy, t1=t1, t2=t2)
            )
            await asyncio.sleep(5)
            game_mode = random.choice(["typeit", "maths", "hangman"])
            if game_mode == "typeit":
                w = random.sample(list(string.ascii_letters), 15)
                w.insert(random.randint(1, 14), "\u200b")
                word = "".join(w)
                real = word.replace("\u200b", "")

                def corr(msg):
                    return (
                        msg.author in team1 or msg.author in team2
                    ) and msg.content == real

                await ctx.send(
                    _(
                        "It's word typing time! In 3 seconds, I will send a word."
                        " Whoever types it fastest gets one point!"
                    )
                )
                await asyncio.sleep(3)
                await ctx.send(f"`{word}`")
                try:
                    msg = await self.bot.wait_for("message", check=corr, timeout=45)
                except asyncio.TimeoutError:
                    return await ctx.send(
                        _("Noone managed to get it right, I'll cancel the fight!")
                    )
                if msg.author in team1:
                    points1 += 1
                else:
                    points2 += 1
                await ctx.send(
                    _("{author} got it right!").format(author=ctx.author.mention)
                )
            elif game_mode == "maths":
                m = random.randint(1, 10)
                x = random.randint(1, 10)
                c = random.choice([2, 4, 5])
                d = random.randint(1, 100)
                res = (m * x) / c + d
                if int(res) == res:
                    res = str(int(res))
                else:
                    res = str(res)

                def corr(msg):
                    return (
                        msg.author in team1 or msg.author in team2
                    ) and msg.content == res

                await ctx.send(
                    _(
                        "It's maths time! In 3 seconds, I'll send a simple maths task"
                        " to solve! Type the answer to get a point!"
                    )
                )
                await asyncio.sleep(3)
                await ctx.send(f"`({m} *\u200b {x}) \u200b/ {c} + \u200b{d}`")
                try:
                    msg = await self.bot.wait_for("message", check=corr, timeout=45)
                except asyncio.TimeoutError:
                    return await ctx.send(
                        _("Noone managed to get it right, I'll cancel the fight!")
                    )
                if msg.author in team1:
                    points1 += 1
                else:
                    points2 += 1
                await ctx.send(_("{user} got it right!").format(user=msg.author))
            elif game_mode == "hangman":
                word = random.choice(self.words).strip()

                def corr(msg):
                    return (msg.author in team1 or msg.author in team2) and (
                        msg.content == word or len(msg.content) == 1
                    )

                disp = "_ " * len(word)
                guessed = []
                await ctx.send(
                    _(
                        "It's hangman time! In 3 seconds, I'll send a hangman-style"
                        " word and you will have to either send your full word as the"
                        " guess or a letter to check for!"
                    )
                )
                await asyncio.sleep(3)
                q = await ctx.send(f"`{disp}`")
                while True:
                    try:
                        msg = await self.bot.wait_for("message", check=corr, timeout=20)
                    except asyncio.TimeoutError:
                        return await ctx.send(
                            _("Noone participated, I'll cancel the fight!")
                        )
                    if msg.content == word:
                        if msg.author in team1:
                            points1 += 1
                        else:
                            points2 += 1
                        await ctx.send(
                            _("{user} got it right!").format(user=msg.author)
                        )
                        break
                    else:
                        try:
                            await msg.delete()
                        except discord.Forbidden:
                            pass

                        if msg.content in guessed:
                            continue
                        if msg.content not in word:
                            continue
                        guessed.append(msg.content)
                        disp = " ".join([i if (i in guessed) else "_" for i in word])
                        await q.edit(content=f"`{disp}`")
        if points1 > points2:
            await ctx.send(_("Team 1 ({user}) won!").format(user=ctx.author.mention))
        else:
            await ctx.send(_("Team 2 ({user}) won!").format(user=enemy.mention))
Exemple #24
0
    async def reward(self, ctx, reward_id: IntFromTo(1, 9)):
        _(
            """`<reward_id>` - A whole number from 1 to 9

            Claim a reward by its ID.

            A list of rewards along with their ID can be seen with `{prefix}easter rewards`."""
        )
        reward = [
            (100, "crates", 10, "common"),
            (500, "money", 10000),
            (1000, "item", 1, 49),
            (2000, "crates", 250, "common"),
            (2500, "boosters", 10),
            (5000, "crates", 10, "rare"),
            (7500, "badge"),
            (7500, "crates", 1, "magic"),
            (12500, "crates", 1, "legendary"),
        ][reward_id - 1]
        if ctx.character_data["eastereggs"] < reward[0]:
            return await ctx.send(_("You don't have enough eggs to claim this."))

        if reward[1] == "crates":
            async with self.bot.pool.acquire() as conn:
                await conn.execute(
                    f'UPDATE profile SET "crates_{reward[3]}"="crates_{reward[3]}"+$1,'
                    ' "eastereggs"="eastereggs"-$2 WHERE "user"=$3;',
                    reward[2],
                    reward[0],
                    ctx.author.id,
                )
                await self.bot.log_transaction(
                    ctx,
                    from_=1,
                    to=ctx.author.id,
                    subject="crates",
                    data={"Rarity": reward[3], "Amount": reward[2]},
                    conn=conn,
                )
            await self.bot.cache.update_profile_cols_rel(
                ctx.author.id,
                **{f"crates_{reward[3]}": reward[2], "eastereggs": -[reward[0]]},
            )
        elif reward[1] == "money":
            async with self.bot.pool.acquire() as conn:
                await conn.execute(
                    'UPDATE profile SET "money"="money"+$1,'
                    ' "eastereggs"="eastereggs"-$2 WHERE "user"=$3;',
                    reward[2],
                    reward[0],
                    ctx.author.id,
                )
                await self.bot.log_transaction(
                    ctx,
                    from_=1,
                    to=ctx.author.id,
                    subject="money",
                    data={"Amount": reward[2]},
                    conn=conn,
                )
            await self.bot.cache.update_profile_cols_rel(
                ctx.author.id, money=reward[2], eastereggs=-reward[0]
            )
        elif reward[1] == "boosters":
            await self.bot.pool.execute(
                'UPDATE profile SET "money_booster"="money_booster"+$1,'
                ' "time_booster"="time_booster"+$1, "luck_booster"="luck_booster"+$1,'
                ' "eastereggs"="eastereggs"-$2 WHERE "user"=$3;',
                reward[2],
                reward[0],
                ctx.author.id,
            )
            await self.bot.cache.update_profile_cols_rel(
                ctx.author.id,
                money_booster=reward[2],
                time_booster=reward[2],
                luck_booster=reward[2],
                eastereggs=-reward[0],
            )
        elif reward[1] == "badge":
            async with self.bot.pool.acquire() as conn:
                await conn.execute(
                    'UPDATE profile SET "eastereggs"="eastereggs"-$1 WHERE "user"=$2;',
                    reward[0],
                    ctx.author.id,
                )
                await conn.execute(
                    'UPDATE guild SET "badges"=array_append("badges", $1) WHERE'
                    ' "id"=$2;',
                    "https://i.imgur.com/VHUDdTv.jpg",
                    ctx.character_data["guild"],
                )
            await self.bot.cache.update_profile_cols_rel(
                ctx.author.id, eastereggs=-reward[0]
            )
        elif reward[1] == "item":
            item = await self.bot.create_random_item(
                minstat=reward[2],
                maxstat=reward[3],
                minvalue=1000,
                maxvalue=1000,
                owner=ctx.author,
                insert=False,
            )
            item["name"] = (
                random.choice(["Bunny Ear", "Egg Cannon", "Chocolate Bar"])
                if item["type_"] != "Shield"
                else random.choice(["Giant Egg", "Sweet Defender"])
            )
            async with self.bot.pool.acquire() as conn:
                await self.bot.create_item(**item, conn=conn)
                await conn.execute(
                    'UPDATE profile SET "eastereggs"="eastereggs"-$1 WHERE "user"=$2;',
                    reward[0],
                    ctx.author.id,
                )
                await self.bot.log_transaction(
                    ctx,
                    from_=1,
                    to=ctx.author.id,
                    subject="item",
                    data={"Name": item["name"], "Value": item["value"]},
                    conn=conn,
                )
            await self.bot.cache.update_profile_cols_rel(
                ctx.author.id, eastereggs=-reward[0]
            )

        await ctx.send(
            _(
                "You claimed your reward. Check your"
                " inventory/boosters/crates/money/etc.! You can claim multiple rewards,"
                " keep hunting!"
            )
        )
Exemple #25
0
    async def _open(
        self, ctx, rarity: CrateRarity = "common", amount: IntFromTo(1, 100) = 1
    ):
        _(
            """`[rarity]` - the crate's rarity to open, can be common, uncommon, rare, magic or legendary; defaults to common
            `[amount]` - the amount of crates to open, may be in range from 1 to 100 at once

            Open one of your crates to receive a weapon. To check which crates contain which items, check `{prefix}help crates`.
            This command takes up a lot of space, so choose a spammy channel to open crates."""
        )
        if ctx.character_data[f"crates_{rarity}"] < amount:
            return await ctx.send(
                _(
                    "Seems like you don't have {amount} crate(s) of this rarity yet."
                    " Vote me up to get a random one or find them!"
                ).format(amount=amount)
            )

        async with self.bot.pool.acquire() as conn:
            await conn.execute(
                f'UPDATE profile SET "crates_{rarity}"="crates_{rarity}"-$1 WHERE'
                ' "user"=$2;',
                amount,
                ctx.author.id,
            )

            if rarity == "mystery":
                crates = {
                    "common": 0,
                    "uncommon": 0,
                    "rare": 0,
                    "magic": 0,
                    "legendary": 0,
                }

                for _i in range(amount):
                    rng = random.randint(0, 10000)

                    if rng < 20:
                        new_rarity = "legendary"
                    elif rng < 200:
                        new_rarity = "magic"
                    elif rng < 1000:
                        new_rarity = "rare"
                    elif rng < 2000:
                        new_rarity = "uncommon"
                    else:
                        new_rarity = "common"

                    crates[new_rarity] += 1

                await conn.execute(
                    'UPDATE profile SET "crates_common"="crates_common"+$1, "crates_uncommon"="crates_uncommon"+$2, "crates_rare"="crates_rare"+$3, "crates_magic"="crates_magic"+$4, "crates_legendary"="crates_legendary"+$5 WHERE "user"=$6;',
                    crates["common"],
                    crates["uncommon"],
                    crates["rare"],
                    crates["magic"],
                    crates["legendary"],
                    ctx.author.id,
                )

                for r, a in crates.items():
                    if a > 0:
                        await self.bot.log_transaction(
                            ctx,
                            from_=1,
                            to=ctx.author.id,
                            subject="crates",
                            data={"Rarity": r, "Amount": a},
                            conn=conn,
                        )

                text = _(
                    "You opened {mystery_amount} {mystery_emoji} and received:\n"
                    "- {common_amount} {common_emoji}\n"
                    "- {uncommon_amount} {uncommon_emoji}\n"
                    "- {rare_amount} {rare_emoji}\n"
                    "- {magic_amount} {magic_emoji}\n"
                    "- {legendary_amount} {legendary_emoji}"
                ).format(
                    mystery_amount=amount,
                    mystery_emoji=self.emotes.mystery,
                    common_amount=crates["common"],
                    common_emoji=self.emotes.common,
                    uncommon_amount=crates["uncommon"],
                    uncommon_emoji=self.emotes.uncommon,
                    rare_amount=crates["rare"],
                    rare_emoji=self.emotes.rare,
                    magic_amount=crates["magic"],
                    magic_emoji=self.emotes.magic,
                    legendary_amount=crates["legendary"],
                    legendary_emoji=self.emotes.legendary,
                )

                await ctx.send(text)

            else:
                items = []
                for _i in range(amount):
                    # A number to detemine the crate item range
                    rand = random.randint(0, 9)
                    if rarity == "common":
                        if rand < 2:  # 20% 20-30
                            minstat, maxstat = (20, 30)
                        elif rand < 5:  # 30% 10-19
                            minstat, maxstat = (10, 19)
                        else:  # 50% 1-9
                            minstat, maxstat = (1, 9)
                    elif rarity == "uncommon":
                        if rand < 2:  # 20% 30-35
                            minstat, maxstat = (30, 35)
                        elif rand < 5:  # 30% 20-29
                            minstat, maxstat = (20, 29)
                        else:  # 50% 10-19
                            minstat, maxstat = (10, 19)
                    elif rarity == "rare":
                        if rand < 2:  # 20% 35-40
                            minstat, maxstat = (35, 40)
                        elif rand < 5:  # 30% 30-34
                            minstat, maxstat = (30, 34)
                        else:  # 50% 20-29
                            minstat, maxstat = (20, 29)
                    elif rarity == "magic":
                        if rand < 2:  # 20% 41-45
                            minstat, maxstat = (41, 45)
                        elif rand < 5:  # 30% 35-40
                            minstat, maxstat = (35, 40)
                        else:
                            minstat, maxstat = (30, 34)
                    elif rarity == "legendary":  # no else because why
                        if rand < 2:  # 20% 49-50
                            minstat, maxstat = (49, 50)
                        elif rand < 5:  # 30% 46-48
                            minstat, maxstat = (46, 48)
                        else:  # 50% 41-45
                            minstat, maxstat = (41, 45)

                    item = await self.bot.create_random_item(
                        minstat=minstat,
                        maxstat=maxstat,
                        minvalue=1,
                        maxvalue=250,
                        owner=ctx.author,
                        conn=conn,
                    )
                    items.append(item)
                    await self.bot.log_transaction(
                        ctx,
                        from_=1,
                        to=ctx.author.id,
                        subject="item",
                        data={"Name": item["name"], "Value": item["value"]},
                        conn=conn,
                    )

                if amount == 1:
                    embed = discord.Embed(
                        title=_("You gained an item!"),
                        description=_("You found a new item when opening a crate!"),
                        color=0xFF0000,
                    )
                    embed.set_thumbnail(url=ctx.author.display_avatar.url)
                    embed.add_field(name=_("ID"), value=item["id"], inline=False)
                    embed.add_field(name=_("Name"), value=item["name"], inline=False)
                    embed.add_field(name=_("Type"), value=item["type"], inline=False)
                    embed.add_field(name=_("Damage"), value=item["damage"], inline=True)
                    embed.add_field(name=_("Armor"), value=item["armor"], inline=True)
                    embed.add_field(
                        name=_("Value"), value=f"${item['value']}", inline=False
                    )
                    embed.set_footer(
                        text=_("Remaining {rarity} crates: {crates}").format(
                            crates=ctx.character_data[f"crates_{rarity}"] - 1,
                            rarity=rarity,
                        )
                    )
                    await ctx.send(embed=embed)
                    if rarity == "legendary":
                        await self.bot.public_log(
                            f"**{ctx.author}** opened a legendary crate and received"
                            f" {item['name']} with **{item['damage'] or item['armor']}"
                            f" {'damage' if item['damage'] else 'armor'}**."
                        )
                    elif rarity == "magic" and item["damage"] + item["armor"] >= 41:
                        if item["damage"] >= 41:
                            await self.bot.public_log(
                                f"**{ctx.author}** opened a magic crate and received"
                                f" {item['name']} with **{item['damage'] or item['armor']}"
                                f" {'damage' if item['damage'] else 'armor'}**."
                            )
                else:
                    stats_raw = [i["damage"] + i["armor"] for i in items]
                    stats = Counter(stats_raw)
                    types = Counter([i["type"] for i in items])
                    most_common = "\n".join(
                        [f"- {i[0]} (x{i[1]})" for i in stats.most_common(5)]
                    )
                    most_common_types = "\n".join(
                        [f"- {i[0]} (x{i[1]})" for i in types.most_common()]
                    )
                    top = "\n".join([f"- {i}" for i in sorted(stats, reverse=True)[:5]])
                    average_stat = round(sum(stats_raw) / amount, 2)
                    await ctx.send(
                        _(
                            "Successfully opened {amount} {rarity} crates. Average stat:"
                            " {average_stat}\nMost common stats:\n```\n{most_common}\n```\nBest"
                            " stats:\n```\n{top}\n```\nTypes:\n```\n{most_common_types}\n```"
                        ).format(
                            amount=amount,
                            rarity=rarity,
                            average_stat=average_stat,
                            most_common=most_common,
                            top=top,
                            most_common_types=most_common_types,
                        )
                    )
                    if rarity == "legendary":
                        await self.bot.public_log(
                            f"**{ctx.author}** opened {amount} legendary crates and received"
                            f" stats:\n```\n{most_common}\n```\nAverage: {average_stat}"
                        )
                    elif rarity == "magic":
                        await self.bot.public_log(
                            f"**{ctx.author}** opened {amount} magic crates and received"
                            f" stats:\n```\n{most_common}\n```\nAverage: {average_stat}"
                        )
Exemple #26
0
 async def spoil(self, ctx, item: IntFromTo(1, 40) = None):
     _("""Buy something for your spouse and increase their lovescore.""")
     items = [
         (_("Dog :dog2:"), 50),
         (_("Cat :cat2:"), 50),
         (_("Cow :cow2:"), 75),
         (_("Penguin :penguin:"), 100),
         (_("Unicorn :unicorn:"), 1000),
         (_("Potato :potato:"), 1),
         (_("Sweet potato :sweet_potato:"), 2),
         (_("Peach :peach:"), 5),
         (_("Ice Cream :ice_cream:"), 10),
         (_("Bento Box :bento:"), 50),
         (_("Movie Night :ticket:"), 75),
         (_("Video Game Night :video_game:"), 10),
         (_("Camping Night :fishing_pole_and_fish:"), 15),
         (_("Couple Competition :trophy:"), 30),
         (_("Concert Night :musical_keyboard:"), 100),
         (_("Bicycle :bike:"), 100),
         (_("Motorcycle :motorcycle:"), 250),
         (_("Car :red_car:"), 300),
         (_("Private Jet :airplane:"), 1000),
         (_("Space Rocket :rocket:"), 10000),
         (_("Credit Card :credit_card:"), 20),
         (_("Watch :watch:"), 100),
         (_("Phone :iphone:"), 100),
         (_("Bed :bed:"), 500),
         (_("Home films :projector:"), 750),
         (_("Satchel :school_satchel:"), 25),
         (_("Purse :purse:"), 30),
         (_("Shoes :athletic_shoe:"), 150),
         (_("Casual Attire :shirt:"), 200),
         (_("Ring :ring:"), 1000),
         (_("Balloon :balloon:"), 10),
         (_("Flower Bouquet :bouquet:"), 25),
         (_("Expensive Chocolates :chocolate_bar:"), 40),
         (_("Declaration of Love :love_letter:"), 50),
         (_("Key to Heart :key2:"), 100),
         (_("Ancient Vase :amphora:"), 15000),
         (_("House :house:"), 25000),
         (_("Super Computer :computer:"), 50000),
         (_("Precious Gemstone Collection :gem:"), 75000),
         (_("Planet :earth_americas:"), 1_000_000),
     ]
     text = _("Price")
     items_str = "\n".join([
         f"{idx + 1}.) {item} ... {text}: **${price}**"
         for idx, (item, price) in enumerate(items)
     ])
     if not item:
         text = _(
             "To buy one of these items for your partner, use `{prefix}spoil shopid`"
         ).format(prefix=ctx.prefix)
         return await ctx.send(f"{items_str}\n\n{text}")
     item = items[item - 1]
     if ctx.character_data["money"] < item[1]:
         return await ctx.send(_("You are too poor to buy this."))
     if not ctx.character_data["marriage"]:
         return await ctx.send(_("You're not married yet."))
     async with self.bot.pool.acquire() as conn:
         await conn.execute(
             'UPDATE profile SET lovescore=lovescore+$1 WHERE "user"=$2;',
             item[1],
             ctx.character_data["marriage"],
         )
         await conn.execute(
             'UPDATE profile SET money=money-$1 WHERE "user"=$2;',
             item[1],
             ctx.author.id,
         )
     await ctx.send(
         _("You bought a **{item}** for your partner and increased their love score by **{points}** points!"
           ).format(item=item[0], points=item[1]))
     user = await self.bot.get_user_global(ctx.character_data["marriage"])
     if not user:
         return await ctx.send(
             _("Failed to DM your spouse, could not find their Discord account"
               ))
     await user.send(
         _("**{author}** bought you a **{item}** and increased your love score by **{points}** points!"
           ).format(author=ctx.author, item=item[0], points=item[1]))
Exemple #27
0
    async def reward(self, ctx, reward_id: IntFromTo(1, 10)):
        _("""Get your easter reward. ID may be 1 to 10.""")
        reward = [
            (100, "crates", 1),
            (500, "money", 10000),
            (1000, "item", 1, 49),
            (2000, "crates", 25),
            (2500, "boosters", 10),
            (5000, "crates", 100),
            (7500, "badge"),
            (7500, "crates", 200),
            (7500, "item", 40, 50),
            (10000, "item", 50, 50),
        ][reward_id - 1]
        if ctx.character_data["eastereggs"] < reward[0]:
            return await ctx.send(
                _("You don't have enough eggs to claim this."))

        if reward[1] == "crates":
            await self.bot.pool.execute(
                'UPDATE profile SET "crates_common"="crates_common"+$1, "eastereggs"="eastereggs"-$2 WHERE "user"=$3;',
                reward[2],
                reward[0],
                ctx.author.id,
            )
        elif reward[1] == "money":
            await self.bot.pool.execute(
                'UPDATE profile SET "money"="money"+$1, "eastereggs"="eastereggs"-$2 WHERE "user"=$3;',
                reward[2],
                reward[0],
                ctx.author.id,
            )
        elif reward[1] == "boosters":
            await self.bot.pool.execute(
                'UPDATE profile SET "money_booster"="money_booster"+$1, "time_booster"="time_booster"+$1, "luck_booster"="luck_booster"+$1, "eastereggs"="eastereggs"-$2 WHERE "user"=$3;',
                reward[2],
                reward[0],
                ctx.author.id,
            )
        elif reward[1] == "badge":
            async with self.bot.pool.acquire() as conn:
                await conn.execute(
                    'UPDATE profile SET "eastereggs"="eastereggs"-$1 WHERE "user"=$2;',
                    reward[0],
                    ctx.author.id,
                )
                await conn.execute(
                    'UPDATE guilds SET "badges"=array_append("badges", $1) WHERE "id"=$2;',
                    "https://i.imgur.com/LOM8JcY.png",
                    ctx.character_data["guild"],
                )
        elif reward[1] == "item":
            item = await self.bot.create_random_item(
                minstat=reward[2],
                maxstat=reward[3],
                minvalue=1000,
                maxvalue=1000,
                owner=ctx.author,
                insert=False,
            )
            item["name"] = (random.choice([
                "Bunny Ear", "Egg Cannon", "Chocolate Bar"
            ]) if item["type_"] == "Sword" else random.choice(
                ["Giant Egg", "Sweet Defender"]))
            await self.bot.create_item(**item)
            await self.bot.pool.execute(
                'UPDATE profile SET "eastereggs"="eastereggs"-$1 WHERE "user"=$2;',
                reward[0],
                ctx.author.id,
            )
        await ctx.send(
            _("You claimed your reward. Check your inventory/boosters/crates/money/etc.! You can claim multiple rewards, keep hunting!"
              ))
Exemple #28
0
 async def claim(self, ctx, reward_id: IntFromTo(1, 10)):
     _("""[Guild Leader only] Claim event rewards.""")
     reward = [
         {
             "price": 1000,
             "reward": "money",
             "data": 5000
         },
         {
             "price": 5000,
             "reward": "money",
             "data": 27500
         },
         {
             "price": 10000,
             "reward": "money",
             "data": 60000
         },
         {
             "price": 25000,
             "reward": "money",
             "data": 175000
         },
         {
             "price": 37500,
             "reward": "badge",
             "data": "https://idlerpg.travitia.xyz/halloween_2019_1.png",
         },
         {
             "price": 50000,
             "reward": "badge",
             "data": "https://idlerpg.travitia.xyz/halloween_2019_2.png",
         },
         {
             "price": 10000,
             "reward": "members",
             "data": 2
         },
         {
             "price": 20000,
             "reward": "members",
             "data": 5
         },
         {
             "price": 35000,
             "reward": "members",
             "data": 8
         },
         {
             "price": 50000,
             "reward": "members",
             "data": 15
         },
     ][reward_id - 1]
     async with self.bot.pool.acquire() as conn:
         if (await conn.fetchval(
                 'SELECT pumpkins FROM guild WHERE "id"=$1;',
                 ctx.character_data["guild"],
         ) < reward["price"]):
             return await ctx.send(
                 _("You have insufficient pumpkins for this reward."))
         await conn.execute(
             'UPDATE guild SET "pumpkins"="pumpkins"-$1 WHERE "id"=$2;',
             reward["price"],
             ctx.character_data["guild"],
         )
         if reward["reward"] == "money":
             await conn.execute(
                 'UPDATE guild SET "money"="money"+$1 WHERE "id"=$2;',
                 reward["data"],
                 ctx.character_data["guild"],
             )
         elif reward["reward"] == "badge":
             await conn.execute(
                 'UPDATE guild SET "badges"=array_append("badges", $1) WHERE "id"=$2;',
                 reward["data"],
                 ctx.character_data["guild"],
             )
         elif reward["reward"] == "members":
             await conn.execute(
                 'UPDATE guild SET "memberlimit"="memberlimit"+$1 WHERE "id"=$2;',
                 reward["data"],
                 ctx.character_data["guild"],
             )
     await ctx.send(
         _("Reward successfully claimed for **{amount}** 🎃!").format(
             amount=reward["price"]))
Exemple #29
0
    async def merchall(
        self,
        ctx,
        maxstat: IntFromTo(0, 100) = 100,
        minstat: IntFromTo(0, 100) = 0,
    ):
        _(
            # xgettext: no-python-format
            """`[maxstat]` - The highest damage/defense to include; defaults to 100
            `[minstat]` - The lowest damage/defense to include; defaults to 0

            Sells all your non-equipped items for their value. A convenient way to sell a large amount of items at once.
            If you are in an alliance which owns a trade building, your earnings will be increased by 50% for each level.

            (This command has a cooldown of 30 minutes.)"""
        )
        async with self.bot.pool.acquire() as conn:
            allitems = await conn.fetch(
                "SELECT ai.id, value FROM inventory i JOIN allitems ai ON"
                " (i.item=ai.id) WHERE ai.owner=$1 AND i.equipped IS FALSE AND"
                " ai.armor+ai.damage BETWEEN $2 AND $3;",
                ctx.author.id,
                minstat,
                maxstat,
            )
            count, money = len(allitems), sum(i["value"] for i in allitems)
            if count == 0:
                await self.bot.reset_cooldown(ctx)
                return await ctx.send(_("Nothing to merch."))
            if buildings := await self.bot.get_city_buildings(
                ctx.character_data["guild"]
            ):
                money = int(money * (1 + buildings["trade_building"] / 2))
            if not await ctx.confirm(
                _(
                    "You are about to sell **{count} items for ${money}!**\nAre you"
                    " sure you want to do this?"
                ).format(count=count, money=money)
            ):
                await self.bot.reset_cooldown(ctx)
                return await ctx.send(_("Cancelled selling your items."))
            newcount = await conn.fetchval(
                "SELECT count(value) FROM inventory i JOIN allitems ai ON"
                " (i.item=ai.id) WHERE ai.owner=$1 AND i.equipped IS FALSE AND"
                " ai.armor+ai.damage BETWEEN $2 AND $3;",
                ctx.author.id,
                minstat,
                maxstat,
            )
            if newcount != count:
                await ctx.send(
                    _(
                        "Looks like you got more or less items in that range in the"
                        " meantime. Please try again."
                    )
                )
                return await self.bot.reset_cooldown(ctx)
            async with conn.transaction():
                await self.bot.delete_items([i["id"] for i in allitems], conn=conn)
                await conn.execute(
                    'UPDATE profile SET "money"="money"+$1 WHERE "user"=$2;',
                    money,
                    ctx.author.id,
                )
            await self.bot.log_transaction(
                ctx,
                from_=1,
                to=ctx.author.id,
                subject="merch",
                data={"Amount": f"{count} items", "Value": money},
                conn=conn,
            )
Exemple #30
0
    async def merchall(self,
                       ctx,
                       maxstat: IntFromTo(0, 75) = 75,
                       minstat: IntFromTo(0, 75) = 0):
        _("""`[maxstat]` - The highest damage/defense to include; defaults to 75
            `[minstat]` - The lowest damage/defense to include; defaults to 0

            Sells all your non-equipped items for their value. A convenient way to sell a large amount of items at once.
            If you are in an alliance which owns a trade building, your winnings will be multiplied by 1.5 for each level.

            ⚠ This command is currently disabled.

            (This command has a cooldown of 30 minutes.)""")
        async with self.bot.pool.acquire() as conn:
            money, count = await conn.fetchval(
                "SELECT (sum(value), count(value)) FROM inventory i JOIN allitems ai ON"
                " (i.item=ai.id) WHERE ai.owner=$1 AND i.equipped IS FALSE AND"
                " ai.armor+ai.damage BETWEEN $2 AND $3;",
                ctx.author.id,
                minstat,
                maxstat,
            )
            if count == 0:
                await self.bot.reset_cooldown(ctx)
                return await ctx.send(_("Nothing to merch."))
            if (buildings := await
                    self.bot.get_city_buildings(ctx.character_data["guild"])):
                money = int(money * (1 + buildings["trade_building"] / 2))
            if not await ctx.confirm(
                    _("You are about to sell **{count} items for ${money}!**\nAre you"
                      " sure you want to do this?").format(count=count,
                                                           money=money)):
                await self.bot.reset_cooldown(ctx)
                return await ctx.send(_("Cancelled selling your items."))
            newcount = await self.bot.pool.fetchval(
                "SELECT count(value) FROM inventory i JOIN allitems ai ON"
                " (i.item=ai.id) WHERE ai.owner=$1 AND i.equipped IS FALSE AND"
                " ai.armor+ai.damage BETWEEN $2 AND $3;",
                ctx.author.id,
                minstat,
                maxstat,
            )
            if newcount != count:
                await ctx.send(
                    _("Looks like you got more or less items in that range in the"
                      " meantime. Please try again."))
                return await self.bot.reset_cooldown(ctx)
            async with conn.transaction():
                await conn.execute(
                    "DELETE FROM allitems ai USING inventory i WHERE ai.id=i.item AND"
                    " ai.owner=$1 AND i.equipped IS FALSE AND ai.armor+ai.damage"
                    " BETWEEN $2 AND $3;",
                    ctx.author.id,
                    minstat,
                    maxstat,
                )
                await conn.execute(
                    'UPDATE profile SET "money"="money"+$1 WHERE "user"=$2;',
                    money,
                    ctx.author.id,
                )
            await self.bot.log_transaction(
                ctx,
                from_=1,
                to=ctx.author.id,
                subject="merch",
                data={
                    "Amount": f"{count} items",
                    "Value": money
                },
            )
            await ctx.send(
                _("Merched **{count}** items for **${money}**.").format(
                    count=count, money=money))