Aktualisiert die Punktevergabe in TournamentService.js und TournamentsView.vue, sodass der Sieger +1 Punkt erhält und der Verlierer -1 Punkt. Fügt eine neue Methode getLivePosition hinzu, um die Live-Punkte und -Sätze der Spieler in der Gruppe zu berechnen und anzuzeigen. Optimiert die Darstellung der Platzierung in der Tabelle.
This commit is contained in:
@@ -380,8 +380,13 @@ class TournamentService {
|
||||
for (const m of groupMatches.filter(m => m.groupId === g.id)) {
|
||||
if (!stats[m.player1Id] || !stats[m.player2Id]) continue;
|
||||
const [p1, p2] = m.result.split(":").map(n => parseInt(n, 10));
|
||||
if (p1 > p2) stats[m.player1Id].points += 2;
|
||||
else stats[m.player2Id].points += 2;
|
||||
if (p1 > p2) {
|
||||
stats[m.player1Id].points += 1; // Sieger bekommt +1
|
||||
stats[m.player2Id].points -= 1; // Verlierer bekommt -1
|
||||
} else {
|
||||
stats[m.player2Id].points += 1; // Sieger bekommt +1
|
||||
stats[m.player1Id].points -= 1; // Verlierer bekommt -1
|
||||
}
|
||||
stats[m.player1Id].setsWon += p1;
|
||||
stats[m.player1Id].setsLost += p2;
|
||||
stats[m.player2Id].setsWon += p2;
|
||||
|
||||
@@ -86,6 +86,7 @@
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Index</th>
|
||||
<th>Platz</th>
|
||||
<th>Spieler</th>
|
||||
<th>Punkte</th>
|
||||
<th>Satz</th>
|
||||
@@ -93,12 +94,13 @@
|
||||
<th v-for="(opponent, idx) in groupRankings[group.groupId]" :key="`opp-${opponent.id}`">
|
||||
G{{ String.fromCharCode(96 + group.groupNumber) }}{{ idx + 1 }}
|
||||
</th>
|
||||
<th>Platz</th>
|
||||
<th>Live-Platz</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr v-for="(pl, idx) in groupRankings[group.groupId]" :key="pl.id">
|
||||
<td><strong>G{{ String.fromCharCode(96 + group.groupNumber) }}{{ idx + 1 }}</strong></td>
|
||||
<td>{{ pl.position }}.</td>
|
||||
<td>{{ pl.name }}</td>
|
||||
<td>{{ pl.points }}</td>
|
||||
<td>{{ pl.setsWon }}:{{ pl.setsLost }}</td>
|
||||
@@ -116,7 +118,7 @@
|
||||
</span>
|
||||
<span v-else class="no-match">-</span>
|
||||
</td>
|
||||
<td>{{ pl.position }}.</td>
|
||||
<td>{{ getLivePosition(pl.id, group.groupId) }}.</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
@@ -372,8 +374,13 @@ export default {
|
||||
const e1 = arr.find(x => x.id === m.player1.id);
|
||||
const e2 = arr.find(x => x.id === m.player2.id);
|
||||
if (!e1 || !e2) return;
|
||||
if (s1 > s2) e1.points += 2;
|
||||
else if (s2 > s1) e2.points += 2;
|
||||
if (s1 > s2) {
|
||||
e1.points += 1; // Sieger bekommt +1
|
||||
e2.points -= 1; // Verlierer bekommt -1
|
||||
} else if (s2 > s1) {
|
||||
e2.points += 1; // Sieger bekommt +1
|
||||
e1.points -= 1; // Verlierer bekommt -1
|
||||
}
|
||||
e1.setsWon += s1; e1.setsLost += s2;
|
||||
e2.setsWon += s2; e2.setsLost += s1;
|
||||
});
|
||||
@@ -1049,6 +1056,80 @@ export default {
|
||||
}
|
||||
|
||||
return classes;
|
||||
},
|
||||
|
||||
getLivePosition(playerId, groupId) {
|
||||
// Berechne Live-Punkte für alle Spieler in der Gruppe
|
||||
const groupPlayers = this.groupRankings[groupId] || [];
|
||||
const liveStats = groupPlayers.map(player => {
|
||||
let livePoints = player.points || 0;
|
||||
let liveSetsWon = player.setsWon || 0;
|
||||
let liveSetsLost = player.setsLost || 0;
|
||||
|
||||
// Füge Live-Punkte aus begonnenen (aber nicht abgeschlossenen) Spielen hinzu
|
||||
const playerMatches = this.matches.filter(m =>
|
||||
m.round === 'group' &&
|
||||
m.groupId === groupId &&
|
||||
(m.player1.id === player.id || m.player2.id === player.id) &&
|
||||
!m.isFinished && // Nur begonnene, nicht abgeschlossene Spiele
|
||||
m.tournamentResults && m.tournamentResults.length > 0 // Mit Satz-Ergebnissen
|
||||
);
|
||||
|
||||
playerMatches.forEach(match => {
|
||||
const isPlayer1 = match.player1.id === player.id;
|
||||
const results = match.tournamentResults || [];
|
||||
|
||||
if (results.length > 0) {
|
||||
let setsWon = 0, setsLost = 0;
|
||||
results.forEach(result => {
|
||||
if (isPlayer1) {
|
||||
if (result.pointsPlayer1 > result.pointsPlayer2) setsWon++;
|
||||
else if (result.pointsPlayer2 > result.pointsPlayer1) setsLost++;
|
||||
} else {
|
||||
if (result.pointsPlayer2 > result.pointsPlayer1) setsWon++;
|
||||
else if (result.pointsPlayer1 > result.pointsPlayer2) setsLost++;
|
||||
}
|
||||
});
|
||||
|
||||
// Füge Live-Punkte hinzu (basierend auf aktuellen Sätzen)
|
||||
if (setsWon > setsLost) {
|
||||
livePoints += 1;
|
||||
} else if (setsLost > setsWon) {
|
||||
livePoints -= 1;
|
||||
}
|
||||
|
||||
// Füge Live-Sätze hinzu
|
||||
if (isPlayer1) {
|
||||
liveSetsWon += results.reduce((sum, r) => sum + r.pointsPlayer1, 0);
|
||||
liveSetsLost += results.reduce((sum, r) => sum + r.pointsPlayer2, 0);
|
||||
} else {
|
||||
liveSetsWon += results.reduce((sum, r) => sum + r.pointsPlayer2, 0);
|
||||
liveSetsLost += results.reduce((sum, r) => sum + r.pointsPlayer1, 0);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return {
|
||||
id: player.id,
|
||||
name: player.name,
|
||||
livePoints: livePoints,
|
||||
liveSetsWon: liveSetsWon,
|
||||
liveSetsLost: liveSetsLost,
|
||||
liveSetDiff: liveSetsWon - liveSetsLost
|
||||
};
|
||||
});
|
||||
|
||||
// Sortiere nach Live-Punkten (absteigend), dann nach Satzverhältnis
|
||||
liveStats.sort((a, b) => {
|
||||
if (b.livePoints !== a.livePoints) return b.livePoints - a.livePoints;
|
||||
if (b.liveSetDiff !== a.liveSetDiff) return b.liveSetDiff - a.liveSetDiff;
|
||||
if (b.liveSetsWon !== a.liveSetsWon) return b.liveSetsWon - a.liveSetsWon;
|
||||
return a.name.localeCompare(b.name);
|
||||
});
|
||||
|
||||
// Finde Position des Spielers
|
||||
const position = liveStats.findIndex(p => p.id === playerId) + 1;
|
||||
return position;
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -1226,8 +1307,8 @@ button {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.group-table th:nth-child(2),
|
||||
.group-table td:nth-child(2) {
|
||||
.group-table th:nth-child(3),
|
||||
.group-table td:nth-child(3) {
|
||||
text-align: left;
|
||||
min-width: 120px;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user