Skip to content

Commit

Permalink
Adding a lot more detail/text for bug fixing and meaningful errors
Browse files Browse the repository at this point in the history
  • Loading branch information
gaithern committed Dec 28, 2023
1 parent fe3d222 commit fbd3249
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions worlds/lol/Client.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,12 @@ def get_header(api_key):
def get_puuid_by_summoner_name(summoner_name, api_key, region_short):
url = "https://" + region_short + ".api.riotgames.com/lol/summoner/v4/summoners/by-name/" + str(summoner_name)
response = requests.get(url, headers=get_header(api_key))
return json.loads(response.text)["puuid"]
if str(response) == "<Response [403]>":
return "Forbidden, check your API Key"
elif str(response) == "<Response [404]>":
return "Data not found. Check your summoner name or configure your region."
else:
return json.loads(response.text)["puuid"]

def get_last_match_id_by_puuid(puuid, api_key, region_long):
url = "https://" + region_long + ".api.riotgames.com/lol/match/v5/matches/by-puuid/" + str(puuid) + "/ids?start=0&count=1"
Expand Down Expand Up @@ -121,7 +126,14 @@ def _cmd_set_summoner_name(self, summoner_name):
"""Set the PUUID from Riot API using the passed Summoner Name"""
if self.api_key != "":
self.player_puuid = get_puuid_by_summoner_name(summoner_name, self.api_key, self.region_short)
self.output(f"PUUID Set")
if self.player_puuid == "Forbidden, check your API Key":
self.output("Forbidden, check your API Key")
self.player_puuid = ""
elif self.player_puuid == "Data not found. Check your summoner name or configure your region.":
self.output("Data not found. Check your summoner name or configure your region.")
self.player_puuid = ""
else:
self.output(f"PUUID Set")
else:
self.output(f"Please set your API Key")

Expand Down Expand Up @@ -149,7 +161,9 @@ def _cmd_check_last_match(self):
game_mode_offset = get_game_mode_offset(last_match_info["info"]["gameMode"])
if won_match(self.player_puuid, last_match_info):
item_ids_purchased = get_item_ids_purchased(self.player_puuid, last_match_info)
self.output("Item IDs Unlocked: " + str(unlocked_item_ids))
for item_id in item_ids_purchased:
self.output("Item ID Purchased: " + str(int(item_id) + game_mode_offset + 10000000))
if int(item_id) + game_mode_offset in unlocked_item_ids:
new_locations.append(int(item_id) + game_mode_offset + 10000000)
else:
Expand Down

0 comments on commit fbd3249

Please sign in to comment.