import json import os LEADERBOARD_FILE = "leaderboard.json" def load_leaderboard(): if not os.path.exists(LEADERBOARD_FILE): return {} with open(LEADERBOARD_FILE, 'r') as f: return json.load(f) def get_fun_stats() -> str: leaderboard = load_leaderboard() if not leaderboard: return "No stats available yet." total_battles = sum(data['wins'] + data['losses'] for data in leaderboard.values()) total_wins = sum(data['wins'] for data in leaderboard.values()) total_losses = sum(data['losses'] for data in leaderboard.values()) win_rate = (total_wins / total_battles * 100) if total_battles > 0 else 0 stats_html = f""" """ return stats_html