Method for randomizing trader levels
This commit is contained in:
parent
fc8962ef7f
commit
43a574ed1d
@ -23,7 +23,7 @@ class Tarkov(commands.Cog):
|
||||
@tarkov.command(
|
||||
guild_ids=core_utils.my_guilds,
|
||||
name="lottery",
|
||||
description="🎰🎲 Loadout lottery 🎲🎰",
|
||||
description="Loadout lottery",
|
||||
)
|
||||
async def make_loadout(self, ctx: commands.Context):
|
||||
weapons = tarkov.request_wiki("Weapons", "Weapons")
|
||||
@ -33,13 +33,12 @@ class Tarkov(commands.Cog):
|
||||
backpacks = tarkov.request_wiki("Backpacks", "Backpacks")
|
||||
gun_mods_trader_level = [
|
||||
"Use it as it comes from a trader",
|
||||
random.randint(1, 4),
|
||||
"Any level is allowed",
|
||||
tarkov.allowed_level_roll(),
|
||||
]
|
||||
armor_trader_level = [random.randint(1, 4), "Any level trader armor is allowed"]
|
||||
armor_trader_level = tarkov.allowed_level_roll()
|
||||
|
||||
embed = discord.Embed(
|
||||
title="Loadout Lottery",
|
||||
title="🎲🎰 Loadout Lottery 🎰🎲",
|
||||
description="Your loadout sir",
|
||||
color=discord.Color.red(),
|
||||
type="rich",
|
||||
@ -69,9 +68,9 @@ class Tarkov(commands.Cog):
|
||||
embed.add_field(
|
||||
name="Ammo Trader level",
|
||||
inline=False,
|
||||
value=random.choice(
|
||||
[random.randint(1, 4), "Any level trader ammo is allowed"]
|
||||
),
|
||||
value=tarkov.allowed_level_roll()
|
||||
+ ", "
|
||||
+ f"{str(random.randint(1,5))} magazines",
|
||||
)
|
||||
|
||||
embed.add_field(
|
||||
@ -90,23 +89,13 @@ class Tarkov(commands.Cog):
|
||||
value=random.choice(backpacks),
|
||||
)
|
||||
|
||||
embed.add_field(
|
||||
name="Ears",
|
||||
inline=False,
|
||||
value="Allowed" if random.randint(0, 1) == 1 else "None",
|
||||
)
|
||||
embed.add_field(name="Ears", inline=False, value=tarkov.allowed_level_roll())
|
||||
|
||||
embed.add_field(
|
||||
name="Throwables",
|
||||
inline=False,
|
||||
value="Allowed" if random.randint(0, 1) == 1 else "None",
|
||||
name="Throwables", inline=False, value=tarkov.allowed_level_roll()
|
||||
)
|
||||
|
||||
embed.add_field(
|
||||
name="Meds",
|
||||
inline=False,
|
||||
value="Allowed" if random.randint(0, 1) == 1 else "None",
|
||||
)
|
||||
embed.add_field(name="Meds", inline=False, value=tarkov.allowed_level_roll())
|
||||
|
||||
await ctx.defer()
|
||||
await ctx.send_followup(embed=embed)
|
||||
|
@ -1,5 +1,6 @@
|
||||
from bs4 import BeautifulSoup
|
||||
import requests
|
||||
import random
|
||||
|
||||
|
||||
def request_wiki(url, heading):
|
||||
@ -9,3 +10,14 @@ def request_wiki(url, heading):
|
||||
soup = BeautifulSoup(response, "html.parser")
|
||||
h2_heading = soup.find(f"h2", string=f'Pages in category "{heading}"')
|
||||
return [link.text for link in h2_heading.find_next("div").find_all("a")]
|
||||
|
||||
|
||||
def allowed_level_roll():
|
||||
message = "None"
|
||||
allowed = random.randint(0, 1) == 1
|
||||
if allowed:
|
||||
message = "Allowed"
|
||||
message += ", Trader level: " + random.choice(
|
||||
[str(random.randint(1, 4)), "Any level"]
|
||||
)
|
||||
return message
|
||||
|
Loading…
x
Reference in New Issue
Block a user