From 4a0ce067b5f3a91056baf9cf61fe0ffe2a554b67 Mon Sep 17 00:00:00 2001 From: Felix Kirchner Date: Mon, 14 Jul 2025 11:14:22 +0200 Subject: [PATCH] Updated function _getSortedPlayerIndices() --- lib/presentation/views/active_game_view.dart | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/presentation/views/active_game_view.dart b/lib/presentation/views/active_game_view.dart index 8698c62..6eaee45 100644 --- a/lib/presentation/views/active_game_view.dart +++ b/lib/presentation/views/active_game_view.dart @@ -32,7 +32,10 @@ class _ActiveGameViewState extends State { return ListenableBuilder( listenable: gameSession, builder: (context, _) { - List sortedPlayerIndices = _getSortedPlayerIndices(); + List playerIndices = + List.generate(gameSession.players.length, (index) => index); + List sortedPlayerIndices = + _getSortedPlayerIndices(playerIndices); return CupertinoPageScaffold( navigationBar: CupertinoNavigationBar( middle: Text(gameSession.gameTitle), @@ -260,9 +263,7 @@ class _ActiveGameViewState extends State { /// Returns a list of player indices sorted by their scores in /// ascending order. - List _getSortedPlayerIndices() { - List playerIndices = - List.generate(gameSession.players.length, (index) => index); + List _getSortedPlayerIndices(List playerIndices) { // Sort the indices based on the summed points playerIndices.sort((a, b) { int scoreA = gameSession.playerScores[a]; @@ -285,7 +286,7 @@ class _ActiveGameViewState extends State { /// Calculates the dense rank for a player based on their index in the sorted list of players. int _calculateDenseRank(int index, List playerScores) { - List sortedIndices = _getSortedPlayerIndices(); + List sortedIndices = _getSortedPlayerIndices(playerScores); List denseRanks = []; int rank = 1; for (int i = 0; i < sortedIndices.length; i++) {