Added print statements for debugging

This commit is contained in:
Felix Kirchner
2025-04-22 11:15:38 +02:00
parent fb0e6515a1
commit a2dacad96c
2 changed files with 24 additions and 5 deletions

View File

@@ -27,6 +27,18 @@ class GameSession {
'playerScores: $playerScores]');
}
/// Returns a string representation of the scores for a specific round.
/// The method takes a round number as a parameter and returns a string
/// containing the name of each player and their corressponding score in
/// the given round.
String printRoundScores(int round) {
String result = '';
for (int i = 0; i < players.length; i++) {
result += '${players[i]}: ${playerScores[i][round]}\n';
}
return result;
}
/// Expands the player score lists by adding a new score of 0 for each player.
/// This method is called when a new round starts so the lists in the
/// active game view expands

View File

@@ -313,18 +313,27 @@ class _RoundViewState extends State<RoundView> {
}
/// Finishes the current round.
/// Calls the [_calculateScoredPoints()] method to calculate the points for every player.
/// If the round is the highest round played in this game, it expands the player score lists
/// At the end it updates the score array for the game.
/// Calls the [_calculateScoredPoints()] method to calculate the points for
/// every player. If the round is the highest round played in this game,
/// it expands the player score lists. At the end it updates the score
/// array for the game.
void _finishRound() {
print('====================================');
print('Runde ${widget.roundNumber} beendet');
// The shown round is smaller than the newest round
if (widget.gameSession.round < widget.gameSession.playerScores[0].length) {
print('Da diese Runde bereits gespielt wurde, werden die alten '
'Punktestaende ueberschrieben');
print('Alte Punktestaende:');
print(gameSession.printRoundScores(widget.roundNumber));
}
if (widget.roundNumber >= widget.gameSession.playerScores[0].length) {
gameSession.expandPlayerScoreLists();
print('Das Punkte-Array wurde erweitert');
}
_calculateScoredPoints();
widget.gameSession.sumPoints();
print('Die Punktesummen wurden aktualisiert');
}
/// Checks the scores of the current round and assigns points to the players.
@@ -367,8 +376,6 @@ class _RoundViewState extends State<RoundView> {
print('${widget.gameSession.players[_caboPlayerIndex]} hat CABO gesagt '
'und bekommt 0 Punkte');
print('Alle anderen Spieler bekommen ihre Punkte');
///
_assignPoints([_caboPlayerIndex], -1, roundScores);
} else {
// Ein anderer Spieler hat weniger Punkte