Renamed ScoreEntry to Score

This commit is contained in:
2026-04-08 23:55:24 +02:00
parent be58c9ce01
commit 73533b8c4f
3 changed files with 12 additions and 12 deletions

View File

@@ -2,7 +2,7 @@ import 'package:drift/drift.dart';
import 'package:tallee/data/db/database.dart'; import 'package:tallee/data/db/database.dart';
import 'package:tallee/data/db/tables/score_table.dart'; import 'package:tallee/data/db/tables/score_table.dart';
import 'package:tallee/data/models/player.dart'; import 'package:tallee/data/models/player.dart';
import 'package:tallee/data/models/score_entry.dart'; import 'package:tallee/data/models/score.dart';
part 'score_dao.g.dart'; part 'score_dao.g.dart';
@@ -31,7 +31,7 @@ class ScoreDao extends DatabaseAccessor<AppDatabase> with _$ScoreDaoMixin {
} }
/// Retrieves the score for a specific round. /// Retrieves the score for a specific round.
Future<ScoreEntry?> getScore({ Future<Score?> getScore({
required String playerId, required String playerId,
required String matchId, required String matchId,
int roundNumber = 0, int roundNumber = 0,
@@ -47,7 +47,7 @@ class ScoreDao extends DatabaseAccessor<AppDatabase> with _$ScoreDaoMixin {
final result = await query.getSingleOrNull(); final result = await query.getSingleOrNull();
if (result == null) return null; if (result == null) return null;
return ScoreEntry( return Score(
playerId: result.playerId, playerId: result.playerId,
matchId: result.matchId, matchId: result.matchId,
roundNumber: result.roundNumber, roundNumber: result.roundNumber,
@@ -57,12 +57,12 @@ class ScoreDao extends DatabaseAccessor<AppDatabase> with _$ScoreDaoMixin {
} }
/// Retrieves all scores for a specific match. /// Retrieves all scores for a specific match.
Future<List<ScoreEntry>> getAllMatchScores({required String matchId}) async { Future<List<Score>> getAllMatchScores({required String matchId}) async {
final query = select(scoreTable)..where((s) => s.matchId.equals(matchId)); final query = select(scoreTable)..where((s) => s.matchId.equals(matchId));
final result = await query.get(); final result = await query.get();
return result return result
.map( .map(
(row) => ScoreEntry( (row) => Score(
playerId: row.playerId, playerId: row.playerId,
matchId: row.matchId, matchId: row.matchId,
roundNumber: row.roundNumber, roundNumber: row.roundNumber,
@@ -74,7 +74,7 @@ class ScoreDao extends DatabaseAccessor<AppDatabase> with _$ScoreDaoMixin {
} }
/// Retrieves all scores for a specific player in a match. /// Retrieves all scores for a specific player in a match.
Future<List<ScoreEntry>> getAllPlayerScoresInMatch({ Future<List<Score>> getAllPlayerScoresInMatch({
required String playerId, required String playerId,
required String matchId, required String matchId,
}) async { }) async {
@@ -84,7 +84,7 @@ class ScoreDao extends DatabaseAccessor<AppDatabase> with _$ScoreDaoMixin {
final result = await query.get(); final result = await query.get();
return result return result
.map( .map(
(row) => ScoreEntry( (row) => Score(
playerId: row.playerId, playerId: row.playerId,
matchId: row.matchId, matchId: row.matchId,
roundNumber: row.roundNumber, roundNumber: row.roundNumber,

View File

@@ -3,7 +3,7 @@ import 'package:tallee/core/enums.dart';
import 'package:tallee/data/models/game.dart'; import 'package:tallee/data/models/game.dart';
import 'package:tallee/data/models/group.dart'; import 'package:tallee/data/models/group.dart';
import 'package:tallee/data/models/player.dart'; import 'package:tallee/data/models/player.dart';
import 'package:tallee/data/models/score_entry.dart'; import 'package:tallee/data/models/score.dart';
import 'package:uuid/uuid.dart'; import 'package:uuid/uuid.dart';
class Match { class Match {
@@ -15,7 +15,7 @@ class Match {
final Group? group; final Group? group;
final List<Player> players; final List<Player> players;
final String notes; final String notes;
List<ScoreEntry> scores; List<Score> scores;
Player? winner; Player? winner;
Match({ Match({

View File

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