/// نوع میز (از catalog.table_tiers در GET /api/shop).
class TableTier {
  final String id;
  final String title;
  final int hands;
  final int entry;
  final int prize;
  final int xp;
  final int trophy;
  final int rankReward; // > 0 ⇒ میزِ رتبه‌بندی (به برنده امتیازِ رتبه می‌دهد)

  const TableTier({
    required this.id,
    required this.title,
    required this.hands,
    required this.entry,
    required this.prize,
    required this.xp,
    required this.trophy,
    this.rankReward = 0,
  });

  /// آیا این میزِ رتبه‌بندی است؟ (برد امتیازِ رتبه می‌دهد و در جدولِ قهرمانان بالا می‌برد)
  bool get isRanked => rankReward > 0;

  factory TableTier.fromJson(Map<String, dynamic> j) => TableTier(
        id: j['id'] as String,
        title: j['title'] as String,
        hands: (j['hands'] ?? 0) as int,
        entry: (j['entry'] ?? 0) as int,
        prize: (j['prize'] ?? 0) as int,
        xp: (j['xp'] ?? 0) as int,
        trophy: (j['trophy'] ?? 0) as int,
        rankReward: (j['rank_reward'] ?? 0) as int,
      );
}

/// اطلاعات سهمیه‌ی میزهای خصوصی (GET /api/tables/info).
class TablesInfo {
  final int remaining;
  final bool unlimited;
  const TablesInfo(this.remaining, this.unlimited);

  factory TablesInfo.fromJson(Map<String, dynamic> j) => TablesInfo(
        (j['remaining'] ?? 0) as int,
        (j['unlimited'] ?? false) as bool,
      );
}
