From d0e3ae361021f41e94f64ade7e5be103f4629b59 Mon Sep 17 00:00:00 2001 From: "Torsten Schulz (local)" Date: Wed, 5 Nov 2025 08:45:23 +0100 Subject: [PATCH] Implement ranking logic for players with identical scores in TournamentsView Updated the ranking assignment logic in TournamentsView to ensure players with identical points, set differences, and sets won receive the same position. This change enhances the accuracy of player rankings and improves the user experience by reflecting true standings in tournament scenarios. Additionally, adjusted the position retrieval for players in live stats to accommodate the new ranking logic. --- frontend/src/views/TournamentsView.vue | 42 +++++++++++++++++++++++--- 1 file changed, 37 insertions(+), 5 deletions(-) diff --git a/frontend/src/views/TournamentsView.vue b/frontend/src/views/TournamentsView.vue index f2004ab..2a9cfad 100644 --- a/frontend/src/views/TournamentsView.vue +++ b/frontend/src/views/TournamentsView.vue @@ -789,9 +789,23 @@ export default { if (b.setsWon !== a.setsWon) return b.setsWon - a.setsWon; return a.name.localeCompare(b.name); }); - rankings[gid] = arr.map((p, i) => ({ - ...p, position: i + 1 - })); + // Weise Positionen zu, wobei Spieler mit identischen Werten den gleichen Platz bekommen + let currentPosition = 1; + rankings[gid] = arr.map((p, i) => { + // Wenn nicht der erste Spieler und die Werte identisch sind, verwende die gleiche Position + if (i > 0) { + const prev = arr[i - 1]; + if (prev.points === p.points && + prev.setDiff === p.setDiff && + prev.setsWon === p.setsWon) { + // Gleicher Platz wie Vorgänger + return { ...p, position: currentPosition }; + } + } + // Neuer Platz + currentPosition = i + 1; + return { ...p, position: currentPosition }; + }); }); return rankings; }, @@ -1701,9 +1715,27 @@ export default { return a.name.localeCompare(b.name); }); + // Weise Positionen zu, wobei Spieler mit identischen Werten den gleichen Platz bekommen + let currentPosition = 1; + const positions = liveStats.map((p, i) => { + // Wenn nicht der erste Spieler und die Werte identisch sind, verwende die gleiche Position + if (i > 0) { + const prev = liveStats[i - 1]; + if (prev.livePoints === p.livePoints && + prev.liveSetDiff === p.liveSetDiff && + prev.liveSetsWon === p.liveSetsWon) { + // Gleicher Platz wie Vorgänger + return currentPosition; + } + } + // Neuer Platz + currentPosition = i + 1; + return currentPosition; + }); + // Finde Position des Spielers - const position = liveStats.findIndex(p => p.id === playerId) + 1; - return position; + const playerIndex = liveStats.findIndex(p => p.id === playerId); + return playerIndex >= 0 ? positions[playerIndex] : liveStats.length + 1; } } };