class Game {
  final String id;
  final String myTeam;
  final String opponentTeam;
  final String myScore;
  final String opponentScore;
  final String season;
  final String status;
  final DateTime date;

  Game({
    required this.id,
    required this.myTeam,
    required this.opponentTeam,
    required this.myScore,
    required this.opponentScore,
    required this.season,
    required this.status,
    required this.date,
  });

  // Converte dados do Supabase para o Objeto Dart
  factory Game.fromMap(Map<String, dynamic> map) {
    return Game(
      id: map['id'] ?? '',
      myTeam: map['my_team'] ?? 'Desconhecido',
      opponentTeam: map['opponent_team'] ?? 'Desconhecido',
      // Convertemos para String porque no DB é Integer, mas na UI usas String
      myScore: (map['my_score'] ?? 0).toString(),
      opponentScore: (map['opponent_score'] ?? 0).toString(),
      season: map['season'] ?? '',
      status: map['status'] ?? 'Brevemente',
      date: map['game_date'] != null 
          ? DateTime.parse(map['game_date']) 
          : DateTime.now(),
    );
  }
}