class DailyChallenge { final String wordle; final bool attempted; final bool solved; final int? attempts; final DateTime? solveTime; DailyChallenge({ required this.wordle, required this.attempted, required this.solved, this.attempts, this.solveTime, }); factory DailyChallenge.fromJson(Map json) { return DailyChallenge( wordle: json['wordle'] ?? '', attempted: json['attempted'] ?? false, solved: json['solved'] ?? false, attempts: json['attempts'], solveTime: json['solveTime'] != null ? DateTime.parse(json['solveTime']) : null, ); } Map toJson() { return { 'wordle': wordle, 'attempted': attempted, 'solved': solved, 'attempts': attempts, 'solveTime': solveTime?.toIso8601String(), }; } } class DailyChallengeResponse { final bool status; final String? message; final DailyChallenge? data; DailyChallengeResponse({ required this.status, this.message, this.data, }); factory DailyChallengeResponse.fromJson(Map json) { return DailyChallengeResponse( status: json['status'] ?? false, message: json['message'], data: json['data'] != null ? DailyChallenge.fromJson(json['data']) : null, ); } } class PuzzleAttempt { final int attempts; final bool solved; PuzzleAttempt({ required this.attempts, required this.solved, }); Map toJson() { return { 'attempts': attempts, 'solved': solved, }; } } class GameState { final String targetWord; final List guesses; final int currentAttempt; final bool isGameComplete; final bool isWon; final DateTime? solveTime; final String gameDate; GameState({ required this.targetWord, required this.guesses, required this.currentAttempt, required this.isGameComplete, required this.isWon, this.solveTime, required this.gameDate, }); factory GameState.fromJson(Map json) { return GameState( targetWord: json['targetWord'] ?? '', guesses: List.from(json['guesses'] ?? []), currentAttempt: json['currentAttempt'] ?? 0, isGameComplete: json['isGameComplete'] ?? false, isWon: json['isWon'] ?? false, solveTime: json['solveTime'] != null ? DateTime.parse(json['solveTime']) : null, gameDate: json['gameDate'] ?? '', ); } Map toJson() { return { 'targetWord': targetWord, 'guesses': guesses, 'currentAttempt': currentAttempt, 'isGameComplete': isGameComplete, 'isWon': isWon, 'solveTime': solveTime?.toIso8601String(), 'gameDate': gameDate, }; } GameState copyWith({ String? targetWord, List? guesses, int? currentAttempt, bool? isGameComplete, bool? isWon, DateTime? solveTime, String? gameDate, }) { return GameState( targetWord: targetWord ?? this.targetWord, guesses: guesses ?? this.guesses, currentAttempt: currentAttempt ?? this.currentAttempt, isGameComplete: isGameComplete ?? this.isGameComplete, isWon: isWon ?? this.isWon, solveTime: solveTime ?? this.solveTime, gameDate: gameDate ?? this.gameDate, ); } } class LeaderboardEntry { final String displayName; final String username; final String? avatar; final int attempts; final bool solved; final DateTime submittedAt; LeaderboardEntry({ required this.displayName, required this.username, this.avatar, required this.attempts, required this.solved, required this.submittedAt, }); factory LeaderboardEntry.fromJson(Map json) { return LeaderboardEntry( displayName: json['displayName'] ?? '', username: json['username'] ?? '', avatar: json['avatar'], attempts: json['attempts'] ?? 0, solved: json['solved'] ?? false, submittedAt: DateTime.parse(json['submittedAt']), ); } } class LeaderboardResponse { final bool status; final String? message; final List? data; LeaderboardResponse({ required this.status, this.message, this.data, }); factory LeaderboardResponse.fromJson(Map json) { return LeaderboardResponse( status: json['status'] ?? false, message: json['message'], data: json['data'] != null ? (json['data'] as List).map((e) => LeaderboardEntry.fromJson(e)).toList() : null, ); } }