re-doing some logic to abstract getting boss info from the API
All checks were successful
Build and push / changes (push) Successful in 3s
Build and push / Lint-Python (push) Successful in 6s
Build and push / Build-and-Push-Docker (push) Successful in 18s
Build and push / sync-argocd-app (push) Successful in 2s

This commit is contained in:
Luke R 2024-11-06 09:11:31 -08:00
parent 428d06e727
commit 6f0114e0d2
2 changed files with 73 additions and 34 deletions

View File

@ -170,45 +170,14 @@ class Tarkov(commands.Cog):
embed.set_author(name="Boss Spawn chances by map")
embed.set_thumbnail(url="https://i.ytimg.com/vi/Yis5rmgo_bM/maxresdefault.jpg")
query = """
{
maps(lang: en, gameMode: pve) {
name
bosses{
spawnChance
boss{
name
}
}
}
}
"""
dont_care = [
"assault",
"ExUsec",
"Infected",
"infectedPmc",
"BEAR",
"USEC",
"Rogue",
]
headers = {"Content-Type": "application/json"}
response = tarkov.query_tarkov_api(query)["maps"]
# Wasteful, but make a new dict to hold the info we care about
levels = {}
for level in response:
levels[level["name"]] = {
boss["boss"]["name"]: boss["spawnChance"]
for boss in level["bosses"]
if boss["boss"]["name"] not in dont_care
}
levels = tarkov.tarkov_boss_info()
for key, value in levels.items():
embed.add_field(
name=key,
value="\n".join(
f"{k}: **{str(round(v*100, 2))}%**" for k, v in value.items()
f"{k}: **{str(round(v['spawnChance'],2))}%**"
for k, v in value.items()
),
inline=False,
)
@ -241,6 +210,21 @@ class Tarkov(commands.Cog):
response = requests.get(wiki_url + boss_name).text
soup = BeautifulSoup(response, "html.parser")
# boss_info = tarkov.tarkov_boss_info()
# for k, v in boss_info.items():
# if boss_name in v:
# print(k, v)
# embed.set_thumbnail(url=v[boss_name]["picture"])
# embed.add_field(
# name="Followers", value=v[boss_name]["escorts"], inline=False
# )
# embed.add_field(
# name="Spawn Chance",
# value=f"{v[boss_name]['spawnChance']}",
# inline=False,
# )
# break
portraits = tarkov.query_tarkov_api(
"""{
bosses(lang: en, gameMode:pve) {

View File

@ -28,3 +28,58 @@ def query_tarkov_api(query):
return requests.post(
"https://api.tarkov.dev/graphql", headers=headers, json={"query": query}
).json()["data"]
def tarkov_boss_info():
"""
Returns a dict of boss spawn chances per map, and their escorts
"""
query = """{
maps {
name
bosses {
name
spawnChance
escorts {
boss {
name
}
amount {
count
}
}
boss {
name
imagePortraitLink
}
}
}
}"""
dont_care = [
"assault",
"Infected",
"BEAR",
"USEC",
"Rogue",
]
headers = {"Content-Type": "application/json"}
response = query_tarkov_api(query)["maps"]
# Wasteful, but make a new dict to hold the info we care about
levels = {}
for level in response:
levels[level["name"]] = {
boss["boss"]["name"]: {
"escorts": sum(
escort["amount"][0]["count"] for escort in boss["escorts"]
),
"spawnChance": f"**{str(round(boss['spawnChance'],2))}%**",
"picture": boss["boss"]["imagePortraitLink"],
}
for boss in level["bosses"]
if boss["boss"]["name"] not in dont_care
}
return levels