/// یک ردیف از جدولِ رتبه‌بندی.
class RankEntry {
  final int rank;
  final String name;
  final String avatar;
  final int rankPoints;
  final String tier; // bronze..king

  RankEntry.fromJson(Map<String, dynamic> j)
      : rank = (j['rank'] ?? 0) as int,
        name = (j['name'] ?? '') as String,
        avatar = (j['avatar'] ?? '') as String,
        rankPoints = (j['rank_points'] ?? 0) as int,
        tier = (j['tier'] ?? 'bronze') as String;
}

/// جدولِ رتبه‌بندیِ فصلِ جاری.
class Leaderboard {
  final int season;
  final List<RankEntry> entries;
  const Leaderboard(this.season, this.entries);

  factory Leaderboard.fromJson(Map<String, dynamic> j) => Leaderboard(
        (j['season'] ?? 1) as int,
        ((j['entries'] as List?) ?? [])
            .map((e) => RankEntry.fromJson(Map<String, dynamic>.from(e as Map)))
            .toList(),
      );
}
