quests quefaire (explicit level)

This commit is contained in:
Amazed 2020-09-25 01:12:17 +02:00
parent 0ccf8ad720
commit f9e9300365

View File

@ -288,7 +288,9 @@ class WynncraftCog(commands.Cog):
self.config.register_global(**default_global) self.config.register_global(**default_global)
@commands.command() @commands.command()
async def quefaire(self, ctx): async def quefaire(self, ctx, explicit_level: int = 0):
if explicit_level == 0:
# check for class then quests
player_name = ctx.author.display_name player_name = ctx.author.display_name
req = requests.get("https://api.wynncraft.com/v2/player/%s/stats" % player_name).json() req = requests.get("https://api.wynncraft.com/v2/player/%s/stats" % player_name).json()
if not req["data"]: if not req["data"]:
@ -303,6 +305,8 @@ class WynncraftCog(commands.Cog):
await ctx.send(":x: impossible de t'aider, je ne te trouve pas ta classe sur Wynncraft :(") await ctx.send(":x: impossible de t'aider, je ne te trouve pas ta classe sur Wynncraft :(")
return return
level = max_class["professions"]["combat"]["level"]
# check for available quests # check for available quests
quests = await self.config.quests() quests = await self.config.quests()
quests.reverse() quests.reverse()
@ -310,10 +314,12 @@ class WynncraftCog(commands.Cog):
if quest["name"] in max_class["quests"]["list"]: if quest["name"] in max_class["quests"]["list"]:
continue # player has already done this quest continue # player has already done this quest
if quest["level"] <= max_class["professions"]["combat"]["level"] and max_class["professions"]["combat"]["level"] - quest["level"] < 10: if quest["level"] <= level and level - quest["level"] < 10:
# quest is doable # quest is doable
await ctx.send(":dizzy: Woosh! Tu peux faire la quête **%s** (%s)" % (quest["name"], quest["url"])) await ctx.send(":dizzy: Woosh! Tu peux faire la quête **%s** (%s)" % (quest["name"], quest["url"]))
return return
else:
level = explicit_level
# check for dungeons and grind spots # check for dungeons and grind spots
dungeons = await self.config.dungeons() dungeons = await self.config.dungeons()
@ -324,12 +330,12 @@ class WynncraftCog(commands.Cog):
hints = [] hints = []
for dungeon in dungeons: for dungeon in dungeons:
if max_class["professions"]["combat"]["level"] >= dungeon["minlevel"] and max_class["professions"]["combat"]["level"] - dungeon["minlevel"] < 10: if level >= dungeon["minlevel"] and level - dungeon["minlevel"] < 10:
hints.append(":cyclone: Tu peux faire le donjon **%s** aux coordonnées %s (%s)" % (dungeon["name"], dungeon["location"], dungeon["url"])) hints.append(":cyclone: Tu peux faire le donjon **%s** aux coordonnées %s (%s)" % (dungeon["name"], dungeon["location"], dungeon["url"]))
break break
for grind_spot in grind_spots: for grind_spot in grind_spots:
if grind_spot["minlevel"] <= max_class["professions"]["combat"]["level"] <= grind_spot["maxlevel"]: if grind_spot["minlevel"] <= level <= grind_spot["maxlevel"]:
hints.append(":star: Tu peux grinder aux coordonnées %s jusqu'au niveau %s" % (grind_spot["location"], grind_spot["maxlevel"])) hints.append(":star: Tu peux grinder aux coordonnées %s jusqu'au niveau %s" % (grind_spot["location"], grind_spot["maxlevel"]))
break break