Example #1
0
    async def _use_uc_crate(self, ctx, item: Item, amount):
        _, name = await self._initiate_crate_callback(ctx, item, amount)

        await asyncio.sleep(random(1., 2.))

        _xp = 0
        _profit = 0
        _golden_profit = 0
        for _i in range(amount):
            _profit += random(460, 1750)
            if random() < 0.002:
                _golden_profit += 1
            if random() < 0.13:
                _xp += random(30, 80)

        await ctx.bot.db.add("users", "shrimp", ctx.author, _profit)
        await ctx.bot.db.add("users", "golden_shrimp", ctx.author,
                             _golden_profit)
        await ctx.bot.db.add_xp(ctx.author, _xp)
        await ctx.maybe_edit(
            _, (f"Opened {name}\n"
                f"{core.SHRIMP} +{_profit:,} shrimp\n" +
                (f"{core.GOLDEN_SHRIMP} +{_golden_profit:,} golden shrimp\n"
                 if _golden_profit > 0 else '') +
                (f"{core.ARROW} +{_xp:,} XP" if _xp > 0 else '')),
            allowed_mentions=discord.AllowedMentions.none())
Example #2
0
 async def _use_fiji_water(self, ctx, __):
     _ = await ctx.send(f"{core.LOADING} Drinking your Fiji™ Water...")
     await asyncio.sleep(random(2., 4.))
     await ctx.db.add("users", "xp_multiplier", ctx.author, profit :=
                      random(.5, .8))
     await ctx.maybe_edit(
         _,
         f"{__.emoji} Mmm, you drank your Fiji™ Water and gained a **{profit*100:.2f}%** XP Multiplier.",
         allowed_mentions=discord.AllowedMentions.none())
Example #3
0
    async def _blackjack(self, ctx, *,
                         amount: converters.CasinoBet(200, 200000)):
        await ctx.cd()
        await ctx.bot.db.add_xp(ctx.author, util.random(2, 4))

        _game = Blackjack(ctx, amount)
        await _game.start()
Example #4
0
    async def _net_buy(self, ctx, *, net: nets.NetConverter):
        await ctx.cd()

        _level = await ctx.db.get("users", ctx.author, "level")
        if net.level_requirement > _level:
            return await ctx.send(
                f"You're too inexperienced to use this net! Come back when you're **Level {net.level_requirement:,}**."
            )

        _owned = await ctx.db.get("users", ctx.author, "nets")
        if nets.has_net(_owned, net):
            return await ctx.send("You already own this net.")

        _balance = await ctx.db.get("users", ctx.author, "shrimp")
        if _balance < net.price:
            _diff = net.price - _balance
            return await ctx.send(
                f"You can't afford this net. Come back when you get {core.SHRIMP} **{_diff:,} more shrimp**."
            )

        await ctx.db.add("users", "shrimp", ctx.author, -net.price)
        await ctx.db.set("users", "nets", ctx.author, _owned | net.flag)

        _embed = discord.Embed(color=core.GREEN)
        _embed.description = f"{core.CHECK} Successfully bought **{net}**."
        await ctx.db.add_xp(ctx.author, util.random(5, 20))
        await ctx.send(
            f"💡 Equip your net using `{ctx.clean_prefix}net equip {net.id}`",
            embed=_embed,
            embed_perms=True)
Example #5
0
    async def _factory_claim(self, ctx):
        data = await ctx.db.get_factory_info(ctx.author, ctx.unix)
        if not data['is_active']:
            return await ctx.send(
                f"Your factory isn't active yet! Start it using **{ctx.clean_prefix}factory start**"
            )
        if data['shrimp'] <= 0 and data['golden_shrimp'] <= 0:
            return await ctx.send("You have nothing to claim.")
        if data['time_passed'] < 60:
            return await ctx.send(
                "You claimed shrimp within the last minute. Slow down, wouldn't you?"
            )
        await ctx.cd()

        await ctx.db.set("factories", "golden_shrimp", ctx.author, 0)
        await ctx.db.set("factories", "last_claim", ctx.author, ctx.unix)
        if random() < 0.03:
            return await ctx.send(
                "You claimed your shrimp, but the shrimp was rotten. You had to throw it out."
            )

        await ctx.db.add("users", "shrimp", ctx.author, data['shrimp'])
        await ctx.db.add("users", "golden_shrimp", ctx.author,
                         data['golden_shrimp'])

        lines = []
        if data['shrimp'] > 0:
            lines.append(f"{core.SHRIMP} **+{data['shrimp']:,}**")
        if data['golden_shrimp'] > 0:
            lines.append(
                f"{core.GOLDEN_SHRIMP} **+{data['golden_shrimp']:,}**")

        await ctx.send(f"{core.FACTORY} ShrimpFactory™ Claim\n" +
                       '\n'.join(lines))
Example #6
0
    async def _use_potion(self, ctx, item):
        no_mention = discord.AllowedMentions.none()
        _ = await ctx.send(f"{core.LOADING} Drinking your potion...")
        await asyncio.sleep(random(1., 2.4))
        if random() < 0.05:
            await ctx.db.die(
                ctx.author, _start_reason :=
                "Your potion was actually poison, and you poisoned yourself.")
            return await ctx.maybe_edit(_,
                                        f"{_start_reason} You died.",
                                        allowed_mentions=no_mention)

        _gain = random(20, 50)
        await ctx.db.add_xp(ctx.author, _gain)
        await ctx.maybe_edit(
            _,
            f"{item.emoji} You drank your potion and gained **{_gain} XP**.")
Example #7
0
 async def _use_coffee(self, ctx, item):
     no_mention = discord.AllowedMentions.none()
     _ = await ctx.send(f"{core.LOADING} Drinking your coffee...")
     await asyncio.sleep(random(1., 2.4))
     if random() < 0.12:
         await ctx.db.die(
             ctx.author, _start_reason :=
             "You drank a little too much coffee today and overdosed on caffeine."
         )
         return await ctx.maybe_edit(_,
                                     f"{_start_reason} You died.",
                                     allowed_mentions=no_mention)
     _profit = random(.01, .06)
     await ctx.db.add("users", "xp_multiplier", ctx.author, _profit)
     await ctx.maybe_edit(
         _, (f"{item.emoji} **Drank a cup of coffee**\n"
             f"Gained a **{_profit*100:.2f}%** XP multiplier"),
         allowed_mentions=no_mention)
Example #8
0
    async def _net_equip(self, ctx, *, net: nets.NetConverter):
        await ctx.cd()

        _owned = await ctx.db.get("users", ctx.author, "nets")
        if not nets.has_net(_owned, net):
            return await ctx.send("You don't own this net.")

        await ctx.db.add_xp(ctx.author, util.random(1, 2))
        await ctx.db.set("users", "net", ctx.author, net.id)
        await ctx.send(f"Successfully equipped **{net}**.")
Example #9
0
 async def _remove(self, ctx, *, item: items.ItemConverter):
     if not item.remover:
         return await ctx.send("That item can't be removed.")
     try:
         await items.remove_item(ctx, item)
     except items.ItemRemovalFailure:
         return
     else:
         await ctx.db.add_xp(ctx.author, util.random(2, 4))
         await ctx.cd()
Example #10
0
    async def _factory(self):
        """ This will add golden shrimp every minute or so """
        if not self.client.db:
            return

        if factories := self.client.db.route("factories"):
            for factory in factories.values():
                if factory["is_active"] and factory["golden_shrimp"] < factory["golden_capacity"]:
                    if random() < factory["golden_chance_per_minute"]:
                        await self.client.db.add("factories", "golden_shrimp", Object(id=factory["user_id"]), 1)
Example #11
0
 async def _use_shield(self, ctx, sh: Item):
     if ctx.unix <= await ctx.db.get("users", ctx.author, "shield_active"):
         await ctx.send("Your shield is already active.")
         raise ItemUsageFailure()
     _ = await ctx.send(f"{sh.emoji} Using your shield...")
     await asyncio.sleep(hours := random(2., 4.))
     seconds = round(hours * 3600)
     from_now = ctx.unix + seconds
     await ctx.db.set("users", "shield_active", ctx.author, from_now)
     await ctx.maybe_edit(
         _,
         f"{sh.emoji} You activated your shield and will have extra protection "
         f"from robs for **{duration_strf(seconds, 2)}**.",
         allowed_mentions=discord.AllowedMentions.none())
Example #12
0
    async def _stock(self):
        """ This will update the stocks graph """
        if not self.client.db:
            return

        last = await self.client.db.fetchrow("SELECT * FROM stocks ORDER BY id DESC")
        if not last:
            last = {
                "shrimp": 100,
                "created_at": self.client.unix,
                "id": 0
            }
        await self.client.db.execute(
            "INSERT INTO stocks (shrimp, created_at) VALUES ($1, $2);"
            "DELETE FROM stocks WHERE id < $3",
            last['shrimp'] + random(-52, 50), self.client.unix,
            last['id'] - 100  # Delete stocks past 100 ticks
        )
Example #13
0
    async def roulette(self, ctx, bet: RouletteBetConverter(),
                       amount: converters.CasinoBet(maximum=200000)):
        await ctx.cd()
        color = random.choice(("red", "black"))
        value = random.randint(1, 36)
        if util.random() < 1 / 36:
            color, value = "green", 0

        won = False
        if isinstance(bet, str):
            if bet in ("red", "black", "green"):
                won = color == bet
            else:
                modulo_check = 1 if bet == 'odd' else 0
                won = value % 2 == modulo_check
        elif isinstance(bet, int):
            won = value == bet
        elif isinstance(bet, tuple):
            won = bet[0] <= value <= bet[1]

        text = f"{core.ROULETTE_EMOJIS[color]} {color.title()} {value}"

        embed = discord.Embed(timestamp=ctx.now)
        embed.set_author(name=f"{ctx.author.name} - Roulette",
                         icon_url=ctx.avatar)
        embed.add_field(name="Landed on", value=text, inline=False)

        if won:
            embed.colour = core.GREEN
            _field_title = "You won!"
            if color == "green":
                _field_title = "Roulette!"

            _base_multiplier = 1
            if color == "green":
                _base_multiplier = 30
            elif isinstance(bet, int):
                _base_multiplier = 15

            profit = round(amount * _base_multiplier)
            await ctx.db.add("users", "shrimp", ctx.author, profit)
            new = await ctx.bot.db.get("users", ctx.author, "shrimp")

            embed.add_field(
                name=_field_title,
                value=(f"You won {core.SHRIMP} **{profit:,} shrimp**.\n"
                       f"You now have {core.SHRIMP} **{new:,} shrimp**."))
        else:
            embed.colour = core.RED
            _field_title = "You lost!"

            await ctx.db.add("users", "shrimp", ctx.author, -amount)
            new = await ctx.bot.db.get("users", ctx.author, "shrimp")

            embed.add_field(
                name=_field_title,
                value=(f"You lost {core.SHRIMP} **{amount:,} shrimp**.\n"
                       f"You now have {core.SHRIMP} **{new:,} shrimp**."))

        _before_embed = discord.Embed(color=core.EMBED_COLOR, description=text)
        original = await ctx.send(
            f"{core.LOADING} Spinning the roulette wheel... (Bet amount: {amount:,})"
        )

        await asyncio.sleep(util.random(1.5, 2.5))
        await ctx.maybe_edit(original,
                             "",
                             embed=_before_embed,
                             allowed_mentions=discord.AllowedMentions.none())

        await asyncio.sleep(util.random(.5, 1.2))
        await ctx.maybe_edit(original,
                             f"Your bet: {bet}",
                             embed=embed,
                             allowed_mentions=discord.AllowedMentions.none())

        await ctx.bot.db.add_xp(ctx.author, util.random(2, 5))
Example #14
0
    async def _slots(self, ctx, amount: converters.CasinoBet(maximum=100000),
                     **options):
        await ctx.cd()

        _rigged = options.get("rig", options.get("rigged", False))
        if not await ctx.bot.is_owner(ctx.author):
            _rigged = False

        _slots = random.choices(core.SLOTS, k=3) if not _rigged else ("f", "f",
                                                                      "f")
        _combo = "".join(sorted(_slots))
        _base_multiplier = 0

        sorted_keys = sorted(list(core.SLOTS_MULTIS), key=lambda k: len(k))
        for combo in sorted_keys:
            if combo in _combo:
                _base_multiplier = core.SLOTS_MULTIS[combo]

        emojis = " ".join(core.SLOTS_EMOJIS[_] for _ in _slots)
        emojis = f"**»** {emojis} **«**"

        embed = discord.Embed(timestamp=ctx.now, description=emojis)
        embed.set_author(name=f"{ctx.author.name}'s Slot Machine",
                         icon_url=ctx.avatar)

        if _base_multiplier > 0:
            profit = round(amount * _base_multiplier)
            await ctx.bot.db.add("users", "shrimp", ctx.author, profit)

            embed.colour = core.GREEN
            _field_name = "Winner!"
            if _combo == 'ggg':
                _field_name = "**JACKPOT!!!**"
            elif _combo == "fff":
                _field_name = "**MEGA JACKPOT!!!!**"

            new = await ctx.bot.db.get("users", ctx.author, "shrimp")

            embed.add_field(
                name=_field_name,
                value=
                (f"You won {core.SHRIMP} **{profit:,} shrimp**. ({round(_base_multiplier*100):,}%)\n"
                 f"You now have {core.SHRIMP} **{new:,} shrimp**."))
        else:
            await ctx.bot.db.add("users", "shrimp", ctx.author, -amount)
            new = await ctx.bot.db.get("users", ctx.author, "shrimp")

            embed.colour = core.RED
            embed.add_field(
                name="Loser!",
                value=(f"You lost {core.SHRIMP} **{amount:,} shrimp**.\n"
                       f"You now have {core.SHRIMP} **{new:,} shrimp**."))

        _before_embed = discord.Embed(color=core.EMBED_COLOR,
                                      description=emojis)
        original = await ctx.send(
            f"{core.LOADING} Spinning the slot machine... (Bet: {amount:,})")

        await asyncio.sleep(util.random(1.5, 2.5))
        await ctx.maybe_edit(original,
                             "",
                             embed=_before_embed,
                             allowed_mentions=discord.AllowedMentions.none())

        await asyncio.sleep(util.random(.5, 1.2))
        await ctx.maybe_edit(original,
                             "",
                             embed=embed,
                             allowed_mentions=discord.AllowedMentions.none())

        await ctx.bot.db.add_xp(ctx.author, util.random(2, 4))
Example #15
0
    async def _roll(self, ctx, amount: converters.CasinoBet(), **options):
        await ctx.cd()

        _rigged = options.get("rig", options.get("rigged", False))
        if not await ctx.bot.is_owner(ctx.author):
            _rigged = False

        if not _rigged:
            rolls = random.choices(_range := range(1, 7), k=2)
            my_rolls = random.choices(_range, k=2)
        else:
            rolls = (6, 6)
            my_rolls = (1, 1)

        winner = sum(rolls) > sum(my_rolls)
        draw = sum(rolls) == sum(my_rolls)

        def _format_rolls(r):
            return f"{core.DICE[r[0]]} {core.DICE[r[1]]}"

        embed = discord.Embed(timestamp=ctx.now)
        embed.set_author(name=f"{ctx.author.name}'s Gambling session",
                         icon_url=ctx.avatar)

        if winner:
            _base_multiplier = util.random(.5, .95)
            profit = round(amount * _base_multiplier)
            await ctx.bot.db.add("users", "shrimp", ctx.author, profit)
            new = await ctx.bot.db.get("users", ctx.author, "shrimp")

            embed.colour = core.GREEN
            embed.add_field(
                name="Winner!",
                value=
                (f"You won {core.SHRIMP} **{profit:,} shrimp**. ({round(_base_multiplier*100)}%)\n"
                 f"You now have {core.SHRIMP} **{new:,} shrimp**."),
                inline=False)
        elif draw:
            embed.colour = core.YELLOW
            embed.add_field(
                name="Draw!",
                value=(f"Our sums are the same. Try again later..?"),
                inline=False)
        else:
            await ctx.bot.db.add("users", "shrimp", ctx.author, -amount)
            new = await ctx.bot.db.get("users", ctx.author, "shrimp")

            embed.colour = core.RED
            embed.add_field(
                name="Loser!",
                value=(f"You lost {core.SHRIMP} **{amount:,} shrimp.**\n"
                       f"You now have {core.SHRIMP} **{new:,} shrimp**."),
                inline=False)

        embed.add_field(name=ctx.author.name + f" ({sum(rolls)})",
                        value=_format_rolls(rolls))
        embed.add_field(name=ctx.bot.user.name + f" ({sum(my_rolls)})",
                        value=_format_rolls(my_rolls))

        _ = await ctx.send(
            f"{core.LOADING} Rolling your dice... (Bet: {amount:,})",
            embed_perms=True)
        await asyncio.sleep(util.random(2., 4.))

        await ctx.maybe_edit(_,
                             content="",
                             embed=embed,
                             allowed_mentions=discord.AllowedMentions.none())
        await ctx.bot.db.add_xp(ctx.author, util.random(2, 4))
Example #16
0
 async def _use_clover(self, ctx, _):
     async with Loading(ctx, "Using your clover..."):
         await asyncio.sleep(random(1.5, 3.))
     await ctx.send("idiot")
Example #17
0
            return await ctx.send(
                f"You only own {owned:,} out of the requested {quantity:,} items."
            )

        args = (ctx, item)
        if item.use_multiple:
            args = (ctx, item, quantity)

        try:
            await items.use_item(item.usage, *args)
        except items.ItemUsageFailure:
            return
        else:
            if item.dispose:
                await ctx.db.add("items", item.id, ctx.author, -quantity)
        await ctx.db.add_xp(ctx.author, util.random(2, 4))

    @core.command(
        name="buy",
        aliases=("b", "purchase"),
        usage="<item> [quantity=1]",
        brief="Buy an item.",
        description=(
            "Buy an item. You can provide arguments such as "
            "\"all\", \"half\", fractions, numbers, or percentages to "
            "buy in bulk."),
        cooldown=(4, 2),
        examples=("buy clover", "buy clover 4", "buy clover all"))
    async def _buy(self, ctx, *, query):
        _use_after = False
        _temp_split = query.split()