First version of inserting into db
This commit is contained in:
88
lib/data/dao/game_session_dao.dart
Normal file
88
lib/data/dao/game_session_dao.dart
Normal file
@@ -0,0 +1,88 @@
|
||||
import 'package:cabo_counter/data/db/database.dart';
|
||||
import 'package:cabo_counter/data/db/tables/game_session_table.dart';
|
||||
import 'package:cabo_counter/data/dto/game_session.dart';
|
||||
import 'package:cabo_counter/data/dto/player.dart';
|
||||
import 'package:cabo_counter/data/dto/round.dart';
|
||||
import 'package:drift/drift.dart';
|
||||
|
||||
part 'game_session_dao.g.dart';
|
||||
|
||||
@DriftAccessor(tables: [GameSessionTable])
|
||||
class GameSessionDao extends DatabaseAccessor<AppDatabase>
|
||||
with _$GameSessionDaoMixin {
|
||||
GameSessionDao(super.db);
|
||||
|
||||
/// Retrieves a game session by its ID.
|
||||
Future<GameSession> getGameSession(String id) async {
|
||||
final query = select(gameSessionTable)..where((tbl) => tbl.id.equals(id));
|
||||
final gameSessionResult = await query.getSingle();
|
||||
|
||||
List<Player> playerList = await db.playerDao.getPlayersByGameId(id);
|
||||
List<Round> roundList = await db.roundsDao.getRoundsByGameId(id);
|
||||
|
||||
GameSession gameSession = GameSession(
|
||||
id: gameSessionResult.id,
|
||||
createdAt: gameSessionResult.createdAt,
|
||||
gameTitle: gameSessionResult.gameTitle,
|
||||
players: playerList,
|
||||
pointLimit: gameSessionResult.pointLimit,
|
||||
caboPenalty: gameSessionResult.caboPenalty,
|
||||
isPointsLimitEnabled: gameSessionResult.isPointsLimitEnabled,
|
||||
isGameFinished: gameSessionResult.isGameFinished,
|
||||
winner: gameSessionResult.winner ?? '',
|
||||
roundNumber: gameSessionResult.roundNumber,
|
||||
roundList: roundList);
|
||||
|
||||
return gameSession;
|
||||
}
|
||||
|
||||
/// Retrieves all game sessions from the database.
|
||||
Future<List<GameSession>> getAllGameSessions() async {
|
||||
final query = select(gameSessionTable);
|
||||
final gameSessionResults = await query.get();
|
||||
|
||||
List<GameSession> gameSessions = await Future.wait(
|
||||
gameSessionResults.map((row) async {
|
||||
List<Player> playerList = await db.playerDao.getPlayersByGameId(row.id);
|
||||
List<Round> roundList = await db.roundsDao.getRoundsByGameId(row.id);
|
||||
|
||||
return GameSession(
|
||||
id: row.id,
|
||||
createdAt: row.createdAt,
|
||||
gameTitle: row.gameTitle,
|
||||
players: playerList,
|
||||
pointLimit: row.pointLimit,
|
||||
caboPenalty: row.caboPenalty,
|
||||
isPointsLimitEnabled: row.isPointsLimitEnabled,
|
||||
isGameFinished: row.isGameFinished,
|
||||
winner: row.winner ?? '',
|
||||
roundNumber: row.roundNumber,
|
||||
roundList: roundList,
|
||||
);
|
||||
}),
|
||||
);
|
||||
|
||||
return gameSessions;
|
||||
}
|
||||
|
||||
Future<void> insertGameSession(GameSession gameSession) async {
|
||||
await into(gameSessionTable).insert(
|
||||
GameSessionTableCompanion.insert(
|
||||
id: gameSession.id,
|
||||
createdAt: gameSession.createdAt,
|
||||
gameTitle: gameSession.gameTitle,
|
||||
pointLimit: gameSession.pointLimit,
|
||||
caboPenalty: gameSession.caboPenalty,
|
||||
isPointsLimitEnabled: gameSession.isPointsLimitEnabled,
|
||||
isGameFinished: gameSession.isGameFinished,
|
||||
winner: Value(gameSession.winner),
|
||||
roundNumber: gameSession.roundNumber,
|
||||
),
|
||||
);
|
||||
|
||||
db.playerDao.insertPlayers(gameSession.id, gameSession.players);
|
||||
|
||||
db.roundsDao.insertMultipleRounds(
|
||||
gameSession.id, gameSession.roundList, gameSession.players);
|
||||
}
|
||||
}
|
||||
@@ -35,4 +35,22 @@ class PlayerDao extends DatabaseAccessor<AppDatabase> with _$PlayerDaoMixin {
|
||||
|
||||
return result.position;
|
||||
}
|
||||
|
||||
/// Inserts a new player into the database.
|
||||
Future<void> insertPlayers(String gameId, List<Player> players) async {
|
||||
await batch((batch) {
|
||||
for (int i = 0; i < players.length; i++) {
|
||||
batch.insert(
|
||||
playerTable,
|
||||
PlayerTableCompanion.insert(
|
||||
playerId: players[i].playerId,
|
||||
gameId: gameId,
|
||||
name: players[i].name,
|
||||
position: i,
|
||||
totalScore: players[i].totalScore,
|
||||
),
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -11,7 +11,9 @@ class RoundScoresDao extends DatabaseAccessor<AppDatabase>
|
||||
RoundScoresDao(super.db);
|
||||
|
||||
/// Retrieves all scores for a specific round by its ID.
|
||||
Future<List<RoundScore>> getRoundScoresByRoundId(String roundId) async {
|
||||
/// This method returns a list of [RoundScore] objects sorted by player
|
||||
/// position in the corresponding gameSession
|
||||
Future<List<RoundScore>> _getRoundScoresByRoundId(String roundId) async {
|
||||
final query = select(roundScoresTable)
|
||||
..where((tbl) => tbl.roundId.equals(roundId));
|
||||
|
||||
@@ -37,14 +39,20 @@ class RoundScoresDao extends DatabaseAccessor<AppDatabase>
|
||||
}).toList();
|
||||
}
|
||||
|
||||
/// Retrieves all scores for a specific round by its ID.
|
||||
/// This method returns a list of scores sorted by player position in the
|
||||
/// corresponding gameSession.
|
||||
Future<List<int>> getScoresByRoundId(String roundId) async {
|
||||
List<RoundScore> roundScores = await getRoundScoresByRoundId(roundId);
|
||||
List<RoundScore> roundScores = await _getRoundScoresByRoundId(roundId);
|
||||
|
||||
return roundScores.map((score) => score.score).toList();
|
||||
}
|
||||
|
||||
/// Retrieves all score updates for a specific round by its ID.
|
||||
/// This method returns a list of score updates sorted by player position in
|
||||
/// the corresponding gameSession.
|
||||
Future<List<int>> getScoreUpdatesByRoundId(String roundId) async {
|
||||
List<RoundScore> roundScores = await getRoundScoresByRoundId(roundId);
|
||||
List<RoundScore> roundScores = await _getRoundScoresByRoundId(roundId);
|
||||
|
||||
return roundScores.map((score) => score.scoreUpdate).toList();
|
||||
}
|
||||
140
lib/data/dao/rounds_dao.dart
Normal file
140
lib/data/dao/rounds_dao.dart
Normal file
@@ -0,0 +1,140 @@
|
||||
import 'package:cabo_counter/data/db/database.dart';
|
||||
import 'package:cabo_counter/data/db/tables/round_scores_table.dart';
|
||||
import 'package:cabo_counter/data/db/tables/rounds_table.dart';
|
||||
import 'package:cabo_counter/data/dto/player.dart';
|
||||
import 'package:cabo_counter/data/dto/round.dart';
|
||||
import 'package:drift/drift.dart';
|
||||
import 'package:uuid/uuid.dart';
|
||||
|
||||
part 'rounds_dao.g.dart';
|
||||
|
||||
@DriftAccessor(tables: [RoundsTable, RoundScoresTable])
|
||||
class RoundsDao extends DatabaseAccessor<AppDatabase> with _$RoundsDaoMixin {
|
||||
RoundsDao(super.db);
|
||||
|
||||
/// Retrieves all rounds for a specific game session by its ID.
|
||||
Future<List<Round>> getRoundsByGameId(String gameId) async {
|
||||
final query = select(roundsTable)
|
||||
..where((tbl) => tbl.gameId.equals(gameId));
|
||||
|
||||
final roundResult = await query.get();
|
||||
|
||||
final roundList = await Future.wait(
|
||||
roundResult.map((row) async {
|
||||
final scores = await db.roundScoresDao.getScoresByRoundId(row.roundId);
|
||||
final roundScores =
|
||||
await db.roundScoresDao.getScoreUpdatesByRoundId(row.roundId);
|
||||
|
||||
return Round(
|
||||
roundId: row.roundId,
|
||||
gameId: row.gameId,
|
||||
roundNum: row.roundNumber,
|
||||
caboPlayerIndex: row.caboPlayerIndex,
|
||||
kamikazePlayerIndex: row.kamikazePlayerIndex,
|
||||
scores: scores,
|
||||
scoreUpdates: roundScores,
|
||||
);
|
||||
}),
|
||||
);
|
||||
|
||||
return roundList;
|
||||
}
|
||||
|
||||
/// Retrieves a specific round by its [gameId] and [roundNumber].
|
||||
/// Returns null if the round does not exist.
|
||||
Future<Round?> getRoundByGameIdAndRoundNumber(
|
||||
String gameId, int roundNumber) async {
|
||||
final query = select(roundsTable)
|
||||
..where((tbl) =>
|
||||
tbl.gameId.equals(gameId) & tbl.roundNumber.equals(roundNumber));
|
||||
final roundResult = await query.getSingleOrNull();
|
||||
if (roundResult == null) return null;
|
||||
|
||||
final scoreResult = await Future.wait([
|
||||
db.roundScoresDao.getScoresByRoundId(roundResult.roundId),
|
||||
db.roundScoresDao.getScoreUpdatesByRoundId(roundResult.roundId),
|
||||
]);
|
||||
|
||||
return Round(
|
||||
roundId: roundResult.roundId,
|
||||
gameId: roundResult.gameId,
|
||||
roundNum: roundResult.roundNumber,
|
||||
caboPlayerIndex: roundResult.caboPlayerIndex,
|
||||
kamikazePlayerIndex: roundResult.kamikazePlayerIndex,
|
||||
scores: scoreResult[0],
|
||||
scoreUpdates: scoreResult[1],
|
||||
);
|
||||
}
|
||||
|
||||
/// Inserts a new round into the database.
|
||||
/// This method creates a new round with a unique ID and inserts it
|
||||
/// along with the scores for each player in the round.
|
||||
/// [gameId] is the ID of the game session this round belongs to.
|
||||
/// [round] is the round data to be inserted.
|
||||
/// [players] is the list of players in the game session.
|
||||
Future<void> insertOneRound(
|
||||
String gameId, Round round, List<Player> players) async {
|
||||
var uuid = const Uuid();
|
||||
String roundId = uuid.v1();
|
||||
|
||||
final roundEntry = RoundsTableCompanion.insert(
|
||||
roundId: roundId,
|
||||
gameId: gameId,
|
||||
roundNumber: round.roundNum,
|
||||
caboPlayerIndex: round.caboPlayerIndex,
|
||||
kamikazePlayerIndex: Value(round.kamikazePlayerIndex),
|
||||
);
|
||||
|
||||
await into(roundsTable).insert(roundEntry);
|
||||
|
||||
for (int i = 0; i < players.length; i++) {
|
||||
final player = players[i];
|
||||
final roundScoreEntry = RoundScoresTableCompanion.insert(
|
||||
roundId: roundId,
|
||||
playerId: player.playerId,
|
||||
score: round.scores[i],
|
||||
scoreUpdate: round.scoreUpdates[i],
|
||||
);
|
||||
await into(roundScoresTable).insert(roundScoreEntry);
|
||||
}
|
||||
}
|
||||
|
||||
/// Inserts multiple rounds into the database.
|
||||
/// This method uses a batch operation to insert all rounds and their scores
|
||||
/// in a single transaction.
|
||||
/// [gameId] is the ID of the game session these rounds belong to.
|
||||
/// [rounds] is the list of rounds to be inserted.
|
||||
/// [players] is the list of players in the game session.
|
||||
Future<void> insertMultipleRounds(
|
||||
String gameId, List<Round> rounds, List<Player> players) async {
|
||||
var uuid = const Uuid();
|
||||
|
||||
await batch((batch) {
|
||||
final roundEntries = <RoundsTableCompanion>[];
|
||||
final roundScoreEntries = <RoundScoresTableCompanion>[];
|
||||
|
||||
for (final round in rounds) {
|
||||
final roundId = uuid.v1();
|
||||
roundEntries.add(RoundsTableCompanion.insert(
|
||||
roundId: roundId,
|
||||
gameId: gameId,
|
||||
roundNumber: round.roundNum,
|
||||
caboPlayerIndex: round.caboPlayerIndex,
|
||||
kamikazePlayerIndex: Value(round.kamikazePlayerIndex),
|
||||
));
|
||||
|
||||
for (int i = 0; i < players.length; i++) {
|
||||
roundScoreEntries.add(RoundScoresTableCompanion.insert(
|
||||
roundId: roundId,
|
||||
playerId: players[i].playerId,
|
||||
score: round.scores[i],
|
||||
scoreUpdate: round.scoreUpdates[i],
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
batch.insertAll(roundsTable, roundEntries);
|
||||
batch.insertAll(roundScoresTable, roundScoreEntries);
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -7,4 +7,6 @@ mixin _$RoundsDaoMixin on DatabaseAccessor<AppDatabase> {
|
||||
$GameSessionTableTable get gameSessionTable =>
|
||||
attachedDatabase.gameSessionTable;
|
||||
$RoundsTableTable get roundsTable => attachedDatabase.roundsTable;
|
||||
$RoundScoresTableTable get roundScoresTable =>
|
||||
attachedDatabase.roundScoresTable;
|
||||
}
|
||||
@@ -1,39 +0,0 @@
|
||||
import 'package:cabo_counter/data/db/database.dart';
|
||||
import 'package:cabo_counter/data/db/tables/game_session_table.dart';
|
||||
import 'package:cabo_counter/data/dto/game_session.dart';
|
||||
import 'package:cabo_counter/data/dto/player.dart';
|
||||
import 'package:cabo_counter/data/dto/round.dart';
|
||||
import 'package:drift/drift.dart';
|
||||
|
||||
part 'game_session_dao.g.dart';
|
||||
|
||||
@DriftAccessor(tables: [GameSessionTable])
|
||||
class GameSessionDao extends DatabaseAccessor<AppDatabase>
|
||||
with _$GameSessionDaoMixin {
|
||||
GameSessionDao(super.db);
|
||||
|
||||
/// Retrieves a game session by its ID.
|
||||
Future<GameSession> getGameSession(String id) async {
|
||||
final query = select(gameSessionTable)..where((tbl) => tbl.id.equals(id));
|
||||
final gameSessionResult = await query.getSingle();
|
||||
|
||||
List<Player> playerList = await db.playerDao.getPlayersByGameId(id);
|
||||
List<Round> roundList = await db.roundsDao.getRoundsByGameId(id);
|
||||
|
||||
GameSession gameSession = GameSession(
|
||||
id: gameSessionResult.id,
|
||||
createdAt: gameSessionResult.createdAt,
|
||||
gameTitle: gameSessionResult.gameTitle,
|
||||
players: playerList.map((player) => player.name).toList(),
|
||||
pointLimit: gameSessionResult.pointLimit,
|
||||
caboPenalty: gameSessionResult.caboPenalty,
|
||||
isPointsLimitEnabled: gameSessionResult.isPointsLimitEnabled,
|
||||
isGameFinished: gameSessionResult.isGameFinished,
|
||||
winner: gameSessionResult.winner ?? '',
|
||||
roundNumber: gameSessionResult.roundNumber,
|
||||
playerScores: playerList.map((player) => player.totalScore).toList(),
|
||||
roundList: roundList);
|
||||
|
||||
return gameSession;
|
||||
}
|
||||
}
|
||||
@@ -1,39 +0,0 @@
|
||||
import 'package:cabo_counter/data/db/database.dart';
|
||||
import 'package:cabo_counter/data/db/tables/rounds_table.dart';
|
||||
import 'package:cabo_counter/data/dto/round.dart';
|
||||
import 'package:drift/drift.dart';
|
||||
|
||||
part 'rounds_dao.g.dart';
|
||||
|
||||
@DriftAccessor(tables: [RoundsTable])
|
||||
class RoundsDao extends DatabaseAccessor<AppDatabase> with _$RoundsDaoMixin {
|
||||
RoundsDao(super.db);
|
||||
|
||||
/// Retrieves all rounds for a specific game session by its ID.
|
||||
Future<List<Round>> getRoundsByGameId(String gameId) async {
|
||||
final query = select(roundsTable)
|
||||
..where((tbl) => tbl.gameId.equals(gameId));
|
||||
|
||||
final roundResult = await query.get();
|
||||
|
||||
final roundList = await Future.wait(
|
||||
roundResult.map((row) async {
|
||||
final scores = await db.roundScoresDao.getScoresByRoundId(row.roundId);
|
||||
final roundScores =
|
||||
await db.roundScoresDao.getScoreUpdatesByRoundId(row.roundId);
|
||||
|
||||
return Round(
|
||||
roundId: row.roundId,
|
||||
gameId: row.gameId,
|
||||
roundNum: row.roundNumber,
|
||||
caboPlayerIndex: row.caboPlayerIndex,
|
||||
kamikazePlayerIndex: row.kamikazePlayerIndex,
|
||||
scores: scores,
|
||||
scoreUpdates: roundScores,
|
||||
);
|
||||
}),
|
||||
);
|
||||
|
||||
return roundList;
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
import 'package:cabo_counter/data/db/dao/game_session_dao.dart';
|
||||
import 'package:cabo_counter/data/db/dao/player_dao.dart';
|
||||
import 'package:cabo_counter/data/db/dao/round_scores_dao.dart';
|
||||
import 'package:cabo_counter/data/db/dao/rounds_dao.dart';
|
||||
import 'package:cabo_counter/data/dao/game_session_dao.dart';
|
||||
import 'package:cabo_counter/data/dao/player_dao.dart';
|
||||
import 'package:cabo_counter/data/dao/round_scores_dao.dart';
|
||||
import 'package:cabo_counter/data/dao/rounds_dao.dart';
|
||||
import 'package:cabo_counter/data/db/tables/game_session_table.dart';
|
||||
import 'package:cabo_counter/data/db/tables/player_table.dart';
|
||||
import 'package:cabo_counter/data/db/tables/round_scores_table.dart';
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import 'package:cabo_counter/data/dto/player.dart';
|
||||
import 'package:cabo_counter/data/dto/round.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:uuid/uuid.dart';
|
||||
@@ -16,14 +17,13 @@ class GameSession extends ChangeNotifier {
|
||||
final String id;
|
||||
final DateTime createdAt;
|
||||
final String gameTitle;
|
||||
final List<String> players;
|
||||
final List<Player> players;
|
||||
final int pointLimit;
|
||||
final int caboPenalty;
|
||||
final bool isPointsLimitEnabled;
|
||||
bool isGameFinished;
|
||||
String winner;
|
||||
int roundNumber;
|
||||
List<int> playerScores;
|
||||
List<Round> roundList;
|
||||
|
||||
GameSession(
|
||||
@@ -37,16 +37,13 @@ class GameSession extends ChangeNotifier {
|
||||
this.isGameFinished = false,
|
||||
this.winner = '',
|
||||
this.roundNumber = 1,
|
||||
this.playerScores = const [],
|
||||
this.roundList = const []}) {
|
||||
playerScores = List.filled(players.length, 0);
|
||||
}
|
||||
this.roundList = const []});
|
||||
|
||||
@override
|
||||
toString() {
|
||||
return ('GameSession: [id: $id, createdAt: $createdAt, gameTitle: $gameTitle, '
|
||||
return 'GameSession: [id: $id, createdAt: $createdAt, gameTitle: $gameTitle, '
|
||||
'isPointsLimitEnabled: $isPointsLimitEnabled, pointLimit: $pointLimit, caboPenalty: $caboPenalty,'
|
||||
' players: $players, playerScores: $playerScores, roundList: $roundList, winner: $winner]');
|
||||
' players: $players, roundList: $roundList, winner: $winner]';
|
||||
}
|
||||
|
||||
/// Converts the GameSession object to a JSON map.
|
||||
@@ -61,7 +58,6 @@ class GameSession extends ChangeNotifier {
|
||||
'isGameFinished': isGameFinished,
|
||||
'winner': winner,
|
||||
'roundNumber': roundNumber,
|
||||
'playerScores': playerScores,
|
||||
'roundList': roundList.map((e) => e.toJson()).toList()
|
||||
};
|
||||
|
||||
@@ -70,14 +66,13 @@ class GameSession extends ChangeNotifier {
|
||||
: id = json['id'] ?? const Uuid().v1(),
|
||||
createdAt = DateTime.parse(json['createdAt']),
|
||||
gameTitle = json['gameTitle'],
|
||||
players = List<String>.from(json['players']),
|
||||
players = List<Player>.from(json['players']),
|
||||
pointLimit = json['pointLimit'],
|
||||
caboPenalty = json['caboPenalty'],
|
||||
isPointsLimitEnabled = json['isPointsLimitEnabled'],
|
||||
isGameFinished = json['isGameFinished'],
|
||||
winner = json['winner'],
|
||||
roundNumber = json['roundNumber'],
|
||||
playerScores = List<int>.from(json['playerScores']),
|
||||
roundList =
|
||||
(json['roundList'] as List).map((e) => Round.fromJson(e)).toList();
|
||||
|
||||
@@ -247,8 +242,8 @@ class GameSession extends ChangeNotifier {
|
||||
bonusPlayers = _checkHundredPointsReached();
|
||||
bool limitExceeded = false;
|
||||
|
||||
for (int i = 0; i < playerScores.length; i++) {
|
||||
if (playerScores[i] > pointLimit) {
|
||||
for (int i = 0; i < players.length; i++) {
|
||||
if (players[i].totalScore > pointLimit) {
|
||||
isGameFinished = true;
|
||||
limitExceeded = true;
|
||||
print('${players[i]} hat die 100 Punkte ueberschritten, '
|
||||
@@ -271,9 +266,9 @@ class GameSession extends ChangeNotifier {
|
||||
/// playerScores list.
|
||||
void _sumPoints() {
|
||||
for (int i = 0; i < players.length; i++) {
|
||||
playerScores[i] = 0;
|
||||
players[i].totalScore = 0;
|
||||
for (int j = 0; j < roundList.length; j++) {
|
||||
playerScores[i] += roundList[j].scoreUpdates[i];
|
||||
players[i].totalScore += roundList[j].scoreUpdates[i];
|
||||
}
|
||||
}
|
||||
notifyListeners();
|
||||
@@ -285,7 +280,7 @@ class GameSession extends ChangeNotifier {
|
||||
List<int> _checkHundredPointsReached() {
|
||||
List<int> bonusPlayers = [];
|
||||
for (int i = 0; i < players.length; i++) {
|
||||
if (playerScores[i] == pointLimit) {
|
||||
if (players[i].totalScore == pointLimit) {
|
||||
bonusPlayers.add(i);
|
||||
print('${players[i]} hat genau 100 Punkte erreicht und bekommt '
|
||||
'deswegen ${(pointLimit / 2).round()} Punkte abgezogen');
|
||||
@@ -296,15 +291,23 @@ class GameSession extends ChangeNotifier {
|
||||
return bonusPlayers;
|
||||
}
|
||||
|
||||
List<int> getPlayerScoresAsList() {
|
||||
return players.map((player) => player.totalScore).toList();
|
||||
}
|
||||
|
||||
List<String> getPlayerNamesAsList() {
|
||||
return players.map((player) => player.name).toList();
|
||||
}
|
||||
|
||||
/// Determines the winner of the game session.
|
||||
/// It iterates through the player scores and finds the player
|
||||
/// with the lowest score.
|
||||
void setWinner() {
|
||||
int minScore = playerScores.reduce((a, b) => a < b ? a : b);
|
||||
int minScore = getPlayerScoresAsList().reduce((a, b) => a < b ? a : b);
|
||||
List<String> lowestPlayers = [];
|
||||
for (int i = 0; i < players.length; i++) {
|
||||
if (playerScores[i] == minScore) {
|
||||
lowestPlayers.add(players[i]);
|
||||
if (players[i].totalScore == minScore) {
|
||||
lowestPlayers.add(players[i].name);
|
||||
}
|
||||
}
|
||||
if (lowestPlayers.length > 1) {
|
||||
|
||||
@@ -14,7 +14,7 @@ class Player {
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return '(playerId: $playerId, gameId: $gameId, name: $name, position: $position)';
|
||||
return 'Player: [playerId: $playerId, gameId: $gameId, name: $name, position: $position]';
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
|
||||
Reference in New Issue
Block a user