Had to change access to scores. Somewhat weird due to them being dicts and dicts being difficult to access by index.

This commit is contained in:
alwayscompiling
2022-07-29 16:35:45 -04:00
parent 9e9d616814
commit 306f983c8e
+10 -9
View File
@@ -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