Altered game class

This commit is contained in:
2025-11-23 00:17:11 +01:00
parent feb5fa0615
commit fa841e328e

View File

@@ -9,7 +9,7 @@ class Game {
final String name; final String name;
final List<Player>? players; final List<Player>? players;
final Group? group; final Group? group;
final String? winner; final Player? winner;
Game({ Game({
String? id, String? id,
@@ -17,7 +17,7 @@ class Game {
required this.name, required this.name,
this.players, this.players,
this.group, this.group,
this.winner = '', this.winner,
}) : id = id ?? const Uuid().v4(), }) : id = id ?? const Uuid().v4(),
createdAt = createdAt ?? clock.now(); createdAt = createdAt ?? clock.now();
@@ -37,7 +37,7 @@ class Game {
.toList() .toList()
: null, : null,
group = json['group'] != null ? Group.fromJson(json['group']) : null, group = json['group'] != null ? Group.fromJson(json['group']) : null,
winner = json['winner'] ?? ''; winner = json['winner'] != null ? Player.fromJson(json['winner']) : null;
/// Converts the Game instance to a JSON object. /// Converts the Game instance to a JSON object.
Map<String, dynamic> toJson() => { Map<String, dynamic> toJson() => {
@@ -46,6 +46,6 @@ class Game {
'name': name, 'name': name,
'players': players?.map((player) => player.toJson()).toList(), 'players': players?.map((player) => player.toJson()).toList(),
'group': group?.toJson(), 'group': group?.toJson(),
'winner': winner, 'winner': winner?.toJson(),
}; };
} }