Merge remote-tracking branch 'origin/development' into bug/195-datenbank-onDelete-ueberpruefen
All checks were successful
Pull Request Pipeline / test (pull_request) Successful in 46s
Pull Request Pipeline / lint (pull_request) Successful in 53s

# Conflicts:
#	assets/schema.json
#	lib/data/db/tables/player_match_table.dart
#	lib/data/models/game.dart
This commit is contained in:
gelbeinhalb
2026-05-12 20:19:50 +02:00
71 changed files with 6396 additions and 5268 deletions

View File

@@ -10,27 +10,60 @@ class Game {
final String description;
final GameColor color;
final String icon;
final bool deleted;
Game({
String? id,
DateTime? createdAt,
required this.name,
required this.ruleset,
String? description,
required this.color,
required this.icon,
this.deleted = false,
this.color = GameColor.orange,
this.description = '',
this.icon = '',
String? id,
DateTime? createdAt,
}) : id = id ?? const Uuid().v4(),
createdAt = createdAt ?? clock.now(),
description = description ?? '';
createdAt = createdAt ?? clock.now();
@override
String toString() {
return 'Game{id: $id, name: $name, ruleset: $ruleset, description: $description, color: $color, icon: $icon}';
}
/// Creates a Game instance from a JSON object.
Game copyWith({
String? id,
DateTime? createdAt,
String? name,
Ruleset? ruleset,
String? description,
GameColor? color,
String? icon,
}) {
return Game(
id: id ?? this.id,
createdAt: createdAt ?? this.createdAt,
name: name ?? this.name,
ruleset: ruleset ?? this.ruleset,
description: description ?? this.description,
color: color ?? this.color,
icon: icon ?? this.icon,
);
}
@override
bool operator ==(Object other) =>
identical(this, other) ||
other is Game &&
runtimeType == other.runtimeType &&
id == other.id &&
createdAt == other.createdAt &&
name == other.name &&
ruleset == other.ruleset &&
description == other.description &&
color == other.color &&
icon == other.icon;
@override
int get hashCode =>
Object.hash(id, createdAt, name, ruleset, description, color, icon);
Game.fromJson(Map<String, dynamic> json)
: id = json['id'],
createdAt = DateTime.parse(json['createdAt']),
@@ -41,10 +74,8 @@ class Game {
),
description = json['description'],
color = GameColor.values.firstWhere((e) => e.name == json['color']),
icon = json['icon'],
deleted = json['deleted'] ?? false;
icon = json['icon'];
/// Converts the Game instance to a JSON object.
Map<String, dynamic> toJson() => {
'id': id,
'createdAt': createdAt.toIso8601String(),
@@ -53,6 +84,5 @@ class Game {
'description': description,
'color': color.name,
'icon': icon,
'deleted': deleted,
};
}

View File

@@ -1,4 +1,5 @@
import 'package:clock/clock.dart';
import 'package:collection/collection.dart';
import 'package:tallee/data/models/player.dart';
import 'package:uuid/uuid.dart';
@@ -26,6 +27,42 @@ class Group {
return 'Group{id: $id, name: $name, description: $description, members: $members}';
}
Group copyWith({
String? id,
String? name,
String? description,
DateTime? createdAt,
List<Player>? members,
}) {
return Group(
id: id ?? this.id,
name: name ?? this.name,
description: description ?? this.description,
createdAt: createdAt ?? this.createdAt,
members: members ?? this.members,
);
}
@override
bool operator ==(Object other) =>
identical(this, other) ||
other is Group &&
runtimeType == other.runtimeType &&
id == other.id &&
name == other.name &&
description == other.description &&
createdAt == other.createdAt &&
const DeepCollectionEquality().equals(members, other.members);
@override
int get hashCode => Object.hash(
id,
name,
description,
createdAt,
const DeepCollectionEquality().hash(members),
);
/// Creates a Group instance from a JSON object where the related [Player]
/// objects are represented by their IDs.
Group.fromJson(Map<String, dynamic> json)

View File

@@ -1,9 +1,11 @@
import 'package:clock/clock.dart';
import 'package:collection/collection.dart';
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_entry.dart';
import 'package:tallee/data/models/team.dart';
import 'package:uuid/uuid.dart';
class Match {
@@ -14,6 +16,7 @@ class Match {
final Game game;
final Group? group;
final List<Player> players;
final List<Team>? teams;
final String notes;
Map<String, ScoreEntry?> scores;
final bool deleted;
@@ -24,6 +27,7 @@ class Match {
required this.players,
this.endedAt,
this.group,
this.teams,
this.notes = '',
String? id,
DateTime? createdAt,
@@ -38,9 +42,62 @@ class Match {
return 'Match{id: $id, createdAt: $createdAt, endedAt: $endedAt, name: $name, game: $game, group: $group, players: $players, notes: $notes, scores: $scores, mvp: $mvp}';
}
/// Creates a Match instance from a JSON object where related objects are
/// represented by their IDs. Therefore, the game, group, and players are not
/// fully constructed here.
Match copyWith({
String? id,
DateTime? createdAt,
DateTime? endedAt,
String? name,
Game? game,
Group? group,
List<Player>? players,
List<Team>? teams,
String? notes,
Map<String, ScoreEntry?>? scores,
}) {
return Match(
id: id ?? this.id,
createdAt: createdAt ?? this.createdAt,
endedAt: endedAt ?? this.endedAt,
name: name ?? this.name,
game: game ?? this.game,
group: group ?? this.group,
players: players ?? this.players,
teams: teams ?? this.teams,
notes: notes ?? this.notes,
scores: scores ?? this.scores,
);
}
@override
bool operator ==(Object other) =>
identical(this, other) ||
other is Match &&
runtimeType == other.runtimeType &&
id == other.id &&
createdAt == other.createdAt &&
endedAt == other.endedAt &&
name == other.name &&
game == other.game &&
group == other.group &&
const DeepCollectionEquality().equals(players, other.players) &&
const DeepCollectionEquality().equals(teams, other.teams) &&
notes == other.notes &&
const DeepCollectionEquality().equals(scores, other.scores);
@override
int get hashCode => Object.hash(
id,
createdAt,
endedAt,
name,
game,
group,
const DeepCollectionEquality().hash(players),
const DeepCollectionEquality().hash(teams),
notes,
const DeepCollectionEquality().hash(scores),
);
Match.fromJson(Map<String, dynamic> json)
: id = json['id'],
createdAt = DateTime.parse(json['createdAt']),
@@ -57,6 +114,7 @@ class Match {
),
group = null,
players = [],
teams = [],
scores = json['scores'] != null
? (json['scores'] as Map<String, dynamic>).map(
(key, value) => MapEntry(
@@ -70,9 +128,6 @@ class Match {
notes = json['notes'] ?? '',
deleted = json['deleted'] ?? false;
/// Converts the Match instance to a JSON object. Related objects are
/// represented by their IDs, so the game, group, and players are not fully
/// serialized here.
Map<String, dynamic> toJson() => {
'id': id,
'createdAt': createdAt.toIso8601String(),
@@ -81,6 +136,7 @@ class Match {
'gameId': game.id,
'groupId': group?.id,
'playerIds': players.map((player) => player.id).toList(),
'teams': teams?.map((team) => team.toJson()).toList(),
'scores': scores.map((key, value) => MapEntry(key, value?.toJson())),
'notes': notes,
'deleted': deleted,
@@ -103,7 +159,10 @@ class Match {
return _getPlayersWithLowestScore().take(1).toList();
case Ruleset.multipleWinners:
return [];
return _getPlayersWithHighestScore().toList();
case Ruleset.placement:
return _getPlayersWithHighestScore().take(1).toList();
}
}

View File

@@ -25,7 +25,36 @@ class Player {
return 'Player{id: $id, createdAt: $createdAt, name: $name, nameCount: $nameCount, description: $description}';
}
/// Creates a Player instance from a JSON object.
Player copyWith({
String? id,
DateTime? createdAt,
String? name,
int? nameCount,
String? description,
}) {
return Player(
id: id ?? this.id,
createdAt: createdAt ?? this.createdAt,
name: name ?? this.name,
nameCount: nameCount ?? this.nameCount,
description: description ?? this.description,
);
}
@override
bool operator ==(Object other) =>
identical(this, other) ||
other is Player &&
runtimeType == other.runtimeType &&
id == other.id &&
createdAt == other.createdAt &&
name == other.name &&
nameCount == other.nameCount &&
description == other.description;
@override
int get hashCode => Object.hash(id, createdAt, name, nameCount, description);
Player.fromJson(Map<String, dynamic> json)
: id = json['id'],
createdAt = DateTime.parse(json['createdAt']),
@@ -34,7 +63,6 @@ class Player {
description = json['description'],
deleted = json['deleted'] ?? false;
/// Converts the Player instance to a JSON object.
Map<String, dynamic> toJson() => {
'id': id,
'createdAt': createdAt.toIso8601String(),

View File

@@ -11,6 +11,26 @@ class ScoreEntry {
return 'ScoreEntry{roundNumber: $roundNumber, score: $score, change: $change}';
}
ScoreEntry copyWith({int? roundNumber, int? score, int? change}) {
return ScoreEntry(
roundNumber: roundNumber ?? this.roundNumber,
score: score ?? this.score,
change: change ?? this.change,
);
}
@override
bool operator ==(Object other) =>
identical(this, other) ||
other is ScoreEntry &&
runtimeType == other.runtimeType &&
roundNumber == other.roundNumber &&
score == other.score &&
change == other.change;
@override
int get hashCode => Object.hash(roundNumber, score, change);
ScoreEntry.fromJson(Map<String, dynamic> json)
: roundNumber = json['roundNumber'],
score = json['score'],

View File

@@ -1,4 +1,5 @@
import 'package:clock/clock.dart';
import 'package:collection/collection.dart';
import 'package:tallee/data/models/player.dart';
import 'package:uuid/uuid.dart';
@@ -23,8 +24,38 @@ class Team {
return 'Team{id: $id, name: $name, members: $members}';
}
/// Creates a Team instance from a JSON object (memberIds format).
/// Player objects are reconstructed from memberIds by the DataTransferService.
Team copyWith({
String? id,
String? name,
DateTime? createdAt,
List<Player>? members,
}) {
return Team(
id: id ?? this.id,
name: name ?? this.name,
createdAt: createdAt ?? this.createdAt,
members: members ?? this.members,
);
}
@override
bool operator ==(Object other) =>
identical(this, other) ||
other is Team &&
runtimeType == other.runtimeType &&
id == other.id &&
name == other.name &&
createdAt == other.createdAt &&
const DeepCollectionEquality().equals(members, other.members);
@override
int get hashCode => Object.hash(
id,
name,
createdAt,
const DeepCollectionEquality().hash(members),
);
Team.fromJson(Map<String, dynamic> json)
: id = json['id'],
name = json['name'],
@@ -32,8 +63,6 @@ class Team {
members = [],
deleted = json['deleted'] ?? false;
/// Converts the Team instance to a JSON object. Related objects are
/// represented by their IDs.
Map<String, dynamic> toJson() => {
'id': id,
'name': name,