From 306f983c8ed758379fdd0dd66caf6ea2205a427e Mon Sep 17 00:00:00 2001 From: alwayscompiling Date: Fri, 29 Jul 2022 16:35:45 -0400 Subject: [PATCH] Had to change access to scores. Somewhat weird due to them being dicts and dicts being difficult to access by index. --- utilities/utils.py | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/utilities/utils.py b/utilities/utils.py index 64df95e..e7bdd3f 100644 --- a/utilities/utils.py +++ b/utilities/utils.py @@ -17,27 +17,28 @@ def format_highscore_message(boss_name: str, guild_id: int): ret_string = f"**{boss_name}**\n```" # Gather all categories and add to string - for key, value in highscores_data.get_categories_data(guild_id, boss_name): - ret_string += f"{key}".ljust(26, " ") + for category_name in highscores_data.get_table_categories(guild_id, boss_name): + ret_string += f"{category_name}".ljust(26, " ") ret_string += "\n" highscore_size = highscores_data.get_config_highscore_size() # list rankings in a single line. Start with first place for each category and then continue for i in range(highscore_size): - for key, value in highscores_data.get_categories_data(guild_id, boss_name): - if len(value) > i: - score_pair = value[i] - + for category_name, category_data in highscores_data.get_categories_data( + guild_id, boss_name + ): + if len(category_data) > i: # pad username to max length. - username: str = score_pair[0].ljust( + username: str = list(category_data.keys())[i].ljust( highscores_data.get_guild_username_length(guild_id), " " ) - score: str = str(score_pair[1]) + # turns category data value into a string. Very janky. + score: str = str(list(category_data.values())[i][0]) # pad score to correct length # MM:SS.ms is 7 characters long - if highscores_data.get_config_time_record(key): + if highscores_data.get_config_time_record(category_name): # if there are single digit minutes, add a space for formatting. if score.find(":") and len(score.split(":", maxsplit=1)[0]) < 2: score = " " + score