class Score { final String id; final String memberId; final String eventId; final String clubId; final List frames; final int totalScore; final int? handicap; // 핸디캡 추가 final DateTime date; final String? notes; final String? participantName; Score({ required this.id, required this.memberId, required this.eventId, required this.clubId, required this.frames, required this.totalScore, this.handicap, required this.date, this.notes, this.participantName, }); // 핸디캡 포함 총점 계산 int get totalWithHandicap => totalScore + (handicap ?? 0); factory Score.fromJson(Map json) { return Score( id: json['id']?.toString() ?? '', memberId: json['memberId']?.toString() ?? '', eventId: json['eventId']?.toString() ?? '', clubId: json['clubId']?.toString() ?? '', frames: json['frames'] != null ? List.from(json['frames']) : [], totalScore: json['totalScore'] ?? 0, handicap: json['handicap'], date: json['date'] != null ? DateTime.parse(json['date'].toString()) : DateTime.now(), notes: json['notes']?.toString(), participantName: json['participantName']?.toString(), ); } Map toJson() { return { 'id': id, 'memberId': memberId, 'eventId': eventId, 'clubId': clubId, 'frames': frames, 'totalScore': totalScore, 'handicap': handicap, 'date': date.toIso8601String(), 'notes': notes, 'participantName': participantName, }; } } class ScoreStatistics { final double average; final int highScore; final int lowScore; final int gamesPlayed; final Map? additionalStats; ScoreStatistics({ required this.average, required this.highScore, required this.lowScore, required this.gamesPlayed, this.additionalStats, }); factory ScoreStatistics.fromJson(Map json) { return ScoreStatistics( average: json['average'] != null ? (json['average'] is int ? (json['average'] as int).toDouble() : json['average'].toDouble()) : 0.0, highScore: json['highScore'] ?? 0, lowScore: json['lowScore'] ?? 0, gamesPlayed: json['gamesPlayed'] ?? 0, additionalStats: json['additionalStats'], ); } Map toJson() { return { 'average': average, 'highScore': highScore, 'lowScore': lowScore, 'gamesPlayed': gamesPlayed, 'additionalStats': additionalStats, }; } }