diff --git a/src/highscore.py b/src/highscore.py index 16fae15..6fb57ed 100644 --- a/src/highscore.py +++ b/src/highscore.py @@ -44,4 +44,22 @@ class Highscore: def get_top_scores(self): scores = self.load_scores() scores.sort(key=lambda score: score["ects"], reverse=True) - return scores[:5] \ No newline at end of file + return scores[:5] + + def get_top_scores_formatted(self): + top_scores = self.get_top_scores() + formatted_scores = [] + + for index, score in enumerate(top_scores): + result = "PASSED" if score["won"] else "FAILED" + + line = ( + f"{index + 1}. {score['name']} | " + f"ECTS: {score['ects']} | " + f"Time: {score['time']} | " + f"Result: {result}" + ) + + formatted_scores.append(line) + + return formatted_scores \ No newline at end of file