Huge! Got it to compare spawn rates and post accordingly

This commit is contained in:
Luke Robles 2024-11-06 12:47:53 -08:00
parent 172ad5be01
commit 5a80297db4
2 changed files with 36 additions and 15 deletions

View File

@ -32,26 +32,26 @@ class Tarkov(commands.Cog):
most_recent_spawns = tarkov.tarkov_boss_info() most_recent_spawns = tarkov.tarkov_boss_info()
if os.path.exists("/tmp/boss_spawns.txt"): if os.path.exists("/tmp/boss_spawns.txt"):
embed = discord.Embed(
description="-------", color=discord.Color.blue(), type="rich"
)
known_spawns = eval(open("/tmp/boss_spawns.txt", "r").read()) known_spawns = eval(open("/tmp/boss_spawns.txt", "r").read())
changes_dict = tarkov.compare_boss_spawns(most_recent_spawns, known_spawns)
if most_recent_spawns != known_spawns: if most_recent_spawns != known_spawns:
print("Boss spawns have changed")
embed = discord.Embed(
description="-------", color=discord.Color.blue(), type="rich"
)
embed.set_author(name="🎲 Boss Spawns have updated 🎲") embed.set_author(name="🎲 Boss Spawns have updated 🎲")
for key, value in most_recent_spawns.items(): # for key, value in most_recent_spawns.items():
embed.add_field(
name=key,
value="\n".join(
f"{k}: {v['spawnChance']}" for k, v in value.items()
),
inline=False,
)
open("/tmp/boss_spawns.txt", "w").write(str(most_recent_spawns)) for level, boss in changes_dict.items():
for mob, change in boss.items():
embed.add_field(
name=level,
value=f"{mob}: {change}",
inline=False,
)
open("/tmp/boss_spawns.txt", "w").write(str(most_recent_spawns))
await self.bot.get_channel(channel_id).send(embed=embed) await self.bot.get_channel(channel_id).send(embed=embed)

View File

@ -82,3 +82,24 @@ def tarkov_boss_info():
} }
return levels return levels
def compare_boss_spawns(dict1, dict2):
changes = {} # To store the changes
for level in dict1:
level_changes = {} # Store changes for each level
for boss in dict1.get(level, {}):
boss_info_1 = dict1[level].get(boss, {})
boss_info_2 = dict2[level].get(boss, {})
spawnChance_1 = boss_info_1.get("spawnChance", "N/A")
spawnChance_2 = boss_info_2.get("spawnChance", "N/A")
if spawnChance_1 != spawnChance_2:
level_changes[boss] = f"{spawnChance_1} -> {spawnChance_2}"
if level_changes:
changes[level] = level_changes
return changes