changes
This commit is contained in:
@@ -3,9 +3,10 @@ import {
|
||||
R32, LATER_ROUNDS, R32Match, BracketSlot,
|
||||
ThirdAssignment, slotLabel,
|
||||
} from "@/lib/bracket";
|
||||
import { placeIsSecure } from "@/lib/secure-places";
|
||||
|
||||
// Eine Gruppe gilt als abgeschlossen, wenn alle ihre Gruppenspiele beendet sind
|
||||
// (regulär 6 Spiele pro Vierergruppe). Erst dann sind Platzierungen fix.
|
||||
// Eine Gruppe gilt als abgeschlossen, wenn alle ihre Gruppenspiele beendet sind.
|
||||
// Wird für die Drittplatzierten-Sicherheit genutzt (gruppenübergreifend).
|
||||
function groupFinished(group: GroupId, matches: Match[]): boolean {
|
||||
const groupMatches = matches.filter((m) => m.group === group);
|
||||
if (groupMatches.length === 0) return false;
|
||||
@@ -61,25 +62,29 @@ function resolveR32Slot(
|
||||
assignment: ThirdAssignment | null,
|
||||
thirds: ThirdPlaceRow[],
|
||||
matches: Match[],
|
||||
teams: Team[],
|
||||
annexResolved: boolean,
|
||||
): { teamId: string | null; provisional: boolean } {
|
||||
const table = (g: GroupId) => tables.find((t) => t.group === g);
|
||||
if (slot.type === "W") {
|
||||
const t = table(slot.group!);
|
||||
const teamId = t?.rows.find((r) => r.rank === 1)?.teamId ?? null;
|
||||
return { teamId, provisional: !groupFinished(slot.group!, matches) };
|
||||
// Sieger fix, sobald Platz 1 rechnerisch gesichert ist (auch vor Gruppenende).
|
||||
return { teamId, provisional: !placeIsSecure(slot.group!, 1, teams, matches) };
|
||||
}
|
||||
if (slot.type === "R") {
|
||||
const t = table(slot.group!);
|
||||
const teamId = t?.rows.find((r) => r.rank === 2)?.teamId ?? null;
|
||||
return { teamId, provisional: !groupFinished(slot.group!, matches) };
|
||||
// Zweiter fix, sobald Platz 2 rechnerisch gesichert ist.
|
||||
return { teamId, provisional: !placeIsSecure(slot.group!, 2, teams, matches) };
|
||||
}
|
||||
// 3. Platz: braucht Annex-C-Zuordnung + den Gruppensieger dieses Spiels
|
||||
if (slot.type === "3" && assignment && winnerGroup) {
|
||||
const thirdGroup = assignment[winnerGroup];
|
||||
if (thirdGroup) {
|
||||
const row = thirds.find((r) => r.group === thirdGroup && r.qualifies);
|
||||
// Fix nur, wenn Annex C aufgelöst UND die Quellgruppe abgeschlossen ist.
|
||||
// Fix nur, wenn Annex C aufgelöst UND die Quellgruppe abgeschlossen ist
|
||||
// (Drittplatzierten-Qualifikation ist gruppenübergreifend, bis zuletzt offen).
|
||||
const fix = annexResolved && groupFinished(thirdGroup, matches);
|
||||
return { teamId: row?.teamId ?? null, provisional: !fix };
|
||||
}
|
||||
@@ -126,8 +131,8 @@ export function resolveBracket(
|
||||
// Für 3.-Platz-Slots: Gruppensieger ist die andere Seite (immer W)
|
||||
const winnerGroup = (homeGroup ?? awayGroup) as GroupId | undefined;
|
||||
|
||||
const h = resolveR32Slot(rm.home, winnerGroup, tables, assignment, thirds, matches, annexResolved);
|
||||
const a = resolveR32Slot(rm.away, winnerGroup, tables, assignment, thirds, matches, annexResolved);
|
||||
const h = resolveR32Slot(rm.home, winnerGroup, tables, assignment, thirds, matches, teams, annexResolved);
|
||||
const a = resolveR32Slot(rm.away, winnerGroup, tables, assignment, thirds, matches, teams, annexResolved);
|
||||
const home = sideFrom(h.teamId, slotLabel(rm.home, assignment, winnerGroup), teams, feed, "home", h.provisional);
|
||||
const away = sideFrom(a.teamId, slotLabel(rm.away, assignment, winnerGroup), teams, feed, "away", a.provisional);
|
||||
|
||||
@@ -163,4 +168,4 @@ export function resolveBracket(
|
||||
}
|
||||
|
||||
return { r32, later };
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user