Added caboPlayerIndex in Round-Class

This commit is contained in:
Felix Kirchner
2025-05-03 13:44:44 +02:00
parent 12dfa821ea
commit 96c5df0bcc
3 changed files with 36 additions and 21 deletions

View File

@@ -9,34 +9,40 @@ import 'package:cabo_counter/data/game_session.dart';
/// kamikaze, this value is null.
class Round {
final int roundNum;
final int caboPlayerIndex;
final int? kamikazePlayerIndex;
final List<int> scores;
final List<int> scoreUpdates;
final int? kamikazePlayerIndex;
Round(
{required this.roundNum,
required this.scores,
required this.scoreUpdates,
this.kamikazePlayerIndex});
Round({
required this.roundNum,
required this.caboPlayerIndex,
this.kamikazePlayerIndex,
required this.scores,
required this.scoreUpdates,
});
@override
toString() {
return 'Round $roundNum: scores: $scores, scoreUpdates: $scoreUpdates, '
'kamikazePlayerIndex: $kamikazePlayerIndex';
return 'Round $roundNum, caboPlayerIndex: $caboPlayerIndex, '
'kamikazePlayerIndex: $kamikazePlayerIndex, scores: $scores, '
'scoreUpdates: $scoreUpdates, ';
}
/// Converts the Round object to a JSON map.
Map<String, dynamic> toJson() => {
'roundNum': roundNum,
'caboPlayerIndex': caboPlayerIndex,
'kamikazePlayerIndex': kamikazePlayerIndex,
'scores': scores,
'scoreUpdates': scoreUpdates,
'kamikazePlayerIndex': kamikazePlayerIndex,
};
/// Creates a Round object from a JSON map.
Round.fromJson(Map<String, dynamic> json)
: roundNum = json['roundNum'],
caboPlayerIndex = json['caboPlayerIndex'],
kamikazePlayerIndex = json['kamikazePlayerIndex'],
scores = List<int>.from(json['scores']),
scoreUpdates = List<int>.from(json['scoreUpdates']),
kamikazePlayerIndex = json['kamikazePlayerIndex'];
scoreUpdates = List<int>.from(json['scoreUpdates']);
}