Huge! Got it to compare spawn rates and post accordingly
This commit is contained in:
parent
b5316f6877
commit
14c86eca90
@ -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)
|
||||||
|
|
||||||
|
@ -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
|
||||||
|
Loading…
x
Reference in New Issue
Block a user