Skip to content

Commit

Permalink
Add multichug for vault potions
Browse files Browse the repository at this point in the history
  • Loading branch information
Iapetus-11 committed Jul 11, 2024
1 parent 5c752d7 commit 65d73ac
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions bot/cogs/commands/econ.py
Original file line number Diff line number Diff line change
Expand Up @@ -1577,8 +1577,8 @@ async def use_item(self, ctx: Ctx, *, thing):

if thing == "vault potion":
# TODO: Multi-chug https://github.com/Iapetus-11/Baby-Villager-Bot/commit/da613f3eb13278ef307d609ca2896ff4dd73d61b
if amount > 1:
await ctx.reply_embed(ctx.l.econ.use.stupid_1)
if amount > 100:
await ctx.reply_embed("You can't use more than 100 **{}** at once".format('Vault Potion'))
return

db_user = await self.db.fetch_user(ctx.author.id)
Expand All @@ -1589,15 +1589,17 @@ async def use_item(self, ctx: Ctx, *, thing):
await ctx.reply_embed(ctx.l.econ.use.vault_max)
return

add = random.randint(9, 15)
vault_max_adds_cumsum = numpy.cumsum(numpy.random.randint(9, 15, size=amount))
used_amount_index = int(next(iter(reversed(numpy.where((vault_max_adds_cumsum + db_user.vault_max) <= vault_max_cap)[0])), 0))
vault_max_add = int(vault_max_adds_cumsum[used_amount_index])

if db_user.vault_max + add > vault_max_cap:
add = vault_max_cap - db_user.vault_max
if db_user.vault_max + vault_max_add > vault_max_cap:
vault_max_add = vault_max_cap - db_user.vault_max

await self.db.remove_item(ctx.author.id, "Vault Potion", 1)
await self.db.set_vault(ctx.author.id, db_user.vault_balance, db_user.vault_max + add)
await self.db.remove_item(ctx.author.id, "Vault Potion", used_amount_index + 1)
await self.db.set_vault(ctx.author.id, db_user.vault_balance, db_user.vault_max + vault_max_add)

await ctx.reply_embed(ctx.l.econ.use.vault_pot.format(add))
await ctx.reply_embed(ctx.l.econ.use.vault_pot.format(vault_max_add)) # TODO: Fix message to incorporate amount
return

if thing == "honey jar":
Expand Down

0 comments on commit 65d73ac

Please sign in to comment.