changes
This commit is contained in:
@@ -11,9 +11,13 @@ function emptyRow(teamId: string): StandingRow {
|
||||
};
|
||||
}
|
||||
|
||||
// Trägt ein abgeschlossenes Spiel in zwei Tabellenzeilen ein.
|
||||
function applyMatch(rows: Map<string, StandingRow>, m: Match) {
|
||||
if (m.status !== "FINISHED") return;
|
||||
// Trägt ein Spiel in zwei Tabellenzeilen ein.
|
||||
// Standard: nur abgeschlossene Spiele (FINISHED). Mit includeLive=true werden
|
||||
// auch laufende Spiele (LIVE/IN_PLAY/PAUSED) mit ihrem Zwischenstand gezählt.
|
||||
function applyMatch(rows: Map<string, StandingRow>, m: Match, includeLive = false) {
|
||||
const live = m.status === "LIVE" || m.status === "IN_PLAY" || m.status === "PAUSED";
|
||||
const counts = m.status === "FINISHED" || (includeLive && live);
|
||||
if (!counts) return;
|
||||
if (m.homeTeamId == null || m.awayTeamId == null) return;
|
||||
if (m.homeScore == null || m.awayScore == null) return;
|
||||
const h = rows.get(m.homeTeamId);
|
||||
@@ -75,14 +79,19 @@ function miniTable(matches: Match[], tiedIds: Set<string>): Map<string, Standing
|
||||
}
|
||||
|
||||
// Berechnet alle 12 Gruppentabellen aus Teams + Spielen.
|
||||
export function computeGroupTables(teams: Team[], matches: Match[]): GroupTable[] {
|
||||
// includeLive=false (Standard): nur abgeschlossene Spiele (offizielle Tabelle,
|
||||
// Basis für die fix-Berechnung). includeLive=true: laufende Spiele werden mit
|
||||
// Zwischenstand eingerechnet (Live-Tabelle).
|
||||
export function computeGroupTables(
|
||||
teams: Team[], matches: Match[], includeLive = false,
|
||||
): GroupTable[] {
|
||||
const tables: GroupTable[] = [];
|
||||
for (const g of GROUP_IDS) {
|
||||
const groupTeams = teams.filter((t) => t.group === g);
|
||||
const rows = new Map<string, StandingRow>();
|
||||
groupTeams.forEach((t) => rows.set(t.id, emptyRow(t.id)));
|
||||
const groupMatches = matches.filter((m) => m.group === g);
|
||||
for (const m of groupMatches) applyMatch(rows, m);
|
||||
for (const m of groupMatches) applyMatch(rows, m, includeLive);
|
||||
rows.forEach(finalizeRow);
|
||||
|
||||
const arr = [...rows.values()];
|
||||
@@ -128,4 +137,4 @@ export function computeThirdPlaceTable(tables: GroupTable[]): ThirdPlaceRow[] {
|
||||
r.qualifies = i < 8;
|
||||
});
|
||||
return thirds;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user