Skip to content

Commit

Permalink
Format + add translations for vault pot multicug
Browse files Browse the repository at this point in the history
  • Loading branch information
Iapetus-11 committed Jul 11, 2024
1 parent 65d73ac commit 880239b
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 16 deletions.
39 changes: 28 additions & 11 deletions bot/cogs/commands/econ.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ def msg_check(m):

def get_vault_max_cap_from_pickaxe(self, pickaxe: str) -> int:
pickaxe_level = len(self.d.mining.pickaxes) - self.d.mining.pickaxes.index(pickaxe)
return 2000 * (pickaxe_level ** 3)
return 2000 * (pickaxe_level**3)

async def randomly_increase_vault(
self,
Expand All @@ -139,13 +139,13 @@ async def randomly_increase_vault(
pickaxe: str | None = None,
):
if user_id is None and db_user is None:
raise ValueError('This function requires you to specify at least user_id or user')
raise ValueError("This function requires you to specify at least user_id or user")

if user_id is None:
user_id = db_user.user_id

if lucky is None:
lucky = await self.karen.check_active_fx(user_id, 'Luck Potion')
lucky = await self.karen.check_active_fx(user_id, "Luck Potion")

if random.randint(0, 50) == 1 or (lucky and random.randint(1, 25) == 1):
if db_user is None:
Expand Down Expand Up @@ -1576,10 +1576,7 @@ async def use_item(self, ctx: Ctx, *, thing):
return

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

db_user = await self.db.fetch_user(ctx.author.id)
pickaxe = await self.db.fetch_pickaxe(ctx.author.id)
Expand All @@ -1590,16 +1587,36 @@ async def use_item(self, ctx: Ctx, *, thing):
return

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))
used_amount_index = int(
next(
iter(
reversed(
numpy.where(
(vault_max_adds_cumsum + db_user.vault_max) <= vault_max_cap
)[0]
)
),
0,
)
)
amount = used_amount_index + 1
vault_max_add = int(vault_max_adds_cumsum[used_amount_index])

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", used_amount_index + 1)
await self.db.set_vault(ctx.author.id, db_user.vault_balance, db_user.vault_max + vault_max_add)
await self.db.remove_item(ctx.author.id, "Vault Potion", amount)
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(vault_max_add)) # TODO: Fix message to incorporate amount
await ctx.reply_embed(
(
ctx.l.econ.use.vault_pot_singular
if amount == 1
else ctx.l.econ.use.vault_pot_plural
).format(vault_max_add, amount=amount)
)
return

if thing == "honey jar":
Expand Down
3 changes: 2 additions & 1 deletion bot/data/text/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -2011,7 +2011,8 @@
"stupid_5": "You can't use more items than you have!",
"stupid_6": "Either that isn't a usable item, or it doesn't exist.",
"vault_max": "You cannot expand your vault further via this method.",
"vault_pot": "You've chugged a **Vault Potion**. Your vault space has increased by {} spaces.",
"vault_pot_singular": "You've chugged a **Vault Potion**. Your vault space has increased by {} spaces.",
"vault_pot_plural": "You've chugged {amount} **Vault Potion**s. Your vault space has increased by {} spaces.",
"smoke_seaweed": "You've eaten some **Seaweed** which lasts **{} minutes**",
"use_bonemeal": "You've used some **Bone Meal** on your crops, making them grow!",
"seaweed_done": "The **Seaweed** you ate earlier has worn off.",
Expand Down
3 changes: 2 additions & 1 deletion bot/data/text/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -2011,7 +2011,8 @@
"stupid_5": "¡No puedes usar más objetos de los que tienes!",
"stupid_6": "O eso no es un objeto utilizable, o no existe.",
"vault_max": "No se puede expandir más la bóveda con este método.",
"vault_pot": "Te has tomado una **Poción de Bóveda**. El espacio de tu bóveda se ha incrementado en {} espacios.",
"vault_pot_singular": "Bebiste una **Vault Potion**. La capacidad de tu baúl ha aumentado {} espacios.",
"vault_pot_plural": "Bebiste {amount} **Vault Potion**s. La capacidad de tu baúl ha aumentado {} espacios.",
"smoke_seaweed": "Te has comido un **alga** que dura **{} minutos**",
"use_bonemeal": "¡Has usado un **Polvo de Hueso** en tus cultivos, haciéndolos crecer!",
"seaweed_done": "El **Alga** que te has comido antes ya no tiene efecto.",
Expand Down
3 changes: 2 additions & 1 deletion bot/data/text/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -2011,7 +2011,8 @@
"stupid_5": "Tu ne peux pas utiliser plus d'objet que tu en as !",
"stupid_6": "Soit cet objet est inutilisable, soit il n'existe pas.",
"vault_max": "Tu ne peux plus agrandir ton coffre de cette manière.",
"vault_pot": "Tu as descendu une **Vault Potion**. Ton coffre s'est agrandi de {} emplacements.",
"vault_pot_singular": "Vous avez bu une **Vault Potion**. La taille de votre coffre a augmenté de {} espaces.",
"vault_pot_plural": "Vous avez bu {amount} **Vault Potion**s. La taille de votre coffre a augmenté de {} espaces.",
"smoke_seaweed": "Tu as mangé des **Seaweed** dont les effets durent **{} minutes**",
"use_bonemeal": "Vous avez utilisé de la Boudre d'Os sur vos cultures, les faisant pousser!",
"seaweed_done": "Les effets des **Seaweed** que tu as mangés plus tôt se sont dissipés.",
Expand Down
3 changes: 2 additions & 1 deletion bot/data/text/pt.json
Original file line number Diff line number Diff line change
Expand Up @@ -2011,7 +2011,8 @@
"stupid_5": "Você não pode usar mais itens do que você tem!",
"stupid_6": "Ou isso não é um item utilizável ou não existe.",
"vault_max": "Você não pode expandir seu cofre ainda mais através deste método.",
"vault_pot": "Você tomou uma **Poção de Cofre**. O espaço do seu cofre aumentou em {} espaços.",
"vault_pot_singular": "Você bebeu uma **Vault Potion**. O espaço do seu cofre aumentou em {} espaços.",
"vault_pot_plural": "Você bebeu {amount} **Vault Potion**s. O espaço do seu cofre aumentou em {} espaços.",
"smoke_seaweed": "Você comeu algumas **Algas** que duram **{} minutos**",
"use_bonemeal": "Você usou um pouco de **Farinha de Osso** em suas plantações, fazendo-as crescer!",
"seaweed_done": "A **Alga** que você comeu antes já passou.",
Expand Down
3 changes: 2 additions & 1 deletion bot/models/translation.py
Original file line number Diff line number Diff line change
Expand Up @@ -661,7 +661,8 @@ class Econ_Use(ImmutableBaseModel):
stupid_5: str
stupid_6: str
vault_max: str
vault_pot: str
vault_pot_singular: str
vault_pot_plural: str
smoke_seaweed: str
use_bonemeal: str
seaweed_done: str
Expand Down

0 comments on commit 880239b

Please sign in to comment.