Refactoring

This commit is contained in:
2026-04-12 01:59:51 +02:00
parent eeb68496d5
commit 8a312152a5
12 changed files with 317 additions and 362 deletions

View File

@@ -3,7 +3,7 @@ import 'package:tallee/core/enums.dart';
import 'package:tallee/data/models/game.dart';
import 'package:tallee/data/models/group.dart';
import 'package:tallee/data/models/player.dart';
import 'package:tallee/data/models/score.dart';
import 'package:tallee/data/models/score_entry.dart';
import 'package:uuid/uuid.dart';
class Match {
@@ -15,7 +15,7 @@ class Match {
final Group? group;
final List<Player> players;
final String notes;
Map<String, List<Score>> scores;
Map<String, List<ScoreEntry>> scores;
Player? winner;
Match({
@@ -27,7 +27,7 @@ class Match {
this.group,
this.players = const [],
this.notes = '',
Map<String, List<Score>>? scores,
Map<String, List<ScoreEntry>>? scores,
this.winner,
}) : id = id ?? const Uuid().v4(),
createdAt = createdAt ?? clock.now(),

View File

@@ -1,18 +0,0 @@
class Score {
final int roundNumber;
int score = 0;
int change = 0;
Score({required this.roundNumber, required this.score, required this.change});
Score.fromJson(Map<String, dynamic> json)
: roundNumber = json['roundNumber'],
score = json['score'],
change = json['change'];
Map<String, dynamic> toJson() => {
'roundNumber': roundNumber,
'score': score,
'change': change,
};
}

View File

@@ -0,0 +1,22 @@
class ScoreEntry {
int roundNumber = 0;
final int score;
final int change;
ScoreEntry({
required this.roundNumber,
required this.score,
required this.change,
});
ScoreEntry.fromJson(Map<String, dynamic> json)
: roundNumber = json['roundNumber'],
score = json['score'],
change = json['change'];
Map<String, dynamic> toJson() => {
'roundNumber': roundNumber,
'score': score,
'change': change,
};
}