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