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

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

  factory Game.fromMap(Map<String, dynamic> map) {
    return Game(
      // O "?." converte para texto com segurança, e o "?? '...'" diz o que mostrar se for nulo (vazio)
      id: map['id']?.toString() ?? '',
      myTeam: map['my_team']?.toString() ?? 'Desconhecida',
      opponentTeam: map['opponent_team']?.toString() ?? 'Adversário',
      myScore: map['my_score']?.toString() ?? '0',
      opponentScore: map['opponent_score']?.toString() ?? '0',
      status: map['status']?.toString() ?? 'Terminado',
      season: map['season']?.toString() ?? 'Sem Época',
    );
  }
}