Ensure formatting lines up times and right justifies int scores.
This commit is contained in:
+8
-5
@@ -36,13 +36,16 @@ def format_highscore_message(boss_name: str, guild_data: dict):
|
|||||||
username: str = score_pair[0].ljust(guild_data["username_length"], " ")
|
username: str = score_pair[0].ljust(guild_data["username_length"], " ")
|
||||||
score: str = str(score_pair[1])
|
score: str = str(score_pair[1])
|
||||||
|
|
||||||
|
# pad score to correct length
|
||||||
|
# MM:SS.ms is 7 characters long
|
||||||
if highscores_config["categories"][key]["is_time_record"]:
|
if highscores_config["categories"][key]["is_time_record"]:
|
||||||
# pad score to correct length
|
# if there are single digit minutes, add a space for formatting.
|
||||||
# MM:SS.ms is 7 characters long
|
if score.find(":") and len(score.split(":", maxsplit=1)[0]) < 2:
|
||||||
score = score.ljust(7, " ")
|
score = " " + score
|
||||||
|
else:
|
||||||
|
score = score.rjust(7, " ")
|
||||||
|
|
||||||
line_str = f"{i+1}: {username} - "
|
ret_string += f"{i+1}: {username} - {score}".ljust(26, " ")
|
||||||
ret_string += line_str + score.rjust(26 - len(line_str) - 1) + " "
|
|
||||||
else:
|
else:
|
||||||
ret_string += f"{i+1}: submit your score".ljust(26, " ")
|
ret_string += f"{i+1}: submit your score".ljust(26, " ")
|
||||||
ret_string += "\n"
|
ret_string += "\n"
|
||||||
|
|||||||
Reference in New Issue
Block a user