feat: implemented team score handling
This commit is contained in:
@@ -231,8 +231,13 @@ class Match {
|
||||
}
|
||||
|
||||
List<Team> _getHighestScoreTeam() {
|
||||
if (teams!.every((team) => team.score == null)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
final int highestScore = teams!
|
||||
.map((team) => team.score)
|
||||
.whereType<int>()
|
||||
.reduce((max, score) => score > max ? score : max);
|
||||
|
||||
return teams!.where((team) {
|
||||
@@ -241,8 +246,13 @@ class Match {
|
||||
}
|
||||
|
||||
List<Team> _getLowestScoreTeam() {
|
||||
if (teams!.every((team) => team.score == null)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
final int lowestScore = teams!
|
||||
.map((team) => team.score)
|
||||
.whereType<int>()
|
||||
.reduce((min, score) => score < min ? score : min);
|
||||
|
||||
return teams!.where((team) {
|
||||
|
||||
@@ -9,7 +9,7 @@ class Team {
|
||||
final String name;
|
||||
final DateTime createdAt;
|
||||
final GameColor color;
|
||||
final int score;
|
||||
final int? score;
|
||||
final List<Player> members;
|
||||
|
||||
Team({
|
||||
@@ -17,7 +17,7 @@ class Team {
|
||||
required this.name,
|
||||
DateTime? createdAt,
|
||||
this.color = GameColor.blue,
|
||||
this.score = 0,
|
||||
this.score,
|
||||
required this.members,
|
||||
}) : id = id ?? const Uuid().v4(),
|
||||
createdAt = createdAt ?? clock.now();
|
||||
|
||||
Reference in New Issue
Block a user