Compare commits
36 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| cfb778776e | |||
| 09020b7aef | |||
| dca3a66206 | |||
| 275dda65e0 | |||
| 2a57be6e2f | |||
| 63108cb5a1 | |||
| d982ff1068 | |||
| 6811fc8161 | |||
| edaca815a7 | |||
| 40618d2953 | |||
| 7c910e9199 | |||
| 1d94f805fd | |||
| b3eb21e59b | |||
| 87624ae484 | |||
| 6e73cccdff | |||
| a60cf9c604 | |||
| fafb9dce4b | |||
| 4896fe7159 | |||
| 1a99bd8029 | |||
| e9701ce25b | |||
| 4d838e2fb7 | |||
| 7bad12df68 | |||
| 89a9075391 | |||
| 2b3cadfcb5 | |||
| a721de5b23 | |||
| bf931e70c0 | |||
| 6bb6f9be7a | |||
| 6f0acaad4c | |||
| 1985289a37 | |||
| a38b3fa517 | |||
| 49256e83c6 | |||
| 6eec396b8c | |||
| 1cd4ae3bfb | |||
| 597d321a34 | |||
| c9bdc0c5cf | |||
| a4a47b431a |
@@ -5,3 +5,7 @@ FOOTBALL_DATA_TOKEN=dein_token_hier
|
||||
# Polymarket-Slug des WM-Events (Standard: world-cup-2026).
|
||||
# Den genauen Slug findest du in der Polymarket-URL nach /event/.
|
||||
POLYMARKET_WC_SLUG=world-cup-2026
|
||||
|
||||
# Umami Analytics (selbst gehostet, cookiefrei)
|
||||
# NEXT_PUBLIC_UMAMI_SRC=https://analytics.example.com/script.js
|
||||
# NEXT_PUBLIC_UMAMI_ID=deine-website-id
|
||||
|
||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -3,3 +3,4 @@ node_modules
|
||||
.env
|
||||
.env.local
|
||||
*.log
|
||||
testdata
|
||||
@@ -10,6 +10,12 @@ WORKDIR /app
|
||||
COPY --from=deps /app/node_modules ./node_modules
|
||||
COPY . .
|
||||
ENV NEXT_TELEMETRY_DISABLED=1
|
||||
|
||||
ARG NEXT_PUBLIC_UMAMI_SRC
|
||||
ARG NEXT_PUBLIC_UMAMI_ID
|
||||
ENV NEXT_PUBLIC_UMAMI_SRC=${NEXT_PUBLIC_UMAMI_SRC}
|
||||
ENV NEXT_PUBLIC_UMAMI_ID=${NEXT_PUBLIC_UMAMI_ID}
|
||||
|
||||
RUN npm run build
|
||||
|
||||
# --- Stufe 3: Runtime (standalone) ---
|
||||
|
||||
@@ -1,17 +1,19 @@
|
||||
"use client";
|
||||
|
||||
import { useState, useCallback } from "react";
|
||||
import { GroupTable, Match, Team, ThirdPlaceRow } from "@/lib/types";
|
||||
import { useMemo, useState, useCallback } from "react";
|
||||
import { GroupTable, Match, Team, ThirdPlaceRow, teamName } from "@/lib/types";
|
||||
import { ThirdAssignment, orderedRound } from "@/lib/bracket";
|
||||
import { resolveBracket, ResolvedSide, ResolvedTie } from "@/lib/resolve-bracket";
|
||||
import { Dictionary } from "@/lib/i18n";
|
||||
import { STADIUMS, MATCH_STADIUMS, MATCH_DATES } from "@/lib/stadiums";
|
||||
import Flag from "./Flag";
|
||||
|
||||
interface TipState { x: number; y: number; text: string }
|
||||
|
||||
function Side({
|
||||
s, prob, teams, onShowTip, onHideTip,
|
||||
s, prob, teams, locale, dict, onShowTip, onHideTip,
|
||||
}: {
|
||||
s: ResolvedSide; prob?: number | null; teams: Team[];
|
||||
s: ResolvedSide; prob?: number | null; teams: Team[]; locale: string; dict: Dictionary;
|
||||
onShowTip: (text: string, x: number, y: number) => void;
|
||||
onHideTip: () => void;
|
||||
}) {
|
||||
@@ -32,8 +34,8 @@ function Side({
|
||||
{s.teamId ? (
|
||||
<>
|
||||
<Flag team={team} size={18} />
|
||||
<span className="tn">{s.label}</span>
|
||||
{s.provisional && <span className="prov-mark" title="vorläufig – Gruppe/Zuordnung noch nicht fix">≈</span>}
|
||||
<span className="tn">{teamName(team, locale)}</span>
|
||||
{s.provisional && <span className="prov-mark" title={dict.bracket.provisionalTooltip}>≈</span>}
|
||||
</>
|
||||
) : (
|
||||
<span className="lbl">{s.label}</span>
|
||||
@@ -47,36 +49,71 @@ function Side({
|
||||
);
|
||||
}
|
||||
|
||||
function fmtMatchInfo(utcDate?: string, stadiumId?: string, locale: string = "de"): string {
|
||||
if (!utcDate) return "";
|
||||
const intlLocale = locale === "en" ? "en-US" : "de-DE";
|
||||
const d = new Date(utcDate);
|
||||
const dateStr = d.toLocaleDateString(intlLocale, { day: "numeric", month: "numeric" });
|
||||
const timeStr = d.toLocaleTimeString(intlLocale, { hour: "2-digit", minute: "2-digit" });
|
||||
const city = stadiumId ? STADIUMS[stadiumId]?.city : "";
|
||||
const parts = [`${dateStr}`, `${timeStr}`];
|
||||
if (city) parts.push(city);
|
||||
return parts.join(" ");
|
||||
}
|
||||
|
||||
function Tie({
|
||||
tie, teams, isFinal, onShowTip, onHideTip,
|
||||
tie, teams, isFinal, matchInfo, locale, dict, onShowTip, onHideTip,
|
||||
}: {
|
||||
tie: ResolvedTie; teams: Team[]; isFinal?: boolean;
|
||||
matchInfo?: string;
|
||||
locale: string; dict: Dictionary;
|
||||
onShowTip: (text: string, x: number, y: number) => void;
|
||||
onHideTip: () => void;
|
||||
}) {
|
||||
return (
|
||||
<div className={`tie ${isFinal ? "final-tie" : ""}`}>
|
||||
<div className="tie-head">Spiel {tie.matchNumber}</div>
|
||||
<Side s={tie.home} prob={tie.prob?.home} teams={teams} onShowTip={onShowTip} onHideTip={onHideTip} />
|
||||
<Side s={tie.away} prob={tie.prob?.away} teams={teams} onShowTip={onShowTip} onHideTip={onHideTip} />
|
||||
<div className="match-badge">{tie.matchNumber}</div>
|
||||
<div className="tie-meta">
|
||||
{matchInfo || dict.bracket.match(tie.matchNumber)}
|
||||
</div>
|
||||
<Side s={tie.home} prob={tie.prob?.home} teams={teams} locale={locale} dict={dict} onShowTip={onShowTip} onHideTip={onHideTip} />
|
||||
<Side s={tie.away} prob={tie.prob?.away} teams={teams} locale={locale} dict={dict} onShowTip={onShowTip} onHideTip={onHideTip} />
|
||||
{tie.homePenalty != null && tie.awayPenalty != null && (
|
||||
<div className="tie-meta" style={{ padding: "2px 10px 4px", textAlign: "center" }}>
|
||||
({tie.homePenalty}:{tie.awayPenalty} {dict.bracket.penaltyShootout})
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export default function Bracket({
|
||||
matches, teams, tables, thirds, assignment, annexResolved,
|
||||
preResolved,
|
||||
preResolved, dict, locale,
|
||||
}: {
|
||||
matches: Match[]; teams: Team[]; tables: GroupTable[];
|
||||
thirds: ThirdPlaceRow[]; assignment: ThirdAssignment | null; annexResolved: boolean;
|
||||
preResolved?: { r32: ResolvedTie[]; later: Record<number, ResolvedTie> };
|
||||
dict: Dictionary; locale: string;
|
||||
}) {
|
||||
const { r32: r32Array, later } = preResolved ?? resolveBracket(
|
||||
matches, teams, tables, thirds, assignment, annexResolved,
|
||||
matches, teams, tables, thirds, assignment, annexResolved, undefined, dict,
|
||||
);
|
||||
|
||||
const r32ByNum = new Map(r32Array.map((t) => [t.matchNumber, t]));
|
||||
|
||||
// Slot-Nummer → formatierte Anzeige (Datum/Uhrzeit aus MATCH_DATES, Stadt aus MATCH_STADIUMS)
|
||||
const matchMeta = useMemo(() => {
|
||||
const meta = new Map<number, string>();
|
||||
for (let n = 73; n <= 104; n++) {
|
||||
const utcDate = MATCH_DATES[n];
|
||||
const stadiumId = MATCH_STADIUMS[n];
|
||||
const info = fmtMatchInfo(utcDate, stadiumId, locale);
|
||||
if (info) meta.set(n, info);
|
||||
}
|
||||
return meta;
|
||||
}, [locale]);
|
||||
|
||||
const sfOrder = orderedRound([104]);
|
||||
const qfOrder = orderedRound(sfOrder);
|
||||
const r16Order = orderedRound(qfOrder);
|
||||
@@ -96,48 +133,48 @@ export default function Bracket({
|
||||
return (
|
||||
<div>
|
||||
<div className="bracket-banner">
|
||||
<span className="k">Annex-C-Zuordnung der Drittplatzierten:</span>
|
||||
<span className="k">{dict.bracket.annexHeader}</span>
|
||||
<span className="v">
|
||||
{annexResolved
|
||||
? "aufgelöst — die acht Dritten sind den Gruppensiegern fest zugeteilt"
|
||||
: "noch offen — sobald die 8 besten Dritten feststehen, verbindet sich der Baum automatisch"}
|
||||
? dict.bracket.annexResolved
|
||||
: dict.bracket.annexPending}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div className="bracket-scroll">
|
||||
<div className="bracket">
|
||||
<div className="round">
|
||||
<div className="round-label">Letzte 32</div>
|
||||
<div className="round-label">{dict.round.r32}</div>
|
||||
<div className="round-matches">
|
||||
{r32.map((t) => <Tie key={t.matchNumber} tie={t} teams={teams} onShowTip={showTip} onHideTip={hideTip} />)}
|
||||
{r32.map((t) => <Tie key={t.matchNumber} tie={t} teams={teams} locale={locale} dict={dict} matchInfo={matchMeta.get(t.matchNumber)} onShowTip={showTip} onHideTip={hideTip} />)}
|
||||
</div>
|
||||
</div>
|
||||
<div className="round">
|
||||
<div className="round-label">Achtelfinale</div>
|
||||
<div className="round-label">{dict.round.r16}</div>
|
||||
<div className="round-matches">
|
||||
{r16.map((t) => <Tie key={t.matchNumber} tie={t} teams={teams} onShowTip={showTip} onHideTip={hideTip} />)}
|
||||
{r16.map((t) => <Tie key={t.matchNumber} tie={t} teams={teams} locale={locale} dict={dict} matchInfo={matchMeta.get(t.matchNumber)} onShowTip={showTip} onHideTip={hideTip} />)}
|
||||
</div>
|
||||
</div>
|
||||
<div className="round">
|
||||
<div className="round-label">Viertelfinale</div>
|
||||
<div className="round-label">{dict.round.qf}</div>
|
||||
<div className="round-matches">
|
||||
{qf.map((t) => <Tie key={t.matchNumber} tie={t} teams={teams} onShowTip={showTip} onHideTip={hideTip} />)}
|
||||
{qf.map((t) => <Tie key={t.matchNumber} tie={t} teams={teams} locale={locale} dict={dict} matchInfo={matchMeta.get(t.matchNumber)} onShowTip={showTip} onHideTip={hideTip} />)}
|
||||
</div>
|
||||
</div>
|
||||
<div className="round">
|
||||
<div className="round-label">Halbfinale</div>
|
||||
<div className="round-label">{dict.round.sf}</div>
|
||||
<div className="round-matches">
|
||||
{sf.map((t) => <Tie key={t.matchNumber} tie={t} teams={teams} onShowTip={showTip} onHideTip={hideTip} />)}
|
||||
{sf.map((t) => <Tie key={t.matchNumber} tie={t} teams={teams} locale={locale} dict={dict} matchInfo={matchMeta.get(t.matchNumber)} onShowTip={showTip} onHideTip={hideTip} />)}
|
||||
</div>
|
||||
</div>
|
||||
<div className="round">
|
||||
<div className="round-label">Finale</div>
|
||||
<div className="round-label">{dict.round.final}</div>
|
||||
<div className="round-matches">
|
||||
{fin && <Tie tie={fin} teams={teams} isFinal onShowTip={showTip} onHideTip={hideTip} />}
|
||||
{fin && <Tie tie={fin} teams={teams} isFinal locale={locale} dict={dict} matchInfo={matchMeta.get(fin.matchNumber)} onShowTip={showTip} onHideTip={hideTip} />}
|
||||
{third && (
|
||||
<div style={{ marginTop: 20 }}>
|
||||
<div className="round-label" style={{ marginBottom: 8 }}>Spiel um Platz 3</div>
|
||||
<Tie tie={third} teams={teams} onShowTip={showTip} onHideTip={hideTip} />
|
||||
<div className="round-label" style={{ marginBottom: 8 }}>{dict.round.thirdPlace}</div>
|
||||
<Tie tie={third} teams={teams} locale={locale} dict={dict} matchInfo={matchMeta.get(third.matchNumber)} onShowTip={showTip} onHideTip={hideTip} />
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
@@ -146,12 +183,12 @@ export default function Bracket({
|
||||
</div>
|
||||
|
||||
<div className="legend">
|
||||
<span><i style={{ background: "var(--turf)" }} />Sieger / weiter</span>
|
||||
<span><i style={{ background: "var(--gold)" }} />Finale</span>
|
||||
<span><i className="leg-fix" />fix qualifiziert</span>
|
||||
<span><i className="leg-prov" />vorläufig (≈, nach aktueller Tabelle)</span>
|
||||
<span><i style={{ background: "var(--ink-faint)" }} />Platzhalter offen</span>
|
||||
<span>%-Werte: Polymarket-Wahrscheinlichkeit (falls verfügbar)</span>
|
||||
<span><i style={{ background: "var(--turf)" }} />{dict.legend.winner}</span>
|
||||
<span><i style={{ background: "var(--gold)" }} />{dict.legend.final}</span>
|
||||
<span><i className="leg-fix" />{dict.legend.fixed}</span>
|
||||
<span><i className="leg-prov" />{dict.legend.provisional}</span>
|
||||
<span><i style={{ background: "var(--ink-faint)" }} />{dict.legend.placeholder}</span>
|
||||
<span>{dict.legend.probExplanation}</span>
|
||||
</div>
|
||||
|
||||
{tip && (
|
||||
@@ -1,53 +1,54 @@
|
||||
"use client";
|
||||
|
||||
import { GROUP_IDS, GroupId, Match, Team } from "@/lib/types";
|
||||
import { GROUP_IDS, GroupId, Match, Team, teamName } from "@/lib/types";
|
||||
import { computeGroupTables } from "@/lib/standings";
|
||||
import { Dictionary } from "@/lib/i18n";
|
||||
import Flag from "./Flag";
|
||||
|
||||
function teamById(teams: Team[], id: string | null) {
|
||||
return id ? teams.find((t) => t.id === id) : undefined;
|
||||
}
|
||||
|
||||
// Kürzel der lokalen Browser-Zeitzone, z.B. "MEZ"/"GMT+1" – einmal ermittelt.
|
||||
const TZ_LABEL = (() => {
|
||||
function tzLabel(locale: string): string {
|
||||
try {
|
||||
const parts = new Intl.DateTimeFormat("de-DE", { timeZoneName: "short" })
|
||||
const parts = new Intl.DateTimeFormat(locale === "en" ? "en-US" : "de-DE", { timeZoneName: "short" })
|
||||
.formatToParts(new Date());
|
||||
return parts.find((p) => p.type === "timeZoneName")?.value ?? "";
|
||||
} catch {
|
||||
return "";
|
||||
}
|
||||
})();
|
||||
}
|
||||
|
||||
function fmtDate(iso: string): string {
|
||||
function fmtDate(iso: string, locale: string): string {
|
||||
const d = new Date(iso);
|
||||
const s = d.toLocaleString("de-DE", {
|
||||
const s = d.toLocaleString(locale === "en" ? "en-US" : "de-DE", {
|
||||
weekday: "short", day: "2-digit", month: "2-digit",
|
||||
hour: "2-digit", minute: "2-digit",
|
||||
});
|
||||
return TZ_LABEL ? `${s} ${TZ_LABEL}` : s;
|
||||
const tz = tzLabel(locale);
|
||||
return tz ? `${s} ${tz}` : s;
|
||||
}
|
||||
|
||||
function statusText(m: Match): { text: string; live: boolean } {
|
||||
function statusText(m: Match, dict: Dictionary): { text: string; live: boolean } {
|
||||
switch (m.status) {
|
||||
case "LIVE":
|
||||
case "IN_PLAY":
|
||||
return { text: m.minute != null ? `${m.minute}'` : "läuft", live: true };
|
||||
return { text: m.minute != null ? `${m.minute}'` : dict.status.running, live: true };
|
||||
case "PAUSED":
|
||||
return { text: "Halbzeit", live: true };
|
||||
return { text: dict.status.halftime, live: true };
|
||||
case "FINISHED":
|
||||
return { text: "Beendet", live: false };
|
||||
return { text: dict.status.finished, live: false };
|
||||
default:
|
||||
return { text: fmtDate(m.utcDate), live: false };
|
||||
return { text: "", live: false };
|
||||
}
|
||||
}
|
||||
|
||||
// Mitte: Ergebnis (wenn vorhanden) oder ein schlichtes "–" bei ungespielten
|
||||
// Spielen. Datum/Uhrzeit steht bereits links im Status und wird hier NICHT
|
||||
// wiederholt.
|
||||
function ScoreCell({ m }: { m: Match }) {
|
||||
function ScoreCell({ m, dict }: { m: Match; dict: Dictionary }) {
|
||||
const hasScore = m.homeScore != null && m.awayScore != null;
|
||||
const st = statusText(m);
|
||||
const st = statusText(m, dict);
|
||||
if (hasScore) {
|
||||
return (
|
||||
<span className={`fx-score ${st.live ? "score-live" : ""}`}>
|
||||
@@ -59,8 +60,8 @@ function ScoreCell({ m }: { m: Match }) {
|
||||
}
|
||||
|
||||
function GroupStandings({
|
||||
group, teams, matches,
|
||||
}: { group: GroupId; teams: Team[]; matches: Match[] }) {
|
||||
group, teams, matches, dict,
|
||||
}: { group: GroupId; teams: Team[]; matches: Match[]; dict: Dictionary }) {
|
||||
// Live-Tabelle: laufende Spiele werden mit Zwischenstand eingerechnet.
|
||||
const table = computeGroupTables(teams, matches, true).find((t) => t.group === group);
|
||||
if (!table) return null;
|
||||
@@ -80,15 +81,15 @@ function GroupStandings({
|
||||
return (
|
||||
<div className="fx-standings">
|
||||
<div className="fx-standings-title">
|
||||
Tabelle – Gruppe {group}
|
||||
{hasLive && <span className="fx-standings-live">● LIVE</span>}
|
||||
{dict.fixtures.standingsTitle(group)}
|
||||
{hasLive && <span className="fx-standings-live">{dict.label.liveIndicator}</span>}
|
||||
</div>
|
||||
<table className="standings">
|
||||
<thead>
|
||||
<tr>
|
||||
<th className="team">Mannschaft</th>
|
||||
<th>Sp</th><th>S</th><th>U</th><th>N</th>
|
||||
<th>Tore</th><th>±</th><th>Pkt</th>
|
||||
<th className="team">{dict.table.team}</th>
|
||||
<th>{dict.table.matches}</th><th>{dict.table.won}</th><th>{dict.table.drawn}</th><th>{dict.table.lost}</th>
|
||||
<th>{dict.table.goals}</th><th>{dict.table.goalDiff}</th><th>{dict.table.points}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@@ -101,8 +102,8 @@ function GroupStandings({
|
||||
<td className="team">
|
||||
<span className={`rankdot ${cls}`}>{r.rank}</span>
|
||||
<Flag team={team} size={20} />
|
||||
<span className="team-name">{team?.localisedName ?? team?.name ?? r.teamId}</span>
|
||||
{isLive && <span className="row-live-dot" title="läuft gerade" />}
|
||||
<span className="team-name">{teamName(team, "de")}</span>
|
||||
{isLive && <span className="row-live-dot" title={dict.status.running} />}
|
||||
</td>
|
||||
<td>{r.played}</td>
|
||||
<td>{r.won}</td>
|
||||
@@ -121,11 +122,13 @@ function GroupStandings({
|
||||
}
|
||||
|
||||
export default function Fixtures({
|
||||
group, teams, matches, onSelectGroup,
|
||||
group, teams, matches, onSelectGroup, dict, locale,
|
||||
}: {
|
||||
group: GroupId; teams: Team[]; matches: Match[];
|
||||
onSelectGroup: (g: GroupId) => void;
|
||||
dict: Dictionary; locale: string;
|
||||
}) {
|
||||
const intlLocale = locale === "en" ? "en-US" : "de-DE";
|
||||
const list = matches
|
||||
.filter((m) => m.group === group)
|
||||
.sort((a, b) => +new Date(a.utcDate) - +new Date(b.utcDate));
|
||||
@@ -145,36 +148,37 @@ export default function Fixtures({
|
||||
</div>
|
||||
|
||||
{list.length === 0 ? (
|
||||
<div className="notice">Für Gruppe {group} liegen noch keine Spiele im Feed vor.</div>
|
||||
<div className="notice">{dict.fixtures.noMatches(group)}</div>
|
||||
) : (
|
||||
<div className="fixtures">
|
||||
{list.map((m) => {
|
||||
const home = teamById(teams, m.homeTeamId);
|
||||
const away = teamById(teams, m.awayTeamId);
|
||||
const st = statusText(m);
|
||||
const st = statusText(m, dict);
|
||||
const displayText = st.text || fmtDate(m.utcDate, locale);
|
||||
const homeWin = m.homeScore != null && m.awayScore != null && m.homeScore > m.awayScore;
|
||||
const awayWin = m.homeScore != null && m.awayScore != null && m.awayScore > m.homeScore;
|
||||
return (
|
||||
<div className={`fx ${st.live ? "fx-live" : ""}`} key={m.id}>
|
||||
<div className="fx-status">
|
||||
{st.live && <span className="dot live" />}
|
||||
<span>{st.text}</span>
|
||||
<span>{displayText}</span>
|
||||
</div>
|
||||
<div className="fx-teams">
|
||||
<div className={`fx-team home ${homeWin ? "win" : ""}`}>
|
||||
<Flag team={home} size={22} />
|
||||
<span className="fx-name">{home?.localisedName ?? home?.name ?? "—"}</span>
|
||||
<span className="fx-name">{teamName(home, locale)}</span>
|
||||
</div>
|
||||
<ScoreCell m={m} />
|
||||
<ScoreCell m={m} dict={dict} />
|
||||
<div className={`fx-team away ${awayWin ? "win" : ""}`}>
|
||||
<Flag team={away} size={22} />
|
||||
<span className="fx-name">{away?.localisedName ?? away?.name ?? "—"}</span>
|
||||
<span className="fx-name">{teamName(away, locale)}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div className="fx-meta">
|
||||
{m.venue && <span className="fx-venue">📍 {m.venue}</span>}
|
||||
{m.attendance != null && (
|
||||
<span className="fx-att">👥 {m.attendance.toLocaleString("de-DE")}</span>
|
||||
<span className="fx-att">👥 {m.attendance.toLocaleString(intlLocale)}</span>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
@@ -184,7 +188,7 @@ export default function Fixtures({
|
||||
)}
|
||||
|
||||
{list.length > 0 && (
|
||||
<GroupStandings group={group} teams={teams} matches={matches} />
|
||||
<GroupStandings group={group} teams={teams} matches={matches} dict={dict} />
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
@@ -1,6 +1,7 @@
|
||||
"use client";
|
||||
|
||||
import { GroupId, GroupTable, Match, Team } from "@/lib/types";
|
||||
import { GroupId, GroupTable, Match, Team, teamName } from "@/lib/types";
|
||||
import { Dictionary } from "@/lib/i18n";
|
||||
import Flag from "./Flag";
|
||||
|
||||
function teamById(teams: Team[], id: string) {
|
||||
@@ -26,10 +27,11 @@ function liveTeamIdsFor(group: GroupId, matches: Match[]): Set<string> {
|
||||
}
|
||||
|
||||
export default function Groups({
|
||||
tables, teams, matches, onOpenGroup,
|
||||
tables, teams, matches, onOpenGroup, dict, locale,
|
||||
}: {
|
||||
tables: GroupTable[]; teams: Team[]; matches: Match[];
|
||||
onOpenGroup: (g: GroupId) => void;
|
||||
dict: Dictionary; locale: string;
|
||||
}) {
|
||||
return (
|
||||
<div className="group-grid">
|
||||
@@ -43,19 +45,19 @@ export default function Groups({
|
||||
<button
|
||||
className="group-head group-head-btn"
|
||||
onClick={() => onOpenGroup(t.group)}
|
||||
title={`Spiele der Gruppe ${t.group} ansehen`}
|
||||
title={dict.groups.viewGroupGames(t.group)}
|
||||
>
|
||||
<span className={`group-name${groupComplete ? " group-complete" : ""}`}>Gruppe {t.group}</span>
|
||||
<span className={`group-name${groupComplete ? " group-complete" : ""}`}>{dict.groups.groupLabel(t.group)}</span>
|
||||
<span className="group-tag">
|
||||
{live ? "● LIVE" : "Spiele ansehen →"}
|
||||
{live ? dict.label.liveIndicator : dict.groups.viewGames}
|
||||
</span>
|
||||
</button>
|
||||
<table className="standings">
|
||||
<thead>
|
||||
<tr>
|
||||
<th className="team">Mannschaft</th>
|
||||
<th>Sp</th><th>S</th><th>U</th><th>N</th>
|
||||
<th>Tore</th><th>±</th><th>Pkt</th>
|
||||
<th className="team">{dict.table.team}</th>
|
||||
<th>{dict.table.matches}</th><th>{dict.table.won}</th><th>{dict.table.drawn}</th><th>{dict.table.lost}</th>
|
||||
<th>{dict.table.goals}</th><th>{dict.table.goalDiff}</th><th>{dict.table.points}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@@ -68,8 +70,8 @@ export default function Groups({
|
||||
<td className="team">
|
||||
<span className={`rankdot ${cls}`}>{r.rank}</span>
|
||||
<Flag team={team} size={20} />
|
||||
<span className="team-name">{team?.localisedName ?? team?.name ?? r.teamId}</span>
|
||||
{isLive && <span className="row-live-dot" title="läuft gerade" />}
|
||||
<span className="team-name">{teamName(team, locale)}</span>
|
||||
{isLive && <span className="row-live-dot" title={dict.status.running} />}
|
||||
</td>
|
||||
<td>{r.played}</td>
|
||||
<td>{r.won}</td>
|
||||
281
app/[locale]/components/KoFixtures.tsx
Normal file
281
app/[locale]/components/KoFixtures.tsx
Normal file
@@ -0,0 +1,281 @@
|
||||
"use client";
|
||||
|
||||
import { useMemo, useState, useEffect, useRef } from "react";
|
||||
import { Match, Team, teamName } from "@/lib/types";
|
||||
import { STADIUMS, MATCH_STADIUMS } from "@/lib/stadiums";
|
||||
import { Dictionary } from "@/lib/i18n";
|
||||
import Flag from "./Flag";
|
||||
|
||||
function fmtShortDate(iso: string, locale: string): string {
|
||||
const d = new Date(iso);
|
||||
return d.toLocaleDateString(locale === "en" ? "en-US" : "de-DE", { weekday: "short", day: "2-digit", month: "2-digit" });
|
||||
}
|
||||
|
||||
function fmtTime(iso: string, locale: string): string {
|
||||
const d = new Date(iso);
|
||||
return d.toLocaleTimeString(locale === "en" ? "en-US" : "de-DE", { hour: "2-digit", minute: "2-digit" });
|
||||
}
|
||||
|
||||
function scoreDisplay(m: Match, dict: Dictionary): string {
|
||||
if (m.status === "SCHEDULED" || m.status === "POSTPONED" || (m.homeScore == null && m.awayScore == null)) return "– : –";
|
||||
const base = `${m.homeScore ?? 0} : ${m.awayScore ?? 0}`;
|
||||
if (m.homePenalty != null && m.awayPenalty != null) {
|
||||
return `${base} (${m.homePenalty}:${m.awayPenalty} ${dict.bracket.penaltyShootout})`;
|
||||
}
|
||||
return base;
|
||||
}
|
||||
|
||||
function isLive(m: Match): boolean {
|
||||
return m.status === "LIVE" || m.status === "IN_PLAY" || m.status === "PAUSED";
|
||||
}
|
||||
|
||||
export default function KoFixtures({ teams, matches, dict, locale }: { teams: Team[]; matches: Match[]; dict: Dictionary; locale: string }) {
|
||||
const [mounted, setMounted] = useState(false);
|
||||
useEffect(() => { setMounted(true); }, []);
|
||||
|
||||
function statusLabel(m: Match): string {
|
||||
switch (m.status) {
|
||||
case "LIVE": case "IN_PLAY": return m.minute != null ? `${m.minute}'` : dict.status.live;
|
||||
case "PAUSED": return dict.status.halftime;
|
||||
case "POSTPONED": return dict.status.postponed;
|
||||
case "FINISHED": return dict.status.finished;
|
||||
default: return fmtTime(m.utcDate, locale);
|
||||
}
|
||||
}
|
||||
|
||||
const koMatches = useMemo(() => {
|
||||
return matches
|
||||
.filter((m) =>
|
||||
m.group == null &&
|
||||
m.homeTeamId != null && m.awayTeamId != null &&
|
||||
// Nur Spiele mit bekannten Teams (keine TBD)
|
||||
teams.some(t => t.id === m.homeTeamId) &&
|
||||
teams.some(t => t.id === m.awayTeamId),
|
||||
)
|
||||
.sort((a, b) => +new Date(a.utcDate) - +new Date(b.utcDate));
|
||||
}, [matches, teams]);
|
||||
|
||||
// Lokale Datums-Extraktion (vermeidet UTC-Tagesverschiebung bei US-Spielen)
|
||||
function localDateKey(iso: string): string {
|
||||
const d = new Date(iso);
|
||||
const y = d.getFullYear();
|
||||
const m = String(d.getMonth() + 1).padStart(2, "0");
|
||||
const day = String(d.getDate()).padStart(2, "0");
|
||||
return `${y}-${m}-${day}`;
|
||||
}
|
||||
|
||||
// Nach Datum gruppieren (lokale Zeitzone nach Hydration, sonst UTC)
|
||||
const groups = useMemo(() => {
|
||||
const map = new Map<string, Match[]>();
|
||||
for (const m of koMatches) {
|
||||
const key = mounted ? localDateKey(m.utcDate) : m.utcDate.slice(0, 10);
|
||||
if (!map.has(key)) map.set(key, []);
|
||||
map.get(key)!.push(m);
|
||||
}
|
||||
return [...map.entries()];
|
||||
}, [koMatches, mounted]);
|
||||
|
||||
const targetMatchId = useMemo(() => {
|
||||
const live = koMatches.find(m => isLive(m));
|
||||
if (live) return live.id;
|
||||
const upcoming = koMatches.find(m => m.status !== "FINISHED");
|
||||
return upcoming?.id ?? null;
|
||||
}, [koMatches]);
|
||||
|
||||
const targetRef = useRef<HTMLDivElement>(null);
|
||||
const hasScrolledRef = useRef<string | null>(null);
|
||||
|
||||
useEffect(() => {
|
||||
if (!mounted || !targetRef.current) return;
|
||||
if (targetMatchId === hasScrolledRef.current) return;
|
||||
const el = targetRef.current;
|
||||
const raf = requestAnimationFrame(() => {
|
||||
const rect = el.getBoundingClientRect();
|
||||
const absoluteTop = rect.top + window.scrollY;
|
||||
const offset = 180;
|
||||
window.scrollTo({ top: Math.max(0, absoluteTop - offset), behavior: "smooth" });
|
||||
});
|
||||
hasScrolledRef.current = targetMatchId;
|
||||
return () => cancelAnimationFrame(raf);
|
||||
}, [mounted, targetMatchId, koMatches.length]);
|
||||
|
||||
const [showScrollTop, setShowScrollTop] = useState(false);
|
||||
useEffect(() => {
|
||||
const onScroll = () => setShowScrollTop(window.scrollY > 100);
|
||||
window.addEventListener("scroll", onScroll, { passive: true });
|
||||
onScroll();
|
||||
return () => window.removeEventListener("scroll", onScroll);
|
||||
}, []);
|
||||
|
||||
if (koMatches.length === 0) {
|
||||
return <div className="notice">{dict.koFixtures.noMatches}</div>;
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<div>
|
||||
{groups.map(([date, groupMatches]) => (
|
||||
<div key={date} style={{ marginBottom: 24 }}>
|
||||
<h3 style={{
|
||||
fontFamily: "var(--font-display)", fontSize: 13,
|
||||
textTransform: "uppercase", letterSpacing: "0.06em",
|
||||
color: "var(--ink-dim)", margin: "0 0 10px",
|
||||
}}>
|
||||
{fmtShortDate(groupMatches[0].utcDate, locale)}
|
||||
</h3>
|
||||
<div style={{ display: "flex", flexDirection: "column", gap: 8 }}>
|
||||
{groupMatches.map((m) => {
|
||||
const home = m.homeTeamId ? teams.find(t => t.id === m.homeTeamId) : undefined;
|
||||
const away = m.awayTeamId ? teams.find(t => t.id === m.awayTeamId) : undefined;
|
||||
const live = isLive(m);
|
||||
const stageMap: Record<string, string> = {
|
||||
R32: "R32", R16: dict.stage.r16, QF: dict.stage.qf,
|
||||
SF: dict.stage.sf, "3RD": dict.stage.thirdPlace, FINAL: dict.stage.final,
|
||||
};
|
||||
|
||||
const city = STADIUMS[MATCH_STADIUMS[m.matchNumber]]?.city;
|
||||
const isTarget = String(m.id) === String(targetMatchId);
|
||||
const finished = m.status === "FINISHED";
|
||||
|
||||
return (
|
||||
<div
|
||||
key={m.id}
|
||||
ref={isTarget ? targetRef : undefined}
|
||||
style={{
|
||||
background: "var(--bg-card)",
|
||||
border: `${isTarget ? 2 : 1}px solid ${live ? "var(--turf)" : isTarget ? "var(--turf)" : "var(--line-soft)"}`,
|
||||
borderRadius: "var(--radius-sm)", padding: "12px 14px",
|
||||
opacity: finished && !isTarget ? 0.65 : 1,
|
||||
boxShadow: isTarget ? "0 0 0 1px var(--turf)" : undefined,
|
||||
}}
|
||||
>
|
||||
{/* Kopfzeile */}
|
||||
<div style={{
|
||||
display: "flex", justifyContent: "space-between", alignItems: "center",
|
||||
marginBottom: 8, fontSize: 11,
|
||||
fontFamily: "var(--font-mono)", color: "var(--ink-faint)",
|
||||
}}>
|
||||
<span style={{ display: "flex", alignItems: "center", gap: 8 }}>
|
||||
{isTarget && (
|
||||
<span style={{
|
||||
background: live ? "var(--turf)" : "var(--turf-deep)",
|
||||
color: "#fff", fontSize: 9, fontWeight: 700,
|
||||
padding: "1px 6px", borderRadius: 999,
|
||||
letterSpacing: "0.04em",
|
||||
}}>
|
||||
{live ? dict.koFixtures.liveBadge : dict.koFixtures.nextMatch}
|
||||
</span>
|
||||
)}
|
||||
{m.status === "POSTPONED" && (
|
||||
<span style={{
|
||||
background: "var(--ink-faint)", color: "#fff",
|
||||
fontSize: 9, fontWeight: 700,
|
||||
padding: "1px 6px", borderRadius: 999,
|
||||
letterSpacing: "0.04em",
|
||||
}}>
|
||||
{dict.koFixtures.postponedBadge}
|
||||
</span>
|
||||
)}
|
||||
{stageMap[m.stage] ?? m.stage} · {m.matchNumber ? dict.koFixtures.match(m.matchNumber) : dict.koFixtures.match(0).replace("0", "—")}
|
||||
{city ? ` · ${city}` : ""}
|
||||
</span>
|
||||
<span style={{ color: live ? "var(--turf)" : undefined, fontWeight: live ? 700 : undefined }}>
|
||||
{statusLabel(m)}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
{/* Teams + Score */}
|
||||
<div style={{ display: "flex", alignItems: "center", justifyContent: "space-between" }}>
|
||||
<TeamLabel team={home} locale={locale} />
|
||||
<span style={{
|
||||
fontFamily: "var(--font-mono)", fontSize: 22, fontWeight: 700,
|
||||
color: live ? "var(--turf)" : "var(--ink)",
|
||||
padding: "0 16px",
|
||||
}}>
|
||||
{scoreDisplay(m, dict)}
|
||||
</span>
|
||||
<TeamLabel team={away} reverse locale={locale} />
|
||||
</div>
|
||||
|
||||
{/* Torabfolge */}
|
||||
{m.goals && m.goals.length > 0 && (
|
||||
<div style={{
|
||||
marginTop: 8, padding: "8px 10px",
|
||||
background: "var(--bg-raised)", borderRadius: "var(--radius-sm)",
|
||||
fontSize: 12, fontFamily: "var(--font-mono)",
|
||||
}}>
|
||||
<div style={{ color: "var(--ink-faint)", fontSize: 10, marginBottom: 4 }}>
|
||||
{dict.label.goals}
|
||||
</div>
|
||||
<div style={{ display: "flex", flexWrap: "wrap", gap: 6 }}>
|
||||
{m.goals.map((g, i) => (
|
||||
<span key={i} style={{
|
||||
display: "inline-flex", alignItems: "center", gap: 4,
|
||||
}}>
|
||||
<Flag team={g.team === "home" ? home : away} size={14} />
|
||||
<span style={{ color: "var(--turf)", fontWeight: 700 }}>
|
||||
{g.scorer}
|
||||
</span>
|
||||
<span style={{ color: "var(--ink-faint)", fontSize: 10 }}>
|
||||
{g.minute}'
|
||||
</span>
|
||||
</span>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Prob (falls vorhanden) */}
|
||||
{m.prob && m.prob.home > 0 && (
|
||||
<div style={{
|
||||
marginTop: 6, fontSize: 10, color: "var(--ink-faint)",
|
||||
fontFamily: "var(--font-mono)",
|
||||
}}>
|
||||
Polymarket: {Math.round(m.prob.home * 100)}% / {Math.round(m.prob.draw * 100)}% / {Math.round(m.prob.away * 100)}%
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
{showScrollTop && (
|
||||
<button
|
||||
onClick={() => window.scrollTo({ top: 0, behavior: "smooth" })}
|
||||
style={{
|
||||
position: "fixed", right: 24, bottom: 24, zIndex: 50,
|
||||
width: 48, height: 48, borderRadius: "50%",
|
||||
background: "var(--bg-card)", color: "var(--ink-dim)",
|
||||
border: "1px solid var(--line)", boxShadow: "0 2px 8px rgba(0,0,0,0.4)",
|
||||
cursor: "pointer", display: "flex", alignItems: "center", justifyContent: "center",
|
||||
fontSize: 22, lineHeight: 1,
|
||||
}}
|
||||
title={dict.label.scrollToTop}
|
||||
>
|
||||
↑
|
||||
</button>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
function TeamLabel({ team, reverse, locale }: { team?: Team; reverse?: boolean; locale: string }) {
|
||||
return (
|
||||
<div style={{
|
||||
display: "flex", alignItems: "center", gap: 8,
|
||||
flexDirection: reverse ? "row-reverse" : "row",
|
||||
flex: 1, minWidth: 0,
|
||||
}}>
|
||||
<Flag team={team} size={20} />
|
||||
<span style={{
|
||||
fontWeight: 600, fontSize: 14,
|
||||
whiteSpace: "nowrap", overflow: "hidden", textOverflow: "ellipsis",
|
||||
maxWidth: 120,
|
||||
}}>
|
||||
{teamName(team, locale)}
|
||||
</span>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
118
app/[locale]/components/Simulation.tsx
Normal file
118
app/[locale]/components/Simulation.tsx
Normal file
@@ -0,0 +1,118 @@
|
||||
"use client";
|
||||
|
||||
import { useMemo } from "react";
|
||||
import { Match, Team } from "@/lib/types";
|
||||
import { Dictionary } from "@/lib/i18n";
|
||||
import { computeGroupTables, computeThirdPlaceTable } from "@/lib/standings";
|
||||
import { qualifiedThirdGroups, resolveAnnexC, LATER_ROUNDS } from "@/lib/bracket";
|
||||
import { resolveBracket, ResolvedTie } from "@/lib/resolve-bracket";
|
||||
import { buildSimMatches } from "@/lib/simulation";
|
||||
import Bracket from "./Bracket";
|
||||
|
||||
export default function Simulation({ teams, matches, dict, locale }: { teams: Team[]; matches: Match[]; dict: Dictionary; locale: string }) {
|
||||
// ---- Simulations-Pipeline (Polymarket-Defaults, keine manuellen Overrides) ----
|
||||
const simMatches = useMemo(() => buildSimMatches(matches, {}), [matches]);
|
||||
const simTables = useMemo(() => computeGroupTables(teams, simMatches), [teams, simMatches]);
|
||||
const simThirds = useMemo(() => computeThirdPlaceTable(simTables), [simTables]);
|
||||
const simQGroups = useMemo(() => qualifiedThirdGroups(simThirds), [simThirds]);
|
||||
const simAnnex = useMemo(
|
||||
() => (simQGroups.length === 8 ? resolveAnnexC(simQGroups) : null),
|
||||
[simQGroups],
|
||||
);
|
||||
const simAnnexResolved = simAnnex != null;
|
||||
|
||||
const simBracket = useMemo(
|
||||
() => resolveBracket(simMatches, teams, simTables, simThirds, simAnnex, simAnnexResolved, true, dict),
|
||||
[simMatches, teams, simTables, simThirds, simAnnex, simAnnexResolved, dict],
|
||||
);
|
||||
|
||||
// Echte Tabellen/Bracket für fix/provisional-Flags (nur tatsächlich FINISHED).
|
||||
const realTables = useMemo(() => computeGroupTables(teams, matches), [teams, matches]);
|
||||
const realThirds = useMemo(() => computeThirdPlaceTable(realTables), [realTables]);
|
||||
const realQGroups = useMemo(() => qualifiedThirdGroups(realThirds), [realThirds]);
|
||||
const realAnnex = useMemo(
|
||||
() => (realQGroups.length === 8 ? resolveAnnexC(realQGroups) : null),
|
||||
[realQGroups],
|
||||
);
|
||||
const realBracket = useMemo(
|
||||
() => resolveBracket(matches, teams, realTables, realThirds, realAnnex, realAnnex != null, undefined, dict),
|
||||
[matches, teams, realTables, realThirds, realAnnex, dict],
|
||||
);
|
||||
|
||||
// R32: provisional-Flags aus dem echten Bracket übernehmen.
|
||||
const realProvisional = useMemo(() => {
|
||||
const m = new Map<number, { home: boolean; away: boolean }>();
|
||||
for (const tie of realBracket.r32) {
|
||||
m.set(tie.matchNumber, { home: tie.home.provisional, away: tie.away.provisional });
|
||||
}
|
||||
return m;
|
||||
}, [realBracket]);
|
||||
|
||||
// Folgerunden: decided-Flags aus echten Matches (status === FINISHED).
|
||||
const realDecided = useMemo(() => {
|
||||
const m = new Map<number, boolean>();
|
||||
for (const mt of matches) {
|
||||
if (mt.group == null && mt.matchNumber >= 73) {
|
||||
m.set(mt.matchNumber, mt.status === "FINISHED");
|
||||
}
|
||||
}
|
||||
return m;
|
||||
}, [matches]);
|
||||
|
||||
// Sim-Bracket mit echten provisional-Flags mergen (inkl. Tooltip-Korrektur).
|
||||
const preResolved = useMemo(() => {
|
||||
const fixTooltip = (t: string | null, prov: boolean): string | null => {
|
||||
if (!t) return t;
|
||||
if (prov) return t.startsWith("aktuell ") ? t : `aktuell ${t}`;
|
||||
return t.startsWith("aktuell ") ? t.slice(8) : t;
|
||||
};
|
||||
|
||||
const r32Fixed: ResolvedTie[] = simBracket.r32.map((tie) => {
|
||||
const rp = realProvisional.get(tie.matchNumber);
|
||||
if (!rp) return tie;
|
||||
return {
|
||||
...tie,
|
||||
home: { ...tie.home, provisional: rp.home, tooltip: fixTooltip(tie.home.tooltip, rp.home) },
|
||||
away: { ...tie.away, provisional: rp.away, tooltip: fixTooltip(tie.away.tooltip, rp.away) },
|
||||
};
|
||||
});
|
||||
|
||||
const laterFixed: Record<number, ResolvedTie> = {};
|
||||
for (const km of LATER_ROUNDS) {
|
||||
const tie = simBracket.later[km.matchNumber];
|
||||
if (!tie) continue;
|
||||
const homeProv = !(realDecided.get(km.fromHome) ?? false);
|
||||
const awayProv = !(realDecided.get(km.fromAway) ?? false);
|
||||
laterFixed[km.matchNumber] = {
|
||||
...tie,
|
||||
home: { ...tie.home, provisional: homeProv },
|
||||
away: { ...tie.away, provisional: awayProv },
|
||||
};
|
||||
}
|
||||
|
||||
return { r32: r32Fixed, later: laterFixed };
|
||||
}, [simBracket, realProvisional, realDecided]);
|
||||
|
||||
return (
|
||||
<div>
|
||||
<div className="notice" style={{ marginBottom: 20 }}>
|
||||
{dict.sim.notice}
|
||||
</div>
|
||||
|
||||
<h3 style={{ fontFamily: "var(--font-display)", fontSize: 15, textTransform: "uppercase", letterSpacing: "0.06em", color: "var(--ink-dim)", margin: "0 0 12px" }}>
|
||||
{dict.sim.heading}
|
||||
</h3>
|
||||
<Bracket
|
||||
matches={simMatches}
|
||||
teams={teams}
|
||||
tables={simTables}
|
||||
thirds={simThirds}
|
||||
assignment={simAnnex}
|
||||
annexResolved={simAnnexResolved}
|
||||
preResolved={preResolved}
|
||||
dict={dict}
|
||||
locale={locale}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -1,28 +1,27 @@
|
||||
"use client";
|
||||
|
||||
import { Team, ThirdPlaceRow } from "@/lib/types";
|
||||
import { Team, ThirdPlaceRow, teamName } from "@/lib/types";
|
||||
import { Dictionary } from "@/lib/i18n";
|
||||
|
||||
export default function ThirdPlace({
|
||||
rows, teams,
|
||||
}: { rows: ThirdPlaceRow[]; teams: Team[] }) {
|
||||
rows, teams, secureTeams, dict,
|
||||
}: { rows: ThirdPlaceRow[]; teams: Team[]; secureTeams?: string[]; dict: Dictionary }) {
|
||||
const name = (id: string) => {
|
||||
const t = teams.find((t) => t.id === id);
|
||||
return t?.localisedName ?? t?.name ?? id;
|
||||
return teamName(t, "de");
|
||||
};
|
||||
const secureSet = secureTeams ? new Set(secureTeams) : null;
|
||||
|
||||
return (
|
||||
<div className="third-wrap">
|
||||
<p className="notice" style={{ marginBottom: 16 }}>
|
||||
Acht der zwölf Gruppendritten erreichen die Runde der letzten 32. Gewertet wird
|
||||
gruppenübergreifend nach Punkten, Tordifferenz und Toren — der Direktvergleich
|
||||
entfällt, weil diese Teams nie gegeneinander gespielt haben. Die Trennlinie markiert
|
||||
den Schnitt zwischen Platz 8 und 9.
|
||||
{dict.thirds.explanation}
|
||||
</p>
|
||||
<table className="third-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>#</th><th>Gruppe</th><th>Team</th>
|
||||
<th>Sp</th><th>Pkt</th><th>±</th><th>Tore</th><th>Status</th>
|
||||
<th>{dict.table.rank}</th><th>{dict.table.group}</th><th>Team</th>
|
||||
<th>{dict.table.matches}</th><th>{dict.table.points}</th><th>{dict.table.goalDiff}</th><th>{dict.table.goals}</th><th>{dict.table.status}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@@ -35,14 +34,19 @@ export default function ThirdPlace({
|
||||
>
|
||||
<td>{r.overallRank}</td>
|
||||
<td>{r.group}</td>
|
||||
<td style={{ fontWeight: 600 }}>{name(r.teamId)}</td>
|
||||
<td className={r.played === 3 ? "team-complete" : ""} style={{ fontWeight: 600 }}>
|
||||
{name(r.teamId)}
|
||||
{secureSet?.has(r.teamId) && (
|
||||
<span style={{ color: "var(--turf)", marginLeft: 6, fontSize: 13 }} title={dict.label.securelyQualified}>✓</span>
|
||||
)}
|
||||
</td>
|
||||
<td>{r.played}</td>
|
||||
<td className="pts">{r.points}</td>
|
||||
<td>{r.goalDiff > 0 ? `+${r.goalDiff}` : r.goalDiff}</td>
|
||||
<td>{r.goalsFor}:{r.goalsAgainst}</td>
|
||||
<td>
|
||||
<span className={`qual-badge ${r.qualifies ? "yes" : "no"}`}>
|
||||
{r.qualifies ? "weiter" : "raus"}
|
||||
{r.qualifies ? dict.thirds.advances : dict.thirds.eliminated}
|
||||
</span>
|
||||
</td>
|
||||
</tr>
|
||||
BIN
app/[locale]/favicon.ico
Normal file
BIN
app/[locale]/favicon.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 15 KiB |
501
app/[locale]/globals.css
Normal file
501
app/[locale]/globals.css
Normal file
@@ -0,0 +1,501 @@
|
||||
:root {
|
||||
/* Palette: Stadion bei Nacht über drei Zeitzonen.
|
||||
Tiefes Mitternachtsblau, kühles Flutlicht-Weiß, warmer Rasen-Akzent,
|
||||
ein Signal-Magenta für "live". Bewusst nicht die üblichen AI-Defaults. */
|
||||
--bg: #0b1020;
|
||||
--bg-raised: #121a32;
|
||||
--bg-card: #16203c;
|
||||
--line: #243152;
|
||||
--line-soft: #1b2540;
|
||||
--ink: #eef2fb;
|
||||
--ink-dim: #9aa6c4;
|
||||
--ink-faint: #5f6d92;
|
||||
--turf: #4ade80; /* Rasen / qualifiziert */
|
||||
--turf-deep: #1f7a45;
|
||||
--floodlight: #cfe0ff;
|
||||
--live: #ff3d7f; /* Live-Signal */
|
||||
--gold: #ffd24a; /* Sieger / Finale */
|
||||
--radius: 10px;
|
||||
--radius-sm: 6px;
|
||||
--shadow: 0 8px 30px rgba(0, 0, 0, 0.35);
|
||||
|
||||
--font-display: "Archivo Expanded", "Archivo", system-ui, sans-serif;
|
||||
--font-body: "Inter", system-ui, -apple-system, sans-serif;
|
||||
--font-mono: "Geist Mono", "SFMono-Regular", ui-monospace, monospace;
|
||||
}
|
||||
|
||||
* { box-sizing: border-box; margin: 0; padding: 0; }
|
||||
|
||||
html { scroll-behavior: smooth; }
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
html { scroll-behavior: auto; }
|
||||
* { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
|
||||
}
|
||||
|
||||
body {
|
||||
background:
|
||||
radial-gradient(1200px 600px at 70% -10%, #16224a 0%, transparent 55%),
|
||||
radial-gradient(900px 500px at 10% 0%, #102046 0%, transparent 50%),
|
||||
var(--bg);
|
||||
color: var(--ink);
|
||||
font-family: var(--font-body);
|
||||
font-size: 15px;
|
||||
line-height: 1.5;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
min-height: 100vh;
|
||||
}
|
||||
|
||||
a { color: inherit; text-decoration: none; }
|
||||
|
||||
.wrap { max-width: 1240px; margin: 0 auto; padding: 0 20px 0 0; }
|
||||
|
||||
/* ---------- Header / Hero ---------- */
|
||||
.masthead {
|
||||
border-bottom: 1px solid var(--line);
|
||||
background: linear-gradient(180deg, rgba(18,26,50,0.7), transparent);
|
||||
position: sticky; top: 0; z-index: 50;
|
||||
backdrop-filter: blur(10px);
|
||||
}
|
||||
.masthead-inner {
|
||||
display: flex; align-items: center; justify-content: space-between;
|
||||
padding: 14px 0; gap: 16px; flex-wrap: wrap;
|
||||
}
|
||||
.brand { display: flex; align-items: baseline; gap: 12px; }
|
||||
.brand-mark {
|
||||
font-family: var(--font-display);
|
||||
font-weight: 800; letter-spacing: -0.02em;
|
||||
font-size: clamp(20px, 3vw, 28px);
|
||||
text-transform: uppercase;
|
||||
}
|
||||
.brand-mark .accent { color: var(--turf); }
|
||||
.brand-sub {
|
||||
font-family: var(--font-mono); font-size: 11px;
|
||||
color: var(--ink-faint); letter-spacing: 0.08em; text-transform: uppercase;
|
||||
}
|
||||
|
||||
.status-pill {
|
||||
display: inline-flex; align-items: center; gap: 8px;
|
||||
font-family: var(--font-mono); font-size: 12px;
|
||||
color: var(--ink-dim);
|
||||
border: 1px solid var(--line); border-radius: 999px;
|
||||
padding: 6px 12px; background: var(--bg-card);
|
||||
}
|
||||
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ink-faint); }
|
||||
.dot.on { background: var(--turf); box-shadow: 0 0 0 3px rgba(74,222,128,0.18); }
|
||||
.dot.live { background: var(--live); box-shadow: 0 0 0 3px rgba(255,61,127,0.2); animation: pulse 1.6s infinite; }
|
||||
@keyframes pulse { 50% { box-shadow: 0 0 0 6px rgba(255,61,127,0); } }
|
||||
|
||||
/* ---------- Tabs ---------- */
|
||||
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: 0 0 4px; }
|
||||
.masthead-tabs { width: 100%; border-bottom: none; margin: 0; }
|
||||
.tab {
|
||||
font-family: var(--font-display); font-weight: 700;
|
||||
text-transform: uppercase; letter-spacing: 0.01em;
|
||||
font-size: 14px; color: var(--ink-faint);
|
||||
padding: 16px 18px; cursor: pointer; border: none; background: none;
|
||||
border-bottom: 2px solid transparent; transition: color .15s, border-color .15s;
|
||||
}
|
||||
.tab:hover { color: var(--ink-dim); }
|
||||
.tab.active { color: var(--ink); border-bottom-color: var(--turf); }
|
||||
|
||||
.section { padding: 28px 0 64px; }
|
||||
|
||||
/* ---------- Gruppen ---------- */
|
||||
.group-grid {
|
||||
display: grid; gap: 16px;
|
||||
grid-template-columns: repeat(auto-fill, minmax(330px, 1fr));
|
||||
}
|
||||
.group-card {
|
||||
background: var(--bg-card); border: 1px solid var(--line);
|
||||
border-radius: var(--radius); overflow: hidden;
|
||||
}
|
||||
.group-head {
|
||||
display: flex; align-items: center; justify-content: space-between;
|
||||
padding: 12px 14px; border-bottom: 1px solid var(--line-soft);
|
||||
background: var(--bg-raised);
|
||||
}
|
||||
.group-name {
|
||||
font-family: var(--font-display); font-weight: 800; font-size: 16px;
|
||||
text-transform: uppercase; letter-spacing: 0.02em;
|
||||
}
|
||||
.group-name.group-complete { color: var(--turf); }
|
||||
.group-tag { font-family: var(--font-mono); font-size: 10px; color: var(--ink-faint); }
|
||||
|
||||
table.standings { width: 100%; border-collapse: collapse; }
|
||||
.standings th {
|
||||
font-family: var(--font-mono); font-size: 10px; font-weight: 500;
|
||||
text-transform: uppercase; letter-spacing: 0.06em;
|
||||
color: var(--ink-faint); text-align: right; padding: 8px 6px;
|
||||
}
|
||||
.standings th.team { text-align: left; padding-left: 14px; }
|
||||
.standings td {
|
||||
padding: 9px 6px; text-align: right; font-variant-numeric: tabular-nums;
|
||||
border-top: 1px solid var(--line-soft); font-size: 13px;
|
||||
}
|
||||
.standings td.team {
|
||||
text-align: left; padding-left: 14px; display: flex; align-items: center; gap: 9px;
|
||||
}
|
||||
.rankdot {
|
||||
width: 18px; height: 18px; border-radius: 5px; flex: none;
|
||||
display: grid; place-items: center;
|
||||
font-family: var(--font-mono); font-size: 10px; font-weight: 600;
|
||||
color: var(--bg); background: var(--ink-faint);
|
||||
}
|
||||
.rankdot.q1, .rankdot.q2 { background: var(--turf); }
|
||||
.rankdot.q3 { background: var(--gold); color: #2a2200; }
|
||||
.rankdot.q3.out { background: var(--ink-faint); color: var(--bg); }
|
||||
.team-name { font-weight: 600; }
|
||||
.team-code { font-family: var(--font-mono); font-size: 11px; color: var(--ink-faint); }
|
||||
.pts { font-weight: 700; color: var(--floodlight); }
|
||||
|
||||
/* Live-Zeile */
|
||||
.score-live { color: var(--live); font-weight: 700; }
|
||||
|
||||
/* Gruppen-Tab: grüne Hervorhebung für Teams mit laufendem Spiel */
|
||||
.group-grid .row-live { background: rgba(74, 222, 128, 0.08); }
|
||||
.group-grid .row-live .team-name { color: var(--turf); }
|
||||
.group-grid .row-live-dot {
|
||||
background: var(--turf);
|
||||
}
|
||||
|
||||
/* ---------- Drittplatzierte ---------- */
|
||||
.third-wrap { margin-top: 8px; }
|
||||
.third-table { width: 100%; border-collapse: collapse; background: var(--bg-card);
|
||||
border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
|
||||
.third-table th {
|
||||
font-family: var(--font-mono); font-size: 10px; text-transform: uppercase;
|
||||
letter-spacing: 0.06em; color: var(--ink-faint); padding: 11px 12px; text-align: right;
|
||||
background: var(--bg-raised); border-bottom: 1px solid var(--line);
|
||||
}
|
||||
.third-table th:first-child, .third-table td:first-child { text-align: left; }
|
||||
.third-table td {
|
||||
padding: 10px 12px; text-align: right; font-variant-numeric: tabular-nums;
|
||||
border-top: 1px solid var(--line-soft); font-size: 13px;
|
||||
}
|
||||
.third-row.qual { background: linear-gradient(90deg, rgba(74,222,128,0.07), transparent); }
|
||||
.third-row.cut td { border-top: 2px solid var(--turf-deep); }
|
||||
.qual-badge {
|
||||
font-family: var(--font-mono); font-size: 10px; padding: 2px 7px; border-radius: 999px;
|
||||
}
|
||||
.qual-badge.yes { background: rgba(74,222,128,0.16); color: var(--turf); }
|
||||
.qual-badge.no { background: rgba(95,109,146,0.16); color: var(--ink-faint); }
|
||||
|
||||
/* Drittplatzierte: Teamname grün, wenn alle 3 Gruppenspiele gespielt */
|
||||
.third-table td.team-complete { color: var(--turf); }
|
||||
|
||||
/* ---------- Bracket ---------- */
|
||||
.bracket-banner {
|
||||
display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
|
||||
background: var(--bg-card); border: 1px solid var(--line);
|
||||
border-radius: var(--radius); padding: 14px 16px; margin-bottom: 20px;
|
||||
}
|
||||
.bracket-banner .k {
|
||||
font-family: var(--font-mono); font-size: 12px; color: var(--ink-dim);
|
||||
}
|
||||
.bracket-banner .v { font-family: var(--font-mono); font-size: 12px; color: var(--turf); }
|
||||
.bracket-scroll {
|
||||
margin-left: -20px;
|
||||
margin-right: -20px;
|
||||
padding-left: 20px;
|
||||
padding-right: 20px;
|
||||
overflow-x: auto;
|
||||
overflow-y: visible;
|
||||
padding-bottom: 10px;
|
||||
scrollbar-gutter: stable;
|
||||
}
|
||||
.bracket {
|
||||
display: flex; gap: 26px; min-width: max-content; align-items: stretch;
|
||||
padding-bottom: 8px;
|
||||
}
|
||||
.round { display: flex; flex-direction: column; min-width: 220px; }
|
||||
.round-label {
|
||||
font-family: var(--font-display); font-weight: 800; text-transform: uppercase;
|
||||
font-size: 12px; letter-spacing: 0.06em; color: var(--ink-faint);
|
||||
margin-bottom: 10px; padding-left: 2px;
|
||||
}
|
||||
.round-matches { display: flex; flex-direction: column; justify-content: space-around; flex: 1; gap: 12px; }
|
||||
|
||||
.tie {
|
||||
background: var(--bg-card); border: 1px solid var(--line);
|
||||
border-radius: var(--radius-sm); position: relative;
|
||||
}
|
||||
.tie.final-tie { border-color: var(--gold); box-shadow: 0 0 0 1px rgba(255,210,74,0.2); }
|
||||
.tie-meta {
|
||||
font-family: var(--font-mono); font-size: 9px; color: rgba(255,255,255,0.55);
|
||||
letter-spacing: 0.04em; padding: 5px 10px 0;
|
||||
white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
|
||||
}
|
||||
.match-badge {
|
||||
position: absolute; top: -6px; right: -6px;
|
||||
font-family: var(--font-mono); font-size: 9px; font-weight: 700;
|
||||
line-height: 18px; min-width: 18px; text-align: center;
|
||||
border-radius: 999px; padding: 0 4px;
|
||||
background: #1a2744; color: #ffffff; border: 1px solid rgba(255,255,255,0.15);
|
||||
}
|
||||
.side {
|
||||
display: flex; align-items: center; justify-content: space-between;
|
||||
padding: 8px 10px; font-size: 13px;
|
||||
}
|
||||
.side + .side { border-top: 1px solid var(--line-soft); }
|
||||
.side .nm { display: flex; align-items: center; gap: 7px; min-width: 0; }
|
||||
.side .nm .c { font-family: var(--font-mono); font-size: 10px; color: var(--ink-faint); }
|
||||
.side .lbl { color: var(--ink-dim); font-style: italic; }
|
||||
.side .sc { font-family: var(--font-mono); font-weight: 700; color: var(--floodlight); }
|
||||
.side.win .sc { color: var(--turf); }
|
||||
.side .prob {
|
||||
font-family: var(--font-mono); font-size: 10px; color: var(--ink-faint);
|
||||
margin-left: 6px;
|
||||
}
|
||||
|
||||
.legend { display: flex; gap: 18px; flex-wrap: wrap; margin-top: 16px;
|
||||
font-family: var(--font-mono); font-size: 11px; color: var(--ink-faint); }
|
||||
.legend span { display: inline-flex; align-items: center; gap: 6px; }
|
||||
.legend i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
|
||||
|
||||
/* Tooltip im K.o.-Baum (position: fixed, damit overflow-x den Tooltip nicht abschneidet) */
|
||||
.kobaum-tip {
|
||||
position: fixed;
|
||||
z-index: 200;
|
||||
pointer-events: none;
|
||||
background: var(--bg-card);
|
||||
border: 1px solid var(--line);
|
||||
color: var(--ink);
|
||||
font-family: var(--font-mono);
|
||||
font-size: 12px;
|
||||
padding: 6px 9px;
|
||||
border-radius: var(--radius-sm);
|
||||
white-space: nowrap;
|
||||
box-shadow: 0 6px 20px rgba(0,0,0,0.4);
|
||||
}
|
||||
|
||||
/* ---------- Zustände ---------- */
|
||||
.notice {
|
||||
background: var(--bg-card); border: 1px solid var(--line);
|
||||
border-radius: var(--radius); padding: 18px 20px; color: var(--ink-dim);
|
||||
font-size: 14px;
|
||||
}
|
||||
.notice.err { border-color: #5a2230; color: #ffb0c0; }
|
||||
.skel { background: var(--bg-card); border: 1px solid var(--line);
|
||||
border-radius: var(--radius); height: 220px; animation: shimmer 1.4s infinite; }
|
||||
@keyframes shimmer { 50% { opacity: .55; } }
|
||||
|
||||
.foot {
|
||||
border-top: 1px solid var(--line); padding: 24px 0 48px;
|
||||
color: var(--ink-faint); font-size: 12px; font-family: var(--font-mono);
|
||||
}
|
||||
.foot a { color: var(--ink-dim); text-decoration: underline; text-underline-offset: 2px; }
|
||||
|
||||
/* =====================================================================
|
||||
MOBIL — Breakpoint 640px (iPhone ~375, Galaxy ~412, alle ≤640)
|
||||
===================================================================== */
|
||||
@media (max-width: 640px) {
|
||||
body { font-size: 14px; }
|
||||
.wrap { padding: 0 12px; }
|
||||
|
||||
/* ---------- mobil: Header ---------- */
|
||||
.masthead { padding: 0 12px; }
|
||||
.masthead-inner { padding: 10px 0; gap: 8px; }
|
||||
.brand { gap: 6px; }
|
||||
.brand-mark { font-size: 18px; }
|
||||
.brand-sub { font-size: 9px; letter-spacing: 0.04em; }
|
||||
.status-pill { font-size: 10px; padding: 4px 10px; gap: 5px; }
|
||||
.dot { width: 6px; height: 6px; }
|
||||
|
||||
/* ---------- mobil: Tabs (zwei Zeilen, kein horizontaler Scroll) ---------- */
|
||||
.masthead-tabs {
|
||||
flex-wrap: wrap;
|
||||
justify-content: center;
|
||||
gap: 2px 4px;
|
||||
}
|
||||
.tab { padding: 8px 13px; font-size: 12px; }
|
||||
|
||||
.section { padding: 18px 0 48px; }
|
||||
|
||||
/* ---------- mobil: Gruppen ---------- */
|
||||
.group-grid { grid-template-columns: 1fr; gap: 12px; }
|
||||
.group-head { padding: 10px 12px; }
|
||||
.group-name { font-size: 14px; }
|
||||
.standings th { font-size: 9px; padding: 6px 3px; }
|
||||
.standings th.team { padding-left: 10px; }
|
||||
.standings td { font-size: 11px; padding: 7px 3px; }
|
||||
.standings td.team { padding-left: 10px; gap: 6px; }
|
||||
.rankdot { width: 16px; height: 16px; font-size: 8px; }
|
||||
.team-name { font-size: 12px; }
|
||||
|
||||
/* ---------- mobil: Spiele (Fixtures) ---------- */
|
||||
.fx { grid-template-columns: 1fr; gap: 8px; padding: 10px 12px; }
|
||||
.fx-meta { flex-direction: row; gap: 14px; align-items: center; }
|
||||
.fx-status { order: -1; }
|
||||
.fx-teams { column-gap: 16px; }
|
||||
.fx-score { font-size: 16px; min-width: 44px; }
|
||||
.fx-vs { font-size: 14px; min-width: 44px; }
|
||||
.fx-name { font-size: 13px; max-width: 110px; }
|
||||
.grp-switch { gap: 8px; }
|
||||
.grp-chip { width: 40px; height: 40px; font-size: 14px; }
|
||||
|
||||
/* ---------- mobil: Drittplatzierte ---------- */
|
||||
.third-table th { font-size: 9px; padding: 8px 6px; }
|
||||
.third-table td { font-size: 11px; padding: 7px 6px; }
|
||||
|
||||
/* ---------- mobil: K.o.-Baum ---------- */
|
||||
.bracket-scroll {
|
||||
margin-left: -12px;
|
||||
margin-right: -12px;
|
||||
padding-left: 12px;
|
||||
padding-right: 12px;
|
||||
-webkit-overflow-scrolling: touch;
|
||||
}
|
||||
.bracket { gap: 18px; }
|
||||
.round { min-width: 170px; }
|
||||
.round-label { font-size: 10px; }
|
||||
.round-matches { gap: 8px; }
|
||||
.tie-meta { font-size: 8px; padding: 3px 8px 0; }
|
||||
.side { padding: 6px 8px; font-size: 11px; }
|
||||
.side .nm { gap: 5px; }
|
||||
.prov-mark { font-size: 10px; }
|
||||
.side .prob { font-size: 9px; }
|
||||
.bracket-banner { padding: 10px 12px; font-size: 13px; }
|
||||
.legend { font-size: 10px; gap: 12px; }
|
||||
|
||||
/* ---------- mobil: Simulation ---------- */
|
||||
.sim-row { flex-wrap: wrap; gap: 6px; padding: 8px 10px; }
|
||||
.sim-row-phase { min-width: 100%; font-size: 9px; }
|
||||
.sim-row-date { min-width: auto; font-size: 9px; }
|
||||
.sim-row input[type="number"] { width: 32px; height: 32px; font-size: 15px; }
|
||||
|
||||
/* ---------- mobil: Footer ---------- */
|
||||
.foot { font-size: 11px; padding: 16px 0 32px; }
|
||||
|
||||
/* Kein horizontaler Überlauf außer im Bracket */
|
||||
body { overflow-x: hidden; }
|
||||
.bracket-scroll { overflow-x: auto; }
|
||||
}
|
||||
|
||||
/* ============ Erweiterungen v2 ============ */
|
||||
|
||||
/* Flaggen / Wappen */
|
||||
.flag {
|
||||
border-radius: 50%; object-fit: cover; flex: none;
|
||||
background: var(--bg-raised); border: 1px solid var(--line-soft);
|
||||
}
|
||||
.flag-fallback {
|
||||
display: grid; place-items: center;
|
||||
font-family: var(--font-mono); font-size: 9px; color: var(--ink-faint);
|
||||
text-transform: uppercase;
|
||||
}
|
||||
|
||||
/* Gruppen-Header als Button */
|
||||
.group-head-btn {
|
||||
width: 100%; cursor: pointer; text-align: left;
|
||||
font: inherit; color: inherit;
|
||||
transition: background .15s;
|
||||
}
|
||||
.group-head-btn:hover { background: var(--bg-card); }
|
||||
.group-head-btn:hover .group-tag { color: var(--turf); }
|
||||
.group-head-btn:focus-visible { outline: 2px solid var(--turf); outline-offset: -2px; }
|
||||
|
||||
/* Gruppen-Wechsler im Spiele-Tab */
|
||||
.grp-switch { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 20px; }
|
||||
.grp-chip {
|
||||
width: 38px; height: 38px; border-radius: 8px;
|
||||
border: 1px solid var(--line); background: var(--bg-card);
|
||||
color: var(--ink-dim); font-family: var(--font-display); font-weight: 700;
|
||||
font-size: 14px; cursor: pointer; transition: all .15s;
|
||||
}
|
||||
.grp-chip:hover { border-color: var(--turf); color: var(--ink); }
|
||||
.grp-chip.active { background: var(--turf); color: var(--bg); border-color: var(--turf); }
|
||||
|
||||
/* Spiele-Karten */
|
||||
.fixtures { display: flex; flex-direction: column; gap: 10px; }
|
||||
.fx {
|
||||
background: var(--bg-card); border: 1px solid var(--line);
|
||||
border-radius: var(--radius); padding: 12px 16px;
|
||||
display: grid; grid-template-columns: 110px minmax(0, 560px) 1fr; gap: 14px; align-items: center;
|
||||
}
|
||||
.fx-live { border-color: rgba(255,61,127,0.4); }
|
||||
.fx-status {
|
||||
display: flex; align-items: center; gap: 7px;
|
||||
font-family: var(--font-mono); font-size: 12px; color: var(--ink-dim);
|
||||
}
|
||||
.fx-teams {
|
||||
display: grid;
|
||||
grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
|
||||
align-items: center; column-gap: 34px;
|
||||
}
|
||||
/* Beide Teams: Flagge links, Name daneben. Linkes Team rechtsbündig an den Score,
|
||||
rechtes Team linksbündig – so ist der Abstand zum Ergebnis beidseitig gleich. */
|
||||
.fx-team { display: flex; align-items: center; gap: 8px; min-width: 0; }
|
||||
.fx-team.home { justify-content: flex-end; }
|
||||
.fx-team.away { justify-content: flex-start; }
|
||||
.fx-team .fx-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
|
||||
.fx-team.win .fx-name { color: var(--turf); }
|
||||
.fx-score { font-family: var(--font-mono); font-weight: 700; font-size: 18px; color: var(--floodlight); white-space: nowrap; text-align: center; min-width: 54px; }
|
||||
.fx-score.score-live { color: var(--live); }
|
||||
.fx-vs { font-family: var(--font-mono); font-size: 15px; color: var(--ink-faint); text-align: center; min-width: 54px; }
|
||||
.fx-meta {
|
||||
display: flex; flex-direction: column; gap: 3px; align-items: flex-end;
|
||||
font-family: var(--font-mono); font-size: 11px; color: var(--ink-faint); white-space: nowrap;
|
||||
}
|
||||
/* Austragungsort heller hervorheben. */
|
||||
.fx-venue { color: var(--ink-dim); }
|
||||
|
||||
/* Live-Tabelle der Gruppe unterhalb der Spiele. */
|
||||
.fx-standings { margin-top: 22px; }
|
||||
.fx-standings-title {
|
||||
font-family: var(--font-display, var(--font-mono)); font-size: 13px; letter-spacing: 0.06em;
|
||||
text-transform: uppercase; color: var(--ink-dim); margin: 0 2px 10px;
|
||||
display: flex; align-items: center; gap: 10px;
|
||||
}
|
||||
.fx-standings-live {
|
||||
font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.04em;
|
||||
color: var(--live); font-weight: 700;
|
||||
animation: livepulse 1.6s ease-in-out infinite;
|
||||
}
|
||||
.fx-standings .standings { width: 100%; }
|
||||
/* Zeile eines Teams mit laufendem Spiel hervorheben. */
|
||||
.fx-standings .row-live { background: rgba(255, 61, 127, 0.07); }
|
||||
.fx-standings .row-live .team-name { color: var(--floodlight); }
|
||||
.row-live-dot {
|
||||
display: inline-block; width: 7px; height: 7px; border-radius: 50%;
|
||||
background: var(--live); margin-left: 8px; vertical-align: middle;
|
||||
animation: livepulse 1.6s ease-in-out infinite;
|
||||
}
|
||||
@keyframes livepulse {
|
||||
0%, 100% { opacity: 1; }
|
||||
50% { opacity: 0.35; }
|
||||
}
|
||||
|
||||
@media (max-width: 720px) {
|
||||
.fx { grid-template-columns: 1fr; gap: 8px; }
|
||||
.fx-meta { flex-direction: row; gap: 14px; align-items: center; }
|
||||
.fx-status { order: -1; }
|
||||
}
|
||||
|
||||
/* Bracket: Label-Header braucht kein Extra-Padding mehr (sitzt im Kasten) */
|
||||
.round-matches { padding-top: 0; }
|
||||
|
||||
/* Bracket: fix vs. vorläufig.
|
||||
.nm trägt die Standardfarbe; Team-Name liegt in .tn. */
|
||||
.side .nm .tn { color: var(--ink); }
|
||||
|
||||
/* vorläufig: gedimmt + kursiv + Marker */
|
||||
.side.prov .nm .tn { color: var(--ink-dim); font-style: italic; }
|
||||
.prov-mark {
|
||||
color: #f0a23a; font-family: var(--font-mono); font-weight: 700;
|
||||
font-size: 12px; margin-left: 2px;
|
||||
}
|
||||
|
||||
/* fix: echtes Team steht fest -> fett weiß + grüner Marker links */
|
||||
.side.fix .nm .tn { color: #ffffff; font-weight: 700; }
|
||||
.side.fix { box-shadow: inset 3px 0 0 var(--turf-deep); }
|
||||
|
||||
/* Sieger eines bereits gespielten Tie sticht zusätzlich grün hervor */
|
||||
.side.win .nm .tn { color: var(--turf); font-weight: 700; }
|
||||
.side.win { box-shadow: inset 3px 0 0 var(--turf); }
|
||||
|
||||
/* Legende-Marker */
|
||||
.legend i.leg-fix { background: var(--turf-deep); }
|
||||
.legend i.leg-prov {
|
||||
background: repeating-linear-gradient(45deg, #f0a23a, #f0a23a 3px, transparent 3px, transparent 6px);
|
||||
border: 1px solid #f0a23a;
|
||||
}
|
||||
36
app/[locale]/layout.tsx
Normal file
36
app/[locale]/layout.tsx
Normal file
@@ -0,0 +1,36 @@
|
||||
import type { Metadata } from "next";
|
||||
import Script from "next/script";
|
||||
import { Locale, getDictionary } from "@/lib/i18n";
|
||||
|
||||
export async function generateMetadata({ params }: { params: Promise<{ locale: string }> }): Promise<Metadata> {
|
||||
const { locale } = await params;
|
||||
const dict = getDictionary(locale as Locale);
|
||||
return {
|
||||
title: dict.meta.title,
|
||||
description: dict.meta.description,
|
||||
};
|
||||
}
|
||||
|
||||
export async function generateStaticParams() {
|
||||
return [{ locale: "en" }, { locale: "de" }];
|
||||
}
|
||||
|
||||
export default function LocaleLayout({
|
||||
children,
|
||||
}: {
|
||||
children: React.ReactNode;
|
||||
}) {
|
||||
return (
|
||||
<>
|
||||
{children}
|
||||
{process.env.NEXT_PUBLIC_UMAMI_SRC && process.env.NEXT_PUBLIC_UMAMI_ID && (
|
||||
<Script
|
||||
defer
|
||||
src={process.env.NEXT_PUBLIC_UMAMI_SRC}
|
||||
data-website-id={process.env.NEXT_PUBLIC_UMAMI_ID}
|
||||
strategy="afterInteractive"
|
||||
/>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -1,13 +1,15 @@
|
||||
"use client";
|
||||
|
||||
import { useEffect, useState, useCallback } from "react";
|
||||
import { useEffect, useState, useCallback, useMemo, use } from "react";
|
||||
import { GroupId, GroupTable, Match, Team, ThirdPlaceRow } from "@/lib/types";
|
||||
import { ThirdAssignment } from "@/lib/bracket";
|
||||
import { getDictionary, Locale, Dictionary } from "@/lib/i18n";
|
||||
import Groups from "./components/Groups";
|
||||
import ThirdPlace from "./components/ThirdPlace";
|
||||
import Bracket from "./components/Bracket";
|
||||
import Fixtures from "./components/Fixtures";
|
||||
import Simulation from "./components/Simulation";
|
||||
import KoFixtures from "./components/KoFixtures";
|
||||
|
||||
interface ApiData {
|
||||
updatedAt: string;
|
||||
@@ -16,22 +18,25 @@ interface ApiData {
|
||||
groupTables: GroupTable[];
|
||||
groupTablesLive: GroupTable[];
|
||||
thirdTable: ThirdPlaceRow[];
|
||||
secureThirdTeams: string[];
|
||||
annexAssignment: ThirdAssignment | null;
|
||||
annexResolved: boolean;
|
||||
}
|
||||
|
||||
type Tab = "groups" | "fixtures" | "thirds" | "bracket" | "sim";
|
||||
type Tab = "groups" | "groupfixtures" | "kofixtures" | "thirds" | "bracket" | "sim";
|
||||
|
||||
export default function Home() {
|
||||
export default function Home({ params }: { params: Promise<{ locale: string }> }) {
|
||||
const { locale } = use(params) as { locale: Locale };
|
||||
const dict = useMemo(() => getDictionary(locale), [locale]);
|
||||
const [data, setData] = useState<ApiData | null>(null);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
const [tab, setTab] = useState<Tab>("groups");
|
||||
const [tab, setTab] = useState<Tab>("kofixtures");
|
||||
// Zuletzt gewählte Gruppe für den Spiele-Tab. null = noch keine gewählt.
|
||||
const [fixturesGroup, setFixturesGroup] = useState<GroupId | null>(null);
|
||||
|
||||
const load = useCallback(async () => {
|
||||
try {
|
||||
const res = await fetch("/api/matches", { cache: "no-store" });
|
||||
const res = await fetch(`/api/matches?locale=${locale}`, { cache: "no-store" });
|
||||
if (!res.ok) {
|
||||
const body = await res.json().catch(() => ({}));
|
||||
throw new Error(body.detail || `Fehler ${res.status}`);
|
||||
@@ -41,7 +46,7 @@ export default function Home() {
|
||||
} catch (e) {
|
||||
setError(e instanceof Error ? e.message : "Verbindung fehlgeschlagen");
|
||||
}
|
||||
}, []);
|
||||
}, [locale]);
|
||||
|
||||
useEffect(() => {
|
||||
load();
|
||||
@@ -52,7 +57,7 @@ export default function Home() {
|
||||
// Klick auf einen Gruppen-Header: Gruppe merken und zum Spiele-Tab wechseln.
|
||||
const openGroupFixtures = useCallback((g: GroupId) => {
|
||||
setFixturesGroup(g);
|
||||
setTab("fixtures");
|
||||
setTab("groupfixtures");
|
||||
}, []);
|
||||
|
||||
const anyLive = data?.matches.some(
|
||||
@@ -65,34 +70,37 @@ export default function Home() {
|
||||
<div className="wrap masthead-inner">
|
||||
<div className="brand">
|
||||
<span className="brand-mark">WM <span className="accent">26</span></span>
|
||||
<span className="brand-sub">USA · Kanada · Mexiko</span>
|
||||
<span className="brand-sub">{dict.header.hostCountries}</span>
|
||||
</div>
|
||||
<span className="status-pill">
|
||||
<span className={`dot ${anyLive ? "live" : data ? "on" : ""}`} />
|
||||
{error
|
||||
? "Feed offline"
|
||||
? dict.status.feedOffline
|
||||
: data
|
||||
? anyLive ? "Live" : `Aktualisiert ${new Date(data.updatedAt).toLocaleTimeString("de-DE")}`
|
||||
: "Lade Daten…"}
|
||||
? anyLive ? dict.status.live : dict.status.updated(new Date(data.updatedAt).toLocaleTimeString(locale === "en" ? "en-US" : "de-DE"))
|
||||
: dict.status.loading}
|
||||
</span>
|
||||
<nav className="tabs masthead-tabs">
|
||||
<button className={`tab ${tab === "kofixtures" ? "active" : ""}`} onClick={() => setTab("kofixtures")}>
|
||||
{dict.nav.koFixtures}
|
||||
</button>
|
||||
<button className={`tab ${tab === "groups" ? "active" : ""}`} onClick={() => setTab("groups")}>
|
||||
Gruppen
|
||||
{dict.nav.groups}
|
||||
</button>
|
||||
<button
|
||||
className={`tab ${tab === "fixtures" ? "active" : ""}`}
|
||||
onClick={() => { if (!fixturesGroup) setFixturesGroup("A"); setTab("fixtures"); }}
|
||||
className={`tab ${tab === "groupfixtures" ? "active" : ""}`}
|
||||
onClick={() => { if (!fixturesGroup) setFixturesGroup("A"); setTab("groupfixtures"); }}
|
||||
>
|
||||
{fixturesGroup ? `Spiele – Gruppe ${fixturesGroup}` : "Spiele"}
|
||||
{fixturesGroup ? dict.nav.groupFixtures(fixturesGroup) : dict.nav.groupFixturesNoGroup}
|
||||
</button>
|
||||
<button className={`tab ${tab === "thirds" ? "active" : ""}`} onClick={() => setTab("thirds")}>
|
||||
Drittplatzierte
|
||||
{dict.nav.thirdPlace}
|
||||
</button>
|
||||
<button className={`tab ${tab === "bracket" ? "active" : ""}`} onClick={() => setTab("bracket")}>
|
||||
K.o.-Baum
|
||||
{dict.nav.bracket}
|
||||
</button>
|
||||
<button className={`tab ${tab === "sim" ? "active" : ""}`} onClick={() => setTab("sim")}>
|
||||
Simulation
|
||||
{dict.nav.simulation}
|
||||
</button>
|
||||
</nav>
|
||||
</div>
|
||||
@@ -103,9 +111,7 @@ export default function Home() {
|
||||
<section className="section">
|
||||
{error && (
|
||||
<div className="notice err">
|
||||
Die Live-Feeds sind gerade nicht erreichbar: {error}.
|
||||
Prüfe den <code>FOOTBALL_DATA_TOKEN</code> und die Netzwerkfreigabe des Servers.
|
||||
Die Seite versucht es automatisch erneut.
|
||||
{dict.error.feedUnreachable}
|
||||
</div>
|
||||
)}
|
||||
|
||||
@@ -115,38 +121,76 @@ export default function Home() {
|
||||
</div>
|
||||
)}
|
||||
|
||||
{data && tab === "kofixtures" && (
|
||||
<KoFixtures teams={data.teams} matches={data.matches} dict={dict} locale={locale} />
|
||||
)}
|
||||
{data && tab === "groups" && (
|
||||
<Groups
|
||||
tables={data.groupTablesLive} teams={data.teams} matches={data.matches}
|
||||
onOpenGroup={openGroupFixtures}
|
||||
onOpenGroup={openGroupFixtures} dict={dict} locale={locale}
|
||||
/>
|
||||
)}
|
||||
{data && tab === "fixtures" && fixturesGroup && (
|
||||
{data && tab === "groupfixtures" && fixturesGroup && (
|
||||
<Fixtures
|
||||
group={fixturesGroup} teams={data.teams} matches={data.matches}
|
||||
onSelectGroup={setFixturesGroup}
|
||||
onSelectGroup={setFixturesGroup} dict={dict} locale={locale}
|
||||
/>
|
||||
)}
|
||||
{data && tab === "thirds" && (
|
||||
<ThirdPlace rows={data.thirdTable} teams={data.teams} />
|
||||
<ThirdPlace rows={data.thirdTable} teams={data.teams} secureTeams={data.secureThirdTeams} dict={dict} />
|
||||
)}
|
||||
{data && tab === "bracket" && (
|
||||
<Bracket
|
||||
matches={data.matches} teams={data.teams} tables={data.groupTablesLive}
|
||||
thirds={data.thirdTable} assignment={data.annexAssignment}
|
||||
annexResolved={data.annexResolved}
|
||||
annexResolved={data.annexResolved} dict={dict} locale={locale}
|
||||
/>
|
||||
)}
|
||||
{data && tab === "sim" && (
|
||||
<Simulation teams={data.teams} matches={data.matches} />
|
||||
<Simulation teams={data.teams} matches={data.matches} dict={dict} locale={locale} />
|
||||
)}
|
||||
</section>
|
||||
</main>
|
||||
|
||||
<footer className="foot">
|
||||
<div className="wrap">
|
||||
Daten: football-data.org (Spiele & Tabellen) · Polymarket Gamma API (Wahrscheinlichkeiten) ·
|
||||
Annex-C-Zuordnung nach den FIFA-Wettbewerbsregeln WM 2026. Kein offizielles FIFA-Produkt.
|
||||
<footer style={{
|
||||
borderTop: "1px solid var(--line-soft)",
|
||||
padding: "24px 0",
|
||||
marginTop: 40,
|
||||
}}>
|
||||
<div className="wrap" style={{
|
||||
display: "flex", flexDirection: "column", alignItems: "center", gap: 8,
|
||||
}}>
|
||||
<div style={{
|
||||
display: "flex", alignItems: "center", gap: 12,
|
||||
}}>
|
||||
<span style={{
|
||||
display: "inline-flex", alignItems: "center", justifyContent: "center",
|
||||
width: 28, height: 28,
|
||||
fontFamily: "var(--font-display)", fontSize: 13, fontWeight: 700,
|
||||
color: "var(--ink-dim)", background: "var(--bg-card)",
|
||||
border: "1px solid var(--line-soft)", borderRadius: "var(--radius-sm)",
|
||||
}}>
|
||||
AK
|
||||
</span>
|
||||
<a href="#" style={{
|
||||
fontFamily: "var(--font-mono)", fontSize: 12,
|
||||
color: "var(--ink-faint)", textDecoration: "none",
|
||||
}}>
|
||||
Andreas Knuth
|
||||
</a>
|
||||
</div>
|
||||
<span style={{
|
||||
fontFamily: "var(--font-mono)", fontSize: 10,
|
||||
color: "var(--ink-faint)",
|
||||
}}>
|
||||
{dict.footer.dashboard}
|
||||
</span>
|
||||
<span style={{
|
||||
fontFamily: "var(--font-mono)", fontSize: 9,
|
||||
color: "var(--ink-faint)", opacity: 0.5, marginTop: 8,
|
||||
}}>
|
||||
{dict.footer.dataSources}
|
||||
</span>
|
||||
</div>
|
||||
</footer>
|
||||
</>
|
||||
@@ -1,35 +1,60 @@
|
||||
import { NextResponse } from "next/server";
|
||||
import { fetchMatchesAndTeams, fetchOdds, attachOdds } from "@/lib/feeds";
|
||||
import type { NextRequest } from "next/server";
|
||||
import { fetchMatchesAndTeams, fetchOdds, attachOdds, attachKOOdds, fetchFifaScores, applyFifaScores, assignKONumbersBySlots, attachFifaGoals } from "@/lib/feeds";
|
||||
import { computeGroupTables, computeThirdPlaceTable } from "@/lib/standings";
|
||||
import { qualifiedThirdGroups, resolveAnnexC } from "@/lib/bracket";
|
||||
import { securelyQualifiedThirdTeams } from "@/lib/third-place-security";
|
||||
|
||||
// Diese Route wird vom Frontend gepollt. Sie ist der einzige Ort, der die
|
||||
// Upstream-Feeds berührt — gecacht, damit Rate Limits eingehalten werden.
|
||||
export const dynamic = "force-dynamic";
|
||||
|
||||
export async function GET() {
|
||||
export async function GET(request: NextRequest) {
|
||||
const locale = request.nextUrl.searchParams.get("locale") || "de";
|
||||
try {
|
||||
const { matches: rawMatches, teams } = await fetchMatchesAndTeams();
|
||||
|
||||
// Odds sind optional: fällt der Polymarket-Call aus, liefern wir trotzdem.
|
||||
let matches = rawMatches;
|
||||
let odds: Awaited<ReturnType<typeof fetchOdds>> | null = null;
|
||||
try {
|
||||
const odds = await fetchOdds();
|
||||
odds = await fetchOdds();
|
||||
matches = attachOdds(rawMatches, teams, odds);
|
||||
} catch (err) {
|
||||
console.error("[polymarket] fetchOdds fehlgeschlagen:", err);
|
||||
}
|
||||
|
||||
// FIFA-Live-Scores (additiv, Fallback auf football-data)
|
||||
assignKONumbersBySlots(matches, teams);
|
||||
|
||||
if (odds) {
|
||||
matches = attachKOOdds(matches, teams, odds);
|
||||
}
|
||||
|
||||
try {
|
||||
const fifaData = await fetchFifaScores(locale);
|
||||
matches = applyFifaScores(matches, teams, fifaData);
|
||||
try {
|
||||
matches = await attachFifaGoals(matches, fifaData, locale);
|
||||
} catch (err) {
|
||||
console.warn("[fifa] Goals fehlgeschlagen:", err instanceof Error ? err.message : err);
|
||||
}
|
||||
} catch (err) {
|
||||
console.warn("[fifa] Scores fehlgeschlagen:", err instanceof Error ? err.message : err);
|
||||
}
|
||||
|
||||
const groupTables = computeGroupTables(teams, matches);
|
||||
const groupTablesLive = computeGroupTables(teams, matches, true);
|
||||
|
||||
// prob-Feld normalisieren: immer null statt undefined, damit JSON konsistent ist
|
||||
const normalizedMatches = matches.map((m) => ({ ...m, prob: m.prob ?? null }));
|
||||
|
||||
const thirdTable = computeThirdPlaceTable(groupTablesLive);
|
||||
const qGroups = qualifiedThirdGroups(thirdTable);
|
||||
const annex = qGroups.length === 8 ? resolveAnnexC(qGroups) : null;
|
||||
|
||||
// Sichere Drittplatzierte (Team-IDs, deren Top-8-Platz mathematisch feststeht)
|
||||
const secureThirdTeams = securelyQualifiedThirdTeams(matches, teams);
|
||||
|
||||
return NextResponse.json({
|
||||
updatedAt: new Date().toISOString(),
|
||||
teams,
|
||||
@@ -37,6 +62,7 @@ export async function GET() {
|
||||
groupTables,
|
||||
groupTablesLive,
|
||||
thirdTable,
|
||||
secureThirdTeams: [...secureThirdTeams],
|
||||
annexAssignment: annex,
|
||||
annexResolved: annex != null,
|
||||
});
|
||||
|
||||
@@ -1,350 +0,0 @@
|
||||
"use client";
|
||||
|
||||
import { useState, useMemo, useCallback, useEffect } from "react";
|
||||
import { Match, Team } from "@/lib/types";
|
||||
import { computeGroupTables, computeThirdPlaceTable } from "@/lib/standings";
|
||||
import { qualifiedThirdGroups, resolveAnnexC, LATER_ROUNDS } from "@/lib/bracket";
|
||||
import { resolveBracket, ResolvedTie } from "@/lib/resolve-bracket";
|
||||
import {
|
||||
loadOverrides, saveOverrides, buildSimMatches,
|
||||
defaultScore, SimOverrides,
|
||||
} from "@/lib/simulation";
|
||||
import Bracket from "./Bracket";
|
||||
import ThirdPlace from "./ThirdPlace";
|
||||
import Flag from "./Flag";
|
||||
|
||||
function teamById(teams: Team[], id: string | null) {
|
||||
return id ? teams.find((t) => t.id === id) : undefined;
|
||||
}
|
||||
|
||||
function fmtDate(iso: string): string {
|
||||
const d = new Date(iso);
|
||||
return d.toLocaleString("de-DE", {
|
||||
weekday: "short", day: "2-digit", month: "2-digit",
|
||||
hour: "2-digit", minute: "2-digit",
|
||||
});
|
||||
}
|
||||
|
||||
// Label für die Spielphase in der Liste
|
||||
function phaseLabel(match: Match): string {
|
||||
if (match.stage === "GROUP" && match.group) return `Gruppe ${match.group}`;
|
||||
if (match.stage === "R32") return "Sechzehntelfinale";
|
||||
if (match.stage === "R16") return "Achtelfinale";
|
||||
if (match.stage === "QF") return "Viertelfinale";
|
||||
if (match.stage === "SF") return "Halbfinale";
|
||||
if (match.stage === "3RD") return "Spiel um Platz 3";
|
||||
if (match.stage === "FINAL") return "Finale";
|
||||
return match.stage;
|
||||
}
|
||||
|
||||
export default function Simulation({ teams, matches }: { teams: Team[]; matches: Match[] }) {
|
||||
const [overrides, setOverrides] = useState<SimOverrides>({});
|
||||
|
||||
useEffect(() => {
|
||||
setOverrides(loadOverrides());
|
||||
}, []);
|
||||
|
||||
const handleScore = useCallback((matchId: string, homeScore: number, awayScore: number) => {
|
||||
setOverrides((prev) => {
|
||||
const next = { ...prev, [matchId]: { homeScore, awayScore } };
|
||||
saveOverrides(next);
|
||||
return next;
|
||||
});
|
||||
}, []);
|
||||
|
||||
const handleReset = useCallback(() => {
|
||||
setOverrides({});
|
||||
saveOverrides({});
|
||||
}, []);
|
||||
|
||||
const handleClear = useCallback((matchId: string) => {
|
||||
setOverrides((prev) => {
|
||||
const next = { ...prev };
|
||||
delete next[matchId];
|
||||
saveOverrides(next);
|
||||
return next;
|
||||
});
|
||||
}, []);
|
||||
|
||||
// ---- Simulations-Pipeline ----
|
||||
const simMatches = useMemo(() => buildSimMatches(matches, overrides), [matches, overrides]);
|
||||
const simTables = useMemo(() => computeGroupTables(teams, simMatches), [teams, simMatches]);
|
||||
const simThirds = useMemo(() => computeThirdPlaceTable(simTables), [simTables]);
|
||||
const simQGroups = useMemo(() => qualifiedThirdGroups(simThirds), [simThirds]);
|
||||
const simAnnex = useMemo(
|
||||
() => (simQGroups.length === 8 ? resolveAnnexC(simQGroups) : null),
|
||||
[simQGroups],
|
||||
);
|
||||
const simAnnexResolved = simAnnex != null;
|
||||
|
||||
const simBracket = useMemo(
|
||||
() => resolveBracket(simMatches, teams, simTables, simThirds, simAnnex, simAnnexResolved, true),
|
||||
[simMatches, teams, simTables, simThirds, simAnnex, simAnnexResolved],
|
||||
);
|
||||
|
||||
// Echte Tabellen/Bracket für fix/provisional-Flags (nur tatsächlich FINISHED).
|
||||
const realTables = useMemo(() => computeGroupTables(teams, matches), [teams, matches]);
|
||||
const realThirds = useMemo(() => computeThirdPlaceTable(realTables), [realTables]);
|
||||
const realQGroups = useMemo(() => qualifiedThirdGroups(realThirds), [realThirds]);
|
||||
const realAnnex = useMemo(
|
||||
() => (realQGroups.length === 8 ? resolveAnnexC(realQGroups) : null),
|
||||
[realQGroups],
|
||||
);
|
||||
const realBracket = useMemo(
|
||||
() => resolveBracket(matches, teams, realTables, realThirds, realAnnex, realAnnex != null),
|
||||
[matches, teams, realTables, realThirds, realAnnex],
|
||||
);
|
||||
|
||||
// R32: provisional-Flags aus dem echten Bracket übernehmen.
|
||||
const realProvisional = useMemo(() => {
|
||||
const m = new Map<number, { home: boolean; away: boolean }>();
|
||||
for (const tie of realBracket.r32) {
|
||||
m.set(tie.matchNumber, { home: tie.home.provisional, away: tie.away.provisional });
|
||||
}
|
||||
return m;
|
||||
}, [realBracket]);
|
||||
|
||||
// Folgerunden: decided-Flags aus echten Matches (status === FINISHED).
|
||||
const realDecided = useMemo(() => {
|
||||
const m = new Map<number, boolean>();
|
||||
for (const mt of matches) {
|
||||
if (mt.group == null && mt.matchNumber >= 73) {
|
||||
m.set(mt.matchNumber, mt.status === "FINISHED");
|
||||
}
|
||||
}
|
||||
return m;
|
||||
}, [matches]);
|
||||
|
||||
// Sim-Bracket mit echten provisional-Flags mergen (inkl. Tooltip-Korrektur).
|
||||
const preResolved = useMemo(() => {
|
||||
const fixTooltip = (t: string | null, prov: boolean): string | null => {
|
||||
if (!t) return t;
|
||||
if (prov) return t.startsWith("aktuell ") ? t : `aktuell ${t}`;
|
||||
return t.startsWith("aktuell ") ? t.slice(8) : t;
|
||||
};
|
||||
|
||||
const r32Fixed: ResolvedTie[] = simBracket.r32.map((tie) => {
|
||||
const rp = realProvisional.get(tie.matchNumber);
|
||||
if (!rp) return tie;
|
||||
return {
|
||||
...tie,
|
||||
home: { ...tie.home, provisional: rp.home, tooltip: fixTooltip(tie.home.tooltip, rp.home) },
|
||||
away: { ...tie.away, provisional: rp.away, tooltip: fixTooltip(tie.away.tooltip, rp.away) },
|
||||
};
|
||||
});
|
||||
|
||||
const laterFixed: Record<number, ResolvedTie> = {};
|
||||
for (const km of LATER_ROUNDS) {
|
||||
const tie = simBracket.later[km.matchNumber];
|
||||
if (!tie) continue;
|
||||
const homeProv = !(realDecided.get(km.fromHome) ?? false);
|
||||
const awayProv = !(realDecided.get(km.fromAway) ?? false);
|
||||
laterFixed[km.matchNumber] = {
|
||||
...tie,
|
||||
home: { ...tie.home, provisional: homeProv },
|
||||
away: { ...tie.away, provisional: awayProv },
|
||||
};
|
||||
}
|
||||
|
||||
return { r32: r32Fixed, later: laterFixed };
|
||||
}, [simBracket, realProvisional, realDecided]);
|
||||
|
||||
// ---- Eingabeliste: offene Spiele aus dem echten Feed ----
|
||||
const openMatches = useMemo(
|
||||
() =>
|
||||
matches
|
||||
.filter((m) => m.status !== "FINISHED")
|
||||
.sort((a, b) => +new Date(a.utcDate) - +new Date(b.utcDate)),
|
||||
[matches],
|
||||
);
|
||||
|
||||
const groupPhase = openMatches.filter((m) => m.stage === "GROUP");
|
||||
const koPhase = openMatches.filter((m) => m.stage !== "GROUP");
|
||||
|
||||
// KO-Eingaben erst freigeben, wenn alle Gruppenspiele beendet sind.
|
||||
const groupPhaseComplete = matches
|
||||
.filter((m) => m.group != null)
|
||||
.every((m) => m.status === "FINISHED");
|
||||
|
||||
const hasChanges = Object.keys(overrides).length > 0;
|
||||
|
||||
return (
|
||||
<div>
|
||||
<div className="notice" style={{ marginBottom: 20 }}>
|
||||
Simulation — Ergebnisse frei wählbar, beeinflusst nicht die echten Daten.
|
||||
Alle ungespielten Spiele sind vorbelegt mit dem Polymarket-Favoriten.
|
||||
Eingaben werden im Browser gespeichert.
|
||||
</div>
|
||||
|
||||
{/* ---- Eingabeliste ---- */}
|
||||
<div style={{ marginBottom: 28 }}>
|
||||
<div style={{ display: "flex", alignItems: "center", justifyContent: "space-between", marginBottom: 14 }}>
|
||||
<h3 style={{ fontFamily: "var(--font-display)", fontSize: 15, textTransform: "uppercase", letterSpacing: "0.06em", color: "var(--ink-dim)", margin: 0 }}>
|
||||
Offene Spiele ({openMatches.length})
|
||||
</h3>
|
||||
{hasChanges && (
|
||||
<button
|
||||
onClick={handleReset}
|
||||
style={{
|
||||
fontFamily: "var(--font-mono)", fontSize: 11,
|
||||
color: "var(--ink-faint)", background: "var(--bg-card)",
|
||||
border: "1px solid var(--line)", borderRadius: "var(--radius-sm)",
|
||||
padding: "5px 12px", cursor: "pointer",
|
||||
}}
|
||||
>
|
||||
Auf Polymarket-Defaults zurücksetzen
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{groupPhase.length > 0 && (
|
||||
<div style={{ marginBottom: 16 }}>
|
||||
<div style={{ fontFamily: "var(--font-display)", fontSize: 12, textTransform: "uppercase", letterSpacing: "0.06em", color: "var(--ink-faint)", marginBottom: 8 }}>
|
||||
Gruppenphase
|
||||
</div>
|
||||
<div style={{ display: "flex", flexDirection: "column", gap: 4 }}>
|
||||
{groupPhase.map((m) => (
|
||||
<SimRow key={m.id} match={m} teams={teams} overrides={overrides} onScore={handleScore} onClear={handleClear} />
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{koPhase.length > 0 && (
|
||||
<div>
|
||||
<div style={{ fontFamily: "var(--font-display)", fontSize: 12, textTransform: "uppercase", letterSpacing: "0.06em", color: "var(--ink-faint)", marginBottom: 8 }}>
|
||||
K.o.-Phase
|
||||
</div>
|
||||
{groupPhaseComplete ? (
|
||||
<div style={{ display: "flex", flexDirection: "column", gap: 4 }}>
|
||||
{koPhase.map((m) => (
|
||||
<SimRow key={m.id} match={m} teams={teams} overrides={overrides} onScore={handleScore} onClear={handleClear} />
|
||||
))}
|
||||
</div>
|
||||
) : (
|
||||
<div className="notice" style={{ fontSize: 13 }}>
|
||||
K.o.-Spiele werden zur Eingabe freigegeben, sobald die Gruppenphase abgeschlossen ist.
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* ---- Drittplatzierte (simuliert) ---- */}
|
||||
<h3 style={{ fontFamily: "var(--font-display)", fontSize: 15, textTransform: "uppercase", letterSpacing: "0.06em", color: "var(--ink-dim)", margin: "0 0 12px" }}>
|
||||
Drittplatzierte (simuliert)
|
||||
</h3>
|
||||
<ThirdPlace rows={simThirds} teams={teams} />
|
||||
|
||||
{/* ---- Simulierter K.o.-Baum ---- */}
|
||||
<h3 style={{ fontFamily: "var(--font-display)", fontSize: 15, textTransform: "uppercase", letterSpacing: "0.06em", color: "var(--ink-dim)", margin: "28px 0 12px" }}>
|
||||
Simulierter K.o.-Baum
|
||||
</h3>
|
||||
<Bracket
|
||||
matches={simMatches}
|
||||
teams={teams}
|
||||
tables={simTables}
|
||||
thirds={simThirds}
|
||||
assignment={simAnnex}
|
||||
annexResolved={simAnnexResolved}
|
||||
preResolved={preResolved}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
// ---- Einzelne Eingabezeile ----
|
||||
function SimRow({
|
||||
match, teams, overrides, onScore, onClear,
|
||||
}: {
|
||||
match: Match; teams: Team[]; overrides: SimOverrides; onScore: (id: string, h: number, a: number) => void;
|
||||
onClear: (id: string) => void;
|
||||
}) {
|
||||
const home = teamById(teams, match.homeTeamId);
|
||||
const away = teamById(teams, match.awayTeamId);
|
||||
const def = defaultScore(match);
|
||||
const ov = overrides[match.id];
|
||||
const homeVal = ov?.homeScore ?? def?.homeScore;
|
||||
const awayVal = ov?.awayScore ?? def?.awayScore;
|
||||
const homeChanged = ov != null;
|
||||
const isKO = match.stage !== "GROUP";
|
||||
|
||||
const inputStyle = (changed: boolean): React.CSSProperties => ({
|
||||
width: 36,
|
||||
height: 28,
|
||||
textAlign: "center",
|
||||
fontFamily: "var(--font-mono)",
|
||||
fontSize: 14,
|
||||
fontWeight: 700,
|
||||
color: changed ? "var(--turf)" : "var(--ink)",
|
||||
background: "var(--bg-raised)",
|
||||
border: `1px solid ${changed ? "var(--turf)" : "var(--line)"}`,
|
||||
borderRadius: "var(--radius-sm)",
|
||||
outline: "none",
|
||||
MozAppearance: "textfield",
|
||||
});
|
||||
|
||||
return (
|
||||
<div className="sim-row" style={{
|
||||
display: "flex", alignItems: "center", gap: 10,
|
||||
padding: "6px 12px",
|
||||
background: "var(--bg-card)", border: "1px solid var(--line-soft)",
|
||||
borderRadius: "var(--radius-sm)",
|
||||
fontSize: 13,
|
||||
}}>
|
||||
<span className="sim-row-phase" style={{ fontFamily: "var(--font-mono)", fontSize: 10, color: "var(--ink-faint)", minWidth: 75 }}>
|
||||
{phaseLabel(match)}
|
||||
</span>
|
||||
<span style={{ display: "flex", alignItems: "center", gap: 6, minWidth: 0, flex: 1, justifyContent: "flex-end" }}>
|
||||
<Flag team={home} size={18} />
|
||||
<span style={{ fontWeight: 600, whiteSpace: "nowrap", overflow: "hidden", textOverflow: "ellipsis", maxWidth: 140 }}>
|
||||
{home?.localisedName ?? home?.name ?? "—"}
|
||||
</span>
|
||||
</span>
|
||||
<input
|
||||
type="number"
|
||||
min={0}
|
||||
style={inputStyle(homeChanged)}
|
||||
value={homeVal ?? ""}
|
||||
placeholder="–"
|
||||
onChange={(e) => {
|
||||
const v = parseInt(e.target.value, 10);
|
||||
if (!isNaN(v) && v >= 0) {
|
||||
onScore(match.id, v, awayVal ?? (isKO ? 0 : 1));
|
||||
} else if (e.target.value === "") {
|
||||
// Bei Leerung: Standard wiederherstellen
|
||||
const fallback = def;
|
||||
if (fallback) onScore(match.id, fallback.homeScore, fallback.awayScore);
|
||||
}
|
||||
}}
|
||||
/>
|
||||
<span style={{ fontFamily: "var(--font-mono)", fontWeight: 700, color: "var(--ink-faint)" }}>:</span>
|
||||
<input
|
||||
type="number"
|
||||
min={0}
|
||||
style={inputStyle(homeChanged)}
|
||||
value={awayVal ?? ""}
|
||||
placeholder="–"
|
||||
onChange={(e) => {
|
||||
const v = parseInt(e.target.value, 10);
|
||||
if (!isNaN(v) && v >= 0) {
|
||||
onScore(match.id, homeVal ?? (isKO ? 0 : 1), v);
|
||||
} else if (e.target.value === "") {
|
||||
const fallback = def;
|
||||
if (fallback) onScore(match.id, fallback.homeScore, fallback.awayScore);
|
||||
else onClear(match.id);
|
||||
}
|
||||
}}
|
||||
/>
|
||||
<span style={{ display: "flex", alignItems: "center", gap: 6, minWidth: 0, flex: 1 }}>
|
||||
<span style={{ fontWeight: 600, whiteSpace: "nowrap", overflow: "hidden", textOverflow: "ellipsis", maxWidth: 140 }}>
|
||||
{away?.localisedName ?? away?.name ?? "—"}
|
||||
</span>
|
||||
<Flag team={away} size={18} />
|
||||
</span>
|
||||
<span className="sim-row-date" style={{ fontFamily: "var(--font-mono)", fontSize: 10, color: "var(--ink-faint)", minWidth: 100, textAlign: "right" }}>
|
||||
{fmtDate(match.utcDate)}
|
||||
</span>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -47,7 +47,7 @@ body {
|
||||
|
||||
a { color: inherit; text-decoration: none; }
|
||||
|
||||
.wrap { max-width: 1240px; margin: 0 auto; padding: 0 20px; }
|
||||
.wrap { max-width: 1240px; margin: 0 auto; padding: 0 20px 0 0; }
|
||||
|
||||
/* ---------- Header / Hero ---------- */
|
||||
.masthead {
|
||||
@@ -180,6 +180,9 @@ table.standings { width: 100%; border-collapse: collapse; }
|
||||
.qual-badge.yes { background: rgba(74,222,128,0.16); color: var(--turf); }
|
||||
.qual-badge.no { background: rgba(95,109,146,0.16); color: var(--ink-faint); }
|
||||
|
||||
/* Drittplatzierte: Teamname grün, wenn alle 3 Gruppenspiele gespielt */
|
||||
.third-table td.team-complete { color: var(--turf); }
|
||||
|
||||
/* ---------- Bracket ---------- */
|
||||
.bracket-banner {
|
||||
display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
|
||||
@@ -217,9 +220,17 @@ table.standings { width: 100%; border-collapse: collapse; }
|
||||
border-radius: var(--radius-sm); position: relative;
|
||||
}
|
||||
.tie.final-tie { border-color: var(--gold); box-shadow: 0 0 0 1px rgba(255,210,74,0.2); }
|
||||
.tie-head {
|
||||
font-family: var(--font-mono); font-size: 9px; color: var(--ink-faint);
|
||||
.tie-meta {
|
||||
font-family: var(--font-mono); font-size: 9px; color: rgba(255,255,255,0.55);
|
||||
letter-spacing: 0.04em; padding: 5px 10px 0;
|
||||
white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
|
||||
}
|
||||
.match-badge {
|
||||
position: absolute; top: -6px; right: -6px;
|
||||
font-family: var(--font-mono); font-size: 9px; font-weight: 700;
|
||||
line-height: 18px; min-width: 18px; text-align: center;
|
||||
border-radius: 999px; padding: 0 4px;
|
||||
background: #1a2744; color: #ffffff; border: 1px solid rgba(255,255,255,0.15);
|
||||
}
|
||||
.side {
|
||||
display: flex; align-items: center; justify-content: space-between;
|
||||
@@ -282,6 +293,7 @@ table.standings { width: 100%; border-collapse: collapse; }
|
||||
.wrap { padding: 0 12px; }
|
||||
|
||||
/* ---------- mobil: Header ---------- */
|
||||
.masthead { padding: 0 12px; }
|
||||
.masthead-inner { padding: 10px 0; gap: 8px; }
|
||||
.brand { gap: 6px; }
|
||||
.brand-mark { font-size: 18px; }
|
||||
@@ -289,15 +301,13 @@ table.standings { width: 100%; border-collapse: collapse; }
|
||||
.status-pill { font-size: 10px; padding: 4px 10px; gap: 5px; }
|
||||
.dot { width: 6px; height: 6px; }
|
||||
|
||||
/* ---------- mobil: Tabs (horizontal scroll, kein Umbruch) ---------- */
|
||||
/* ---------- mobil: Tabs (zwei Zeilen, kein horizontaler Scroll) ---------- */
|
||||
.masthead-tabs {
|
||||
overflow-x: auto;
|
||||
flex-wrap: nowrap;
|
||||
-webkit-overflow-scrolling: touch;
|
||||
scrollbar-width: none;
|
||||
flex-wrap: wrap;
|
||||
justify-content: center;
|
||||
gap: 2px 4px;
|
||||
}
|
||||
.masthead-tabs::-webkit-scrollbar { display: none; }
|
||||
.tab { padding: 10px 14px; font-size: 12px; white-space: nowrap; flex-shrink: 0; }
|
||||
.tab { padding: 8px 13px; font-size: 12px; }
|
||||
|
||||
.section { padding: 18px 0 48px; }
|
||||
|
||||
@@ -320,7 +330,8 @@ table.standings { width: 100%; border-collapse: collapse; }
|
||||
.fx-score { font-size: 16px; min-width: 44px; }
|
||||
.fx-vs { font-size: 14px; min-width: 44px; }
|
||||
.fx-name { font-size: 13px; max-width: 110px; }
|
||||
.grp-chip { width: 34px; height: 34px; font-size: 12px; }
|
||||
.grp-switch { gap: 8px; }
|
||||
.grp-chip { width: 40px; height: 40px; font-size: 14px; }
|
||||
|
||||
/* ---------- mobil: Drittplatzierte ---------- */
|
||||
.third-table th { font-size: 9px; padding: 8px 6px; }
|
||||
@@ -338,7 +349,7 @@ table.standings { width: 100%; border-collapse: collapse; }
|
||||
.round { min-width: 170px; }
|
||||
.round-label { font-size: 10px; }
|
||||
.round-matches { gap: 8px; }
|
||||
.tie-head { font-size: 8px; padding: 3px 8px 0; }
|
||||
.tie-meta { font-size: 8px; padding: 3px 8px 0; }
|
||||
.side { padding: 6px 8px; font-size: 11px; }
|
||||
.side .nm { gap: 5px; }
|
||||
.prov-mark { font-size: 10px; }
|
||||
|
||||
@@ -1,20 +1,8 @@
|
||||
import type { Metadata } from "next";
|
||||
import "./globals.css";
|
||||
|
||||
export const metadata: Metadata = {
|
||||
title: "WM 26 — Gruppen & K.o.-Baum",
|
||||
description:
|
||||
"Live-Gruppentabellen, Drittplatzierten-Wertung und der vollständige K.o.-Baum der FIFA WM 2026 mit Annex-C-Zuordnung und Polymarket-Wahrscheinlichkeiten.",
|
||||
};
|
||||
|
||||
export const viewport = {
|
||||
width: "device-width",
|
||||
initialScale: 1,
|
||||
};
|
||||
|
||||
export default function RootLayout({ children }: { children: React.ReactNode }) {
|
||||
return (
|
||||
<html lang="de">
|
||||
<html lang="en">
|
||||
<head>
|
||||
<link rel="preconnect" href="https://fonts.googleapis.com" />
|
||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossOrigin="" />
|
||||
|
||||
@@ -4,7 +4,11 @@
|
||||
|
||||
services:
|
||||
wm2026:
|
||||
build: .
|
||||
build:
|
||||
context: .
|
||||
args:
|
||||
NEXT_PUBLIC_UMAMI_SRC: ${NEXT_PUBLIC_UMAMI_SRC:-}
|
||||
NEXT_PUBLIC_UMAMI_ID: ${NEXT_PUBLIC_UMAMI_ID:-}
|
||||
image: wm2026-board:latest
|
||||
container_name: wm2026
|
||||
restart: unless-stopped
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { ANNEX_C } from "./annexc-data";
|
||||
import { GroupId, GroupTable, ThirdPlaceRow } from "./types";
|
||||
import { Dictionary } from "./i18n";
|
||||
|
||||
// Die festen Paarungen der Runde der letzten 32 (FIFA-Spielplan, Annex zur Auslosung).
|
||||
// Quelle: FIFA WM 2026 Wettbewerbsregeln, Spiele 73-88.
|
||||
@@ -100,14 +101,16 @@ export function slotLabel(
|
||||
slot: BracketSlot,
|
||||
assignment: ThirdAssignment | null,
|
||||
winnerGroupForThisMatch?: GroupId,
|
||||
dict?: Dictionary,
|
||||
): string {
|
||||
if (slot.type === "W") return `Sieger ${slot.group}`;
|
||||
if (slot.type === "R") return `Zweiter ${slot.group}`;
|
||||
const s = dict?.slot;
|
||||
if (slot.type === "W") return s?.winner(slot.group!) ?? `Sieger ${slot.group}`;
|
||||
if (slot.type === "R") return s?.runnerUp(slot.group!) ?? `Zweiter ${slot.group}`;
|
||||
// 3. Platz
|
||||
if (assignment && winnerGroupForThisMatch && assignment[winnerGroupForThisMatch]) {
|
||||
return `3. der Gruppe ${assignment[winnerGroupForThisMatch]}`;
|
||||
return s?.thirdOfGroup(assignment[winnerGroupForThisMatch]!) ?? `3. der Gruppe ${assignment[winnerGroupForThisMatch]}`;
|
||||
}
|
||||
return `3. ${slot.thirdPool?.join("/") ?? "?"}`;
|
||||
return s?.thirdPlacePool(slot.thirdPool?.join("/") ?? "?") ?? `3. ${slot.thirdPool?.join("/") ?? "?"}`;
|
||||
}
|
||||
|
||||
// Lookup: matchNumber → Quellspiele (fromHome, fromAway, losers).
|
||||
|
||||
489
lib/feeds.ts
489
lib/feeds.ts
@@ -1,6 +1,8 @@
|
||||
import { GroupId, Match, MatchStatus, Team } from "./types";
|
||||
import { GroupId, GoalEvent, Match, MatchStatus, Team } from "./types";
|
||||
import { venueFor } from "./venues";
|
||||
import { localisedTeamName } from "./team-mappings";
|
||||
import { R32, LATER_ROUNDS, resolveAnnexC, qualifiedThirdGroups } from "./bracket";
|
||||
import { computeGroupTables, computeThirdPlaceTable } from "./standings";
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// Caching: einfacher In-Memory-Cache mit TTL. Verhindert, dass jede Browser-
|
||||
@@ -88,26 +90,74 @@ const STAGE_ORDER: Record<Match["stage"], number> = {
|
||||
};
|
||||
|
||||
// Setzt Spielnummern und Stadien.
|
||||
// - K.o.-Spiele: chronologisch ab 73 (Anstöße dort eindeutig) -> für Bracket nötig.
|
||||
// - Venue: Gruppenspiele über die Teampaarung, K.o.-Spiele über die Spielnummer.
|
||||
// K.o.-Spiele: Nummerierung über Slot-Auflösung (assignKONumbersBySlots),
|
||||
// NICHT mehr chronologisch — die FIFA-Nummern folgen der Bracket-Topologie.
|
||||
// Venue: Gruppenspiele über die Teampaarung, K.o.-Spiele über die Spielnummer.
|
||||
function assignNumbersAndVenues(matches: Match[], teams: Team[]): void {
|
||||
// K.o.-Spiele eindeutig durchnummerieren (73..104).
|
||||
const ko = matches
|
||||
.filter((m) => m.group == null)
|
||||
.sort((a, b) => {
|
||||
const sa = STAGE_ORDER[a.stage], sb = STAGE_ORDER[b.stage];
|
||||
if (sa !== sb) return sa - sb;
|
||||
const t = +new Date(a.utcDate) - +new Date(b.utcDate);
|
||||
return t !== 0 ? t : Number(a.id) - Number(b.id);
|
||||
});
|
||||
ko.forEach((m, i) => { m.matchNumber = 73 + i; });
|
||||
|
||||
// Stadien setzen (Gruppenphase per Paarung, K.o. per Nummer).
|
||||
for (const m of matches) {
|
||||
m.venue = venueFor(m, teams);
|
||||
}
|
||||
}
|
||||
|
||||
// Vergibt K.o.-Match-Nummern über Slot-Auflösung (FIFA-Topologie)
|
||||
// statt chronologisch. Für R32-Matches mit Team-IDs wird der Slot gesucht,
|
||||
// dessen aufgelöste Teams dem Feed-Paar entsprechen.
|
||||
export function assignKONumbersBySlots(matches: Match[], teams: Team[]): void {
|
||||
const tables = computeGroupTables(teams, matches);
|
||||
const thirds = computeThirdPlaceTable(tables);
|
||||
const qGroups = qualifiedThirdGroups(thirds);
|
||||
const annex = qGroups.length === 8 ? resolveAnnexC(qGroups) : null;
|
||||
|
||||
const byPair = new Map<string, Match>();
|
||||
for (const m of matches) {
|
||||
if (m.group != null || !m.homeTeamId || !m.awayTeamId) continue;
|
||||
byPair.set(`${m.homeTeamId}::${m.awayTeamId}`, m);
|
||||
byPair.set(`${m.awayTeamId}::${m.homeTeamId}`, m);
|
||||
}
|
||||
|
||||
for (const slot of R32) {
|
||||
const homeGroup = slot.home.type === "W" ? slot.home.group : undefined;
|
||||
const awayGroup = slot.away.type === "W" ? slot.away.group : undefined;
|
||||
const wg = (homeGroup ?? awayGroup) as GroupId | undefined;
|
||||
|
||||
let hid: string | null = null;
|
||||
if (slot.home.type === "W" && slot.home.group) {
|
||||
hid = tables.find(t => t.group === slot.home.group)?.rows.find(r => r.rank === 1)?.teamId ?? null;
|
||||
} else if (slot.home.type === "R" && slot.home.group) {
|
||||
hid = tables.find(t => t.group === slot.home.group)?.rows.find(r => r.rank === 2)?.teamId ?? null;
|
||||
} else if (slot.home.type === "3" && annex && wg) {
|
||||
const tg = annex[wg];
|
||||
if (tg) hid = thirds.find(r => r.group === tg && r.qualifies)?.teamId ?? null;
|
||||
}
|
||||
|
||||
let aid: string | null = null;
|
||||
if (slot.away.type === "W" && slot.away.group) {
|
||||
aid = tables.find(t => t.group === slot.away.group)?.rows.find(r => r.rank === 1)?.teamId ?? null;
|
||||
} else if (slot.away.type === "R" && slot.away.group) {
|
||||
aid = tables.find(t => t.group === slot.away.group)?.rows.find(r => r.rank === 2)?.teamId ?? null;
|
||||
} else if (slot.away.type === "3" && annex && wg) {
|
||||
const tg = annex[wg];
|
||||
if (tg) aid = thirds.find(r => r.group === tg && r.qualifies)?.teamId ?? null;
|
||||
}
|
||||
|
||||
if (hid && aid) {
|
||||
const fm = byPair.get(`${hid}::${aid}`);
|
||||
if (fm) fm.matchNumber = slot.matchNumber;
|
||||
}
|
||||
}
|
||||
|
||||
// R16–Finale: per Stage + Datum den LATER_ROUNDS-Slots zuordnen
|
||||
for (const stage of ["R16", "QF", "SF", "3RD", "FINAL"] as const) {
|
||||
const sm = matches.filter(m => m.stage === stage && m.group == null && m.matchNumber === 0)
|
||||
.sort((a, b) => +new Date(a.utcDate) - +new Date(b.utcDate));
|
||||
const ls = LATER_ROUNDS.filter(k => k.stage === (stage === "3RD" ? "3RD" : stage));
|
||||
for (let i = 0; i < sm.length && i < ls.length; i++) {
|
||||
sm[i].matchNumber = ls[i].matchNumber;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Holt alle Spiele + leitet die Teamliste daraus ab (spart einen Extra-Call).
|
||||
export async function fetchMatchesAndTeams(): Promise<{ matches: Match[]; teams: Team[] }> {
|
||||
return cached("fd:matches", 60_000, async () => {
|
||||
@@ -131,6 +181,10 @@ export async function fetchMatchesAndTeams(): Promise<{ matches: Match[]; teams:
|
||||
id, name: side.name, code: side.tla ?? "", group,
|
||||
crest: `/crests/${id}.svg`,
|
||||
localisedName: localisedTeamName(side.tla ?? "", side.name ?? ""),
|
||||
localisedNames: {
|
||||
de: localisedTeamName(side.tla ?? "", side.name ?? "", "de"),
|
||||
en: localisedTeamName(side.tla ?? "", side.name ?? "", "en"),
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -154,6 +208,7 @@ export async function fetchMatchesAndTeams(): Promise<{ matches: Match[]; teams:
|
||||
});
|
||||
|
||||
const teams = [...teamMap.values()];
|
||||
|
||||
assignNumbersAndVenues(matches, teams);
|
||||
|
||||
return { matches, teams };
|
||||
@@ -183,6 +238,7 @@ interface PmMarket {
|
||||
}
|
||||
|
||||
export interface ParsedOdds {
|
||||
slug: string;
|
||||
homeCode: string;
|
||||
awayCode: string;
|
||||
homeName: string;
|
||||
@@ -190,6 +246,7 @@ export interface ParsedOdds {
|
||||
pHome: number;
|
||||
pDraw: number;
|
||||
pAway: number;
|
||||
startTime: string | null;
|
||||
}
|
||||
|
||||
// Normalisiert Teamcodes zwischen Polymarket-Slug und Feed (3-Buchstaben).
|
||||
@@ -214,7 +271,7 @@ function safeParse<T>(s: string, fallback: T): T {
|
||||
// Holt alle WM-Spiele über den Series-Endpoint mit Pagination.
|
||||
// Parst pro Event die drei Moneyline-Märkte (Heim/Draw/Auswärts).
|
||||
export async function fetchOdds(): Promise<ParsedOdds[]> {
|
||||
return cached("pm:odds", 120_000, async () => {
|
||||
return cached("pm:odds", 300_000, async () => {
|
||||
const allEvents: PmEvent[] = [];
|
||||
for (let offset = 0; ; offset += 100) {
|
||||
const url = `${PM_BASE}/events?series_id=${PM_SERIES}&active=true&closed=false&limit=100&offset=${offset}`;
|
||||
@@ -227,9 +284,9 @@ export async function fetchOdds(): Promise<ParsedOdds[]> {
|
||||
allEvents.push(...page);
|
||||
if (page.length < 100) break;
|
||||
}
|
||||
//console.log("[polymarket] events fetched:", allEvents.length);
|
||||
|
||||
const parsed: ParsedOdds[] = [];
|
||||
|
||||
for (const ev of allEvents) {
|
||||
// Slug: fifwc-{home}-{away}-{yyyy}-{mm}-{dd}
|
||||
const slugParts = ev.slug.replace("fifwc-", "").split("-");
|
||||
@@ -239,10 +296,12 @@ export async function fetchOdds(): Promise<ParsedOdds[]> {
|
||||
|
||||
let pHome = 0, pDraw = 0, pAway = 0;
|
||||
let homeName = "", awayName = "";
|
||||
let marketGameStartTime: string | null = null;
|
||||
|
||||
for (const mk of ev.markets ?? []) {
|
||||
if (mk.sportsMarketType && mk.sportsMarketType !== "moneyline") continue;
|
||||
if (mk.closed) continue;
|
||||
if (!marketGameStartTime) marketGameStartTime = (mk as any).gameStartTime ?? null;
|
||||
const prices = safeParse<string[]>(mk.outcomePrices, []).map(Number);
|
||||
if (prices.length < 2) continue;
|
||||
const yes = prices[0]; // erster Preis = "Yes"-Wahrscheinlichkeit
|
||||
@@ -266,7 +325,8 @@ export async function fetchOdds(): Promise<ParsedOdds[]> {
|
||||
}
|
||||
|
||||
if (pHome > 0 || pDraw > 0 || pAway > 0) {
|
||||
parsed.push({ homeCode, awayCode, homeName, awayName, pHome, pDraw, pAway });
|
||||
const startTime = marketGameStartTime ?? (ev as any).gameStartTime ?? (ev as any).endDate ?? (ev as any).startDate;
|
||||
parsed.push({ slug: ev.slug, homeCode, awayCode, homeName, awayName, pHome, pDraw, pAway, startTime });
|
||||
}
|
||||
}
|
||||
|
||||
@@ -312,7 +372,9 @@ export function attachOdds(matches: Match[], teams: Team[], odds: ParsedOdds[]):
|
||||
}
|
||||
}
|
||||
|
||||
return matches.map((m) => {
|
||||
const attachedOdds = new Set<ParsedOdds>();
|
||||
|
||||
const result = matches.map((m) => {
|
||||
if (!m.homeTeamId || !m.awayTeamId) return m;
|
||||
// Suche in oddsMatch nach einer Kombination die beide Team-IDs matcht
|
||||
for (const [o, ids] of oddsMatch) {
|
||||
@@ -321,6 +383,7 @@ export function attachOdds(matches: Match[], teams: Team[], odds: ParsedOdds[]):
|
||||
if ((ids.homeId === m.homeTeamId && ids.awayId === m.awayTeamId) ||
|
||||
(ids.homeId === m.awayTeamId && ids.awayId === m.homeTeamId)) {
|
||||
const swapped = ids.homeId === m.awayTeamId;
|
||||
attachedOdds.add(o);
|
||||
return {
|
||||
...m,
|
||||
prob: {
|
||||
@@ -333,4 +396,394 @@ export function attachOdds(matches: Match[], teams: Team[], odds: ParsedOdds[]):
|
||||
}
|
||||
return m;
|
||||
});
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// KO-Odds-Fallback: löst R32-Paarungen auf und verknüpft Polymarket-Events
|
||||
// mit K.o.-Feed-Matches, die noch keine Team-IDs im Feed haben.
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// Löst für jeden R32-Slot (73-88) die aktuellen Team-Paarungen auf Basis der
|
||||
// Gruppentabellen und Annex-C-Zuordnung. Gibt eine Map matchNumber → Paarung
|
||||
// zurück, NUR wenn beide Team-IDs eindeutig bekannt sind (kein Raten).
|
||||
function resolveR32Pairings(matches: Match[], teams: Team[]): Map<number, { homeTeamId: string; awayTeamId: string }> {
|
||||
const tables = computeGroupTables(teams, matches);
|
||||
const thirds = computeThirdPlaceTable(tables);
|
||||
const qGroups = qualifiedThirdGroups(thirds);
|
||||
const annex = qGroups.length === 8 ? resolveAnnexC(qGroups) : null;
|
||||
|
||||
const pairings = new Map<number, { homeTeamId: string; awayTeamId: string }>();
|
||||
|
||||
for (const slot of R32) {
|
||||
const homeGroup = slot.home.type === "W" ? slot.home.group : undefined;
|
||||
const awayGroup = slot.away.type === "W" ? slot.away.group : undefined;
|
||||
const wg = (homeGroup ?? awayGroup) as GroupId | undefined;
|
||||
|
||||
let hid: string | null = null;
|
||||
if (slot.home.type === "W" && slot.home.group) {
|
||||
hid = tables.find(t => t.group === slot.home.group)?.rows.find(r => r.rank === 1)?.teamId ?? null;
|
||||
} else if (slot.home.type === "R" && slot.home.group) {
|
||||
hid = tables.find(t => t.group === slot.home.group)?.rows.find(r => r.rank === 2)?.teamId ?? null;
|
||||
} else if (slot.home.type === "3" && annex && wg) {
|
||||
const tg = annex[wg];
|
||||
if (tg) hid = thirds.find(r => r.group === tg && r.qualifies)?.teamId ?? null;
|
||||
}
|
||||
|
||||
let aid: string | null = null;
|
||||
if (slot.away.type === "W" && slot.away.group) {
|
||||
aid = tables.find(t => t.group === slot.away.group)?.rows.find(r => r.rank === 1)?.teamId ?? null;
|
||||
} else if (slot.away.type === "R" && slot.away.group) {
|
||||
aid = tables.find(t => t.group === slot.away.group)?.rows.find(r => r.rank === 2)?.teamId ?? null;
|
||||
} else if (slot.away.type === "3" && annex && wg) {
|
||||
const tg = annex[wg];
|
||||
if (tg) aid = thirds.find(r => r.group === tg && r.qualifies)?.teamId ?? null;
|
||||
}
|
||||
|
||||
if (hid && aid) {
|
||||
pairings.set(slot.matchNumber, { homeTeamId: hid, awayTeamId: aid });
|
||||
}
|
||||
}
|
||||
|
||||
return pairings;
|
||||
}
|
||||
|
||||
// Extrahiert das Datum (YYYY-MM-DD) aus einem Polymarket-Slug.
|
||||
// Slug-Format: fifwc-{home}-{away}-{yyyy}-{mm}-{dd}
|
||||
function slugToDate(slug: string): string | null {
|
||||
const parts = slug.split("-");
|
||||
if (parts.length < 3) return null;
|
||||
const y = parts[parts.length - 3];
|
||||
const m = parts[parts.length - 2];
|
||||
const d = parts[parts.length - 1];
|
||||
if (/^\d{4}$/.test(y) && /^\d{2}$/.test(m) && /^\d{2}$/.test(d)) {
|
||||
return `${y}-${m}-${d}`;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
// Zweiter Durchlauf für attachOdds: ordnet Polymarket-Events K.o.-Feed-Matches
|
||||
// zu, die (noch) keine Team-IDs im Feed haben. Arbeitet direkt auf den
|
||||
// aufgelösten R32-Paarungen (resolveR32Pairings). Identifiziert das Ziel-
|
||||
// Feed-Match über die Slot-matchNumber (Stufe 1) oder Datums-Lookup aus dem
|
||||
// Slug (Stufe 2) — KEINE chronologische Nummernvergabe.
|
||||
// Mutiert matches in-place, setzt nur bei Matches OHNE bestehende prob.
|
||||
export function attachKOOdds(matches: Match[], teams: Team[], odds: ParsedOdds[]): Match[] {
|
||||
const pairings = resolveR32Pairings(matches, teams);
|
||||
if (pairings.size === 0) return matches;
|
||||
|
||||
const idByName = new Map<string, string>();
|
||||
for (const t of teams) {
|
||||
const nn = normName(t.name);
|
||||
if (!idByName.has(nn)) idByName.set(nn, t.id);
|
||||
}
|
||||
const idByCode = new Map(teams.map((t) => [t.code.toLowerCase(), t.id]));
|
||||
|
||||
for (const [matchNum, pairing] of pairings) {
|
||||
if (!pairing.homeTeamId || !pairing.awayTeamId) continue;
|
||||
|
||||
// Finde Polymarket-Event für dieses Team-Paar
|
||||
let matchedEvent: ParsedOdds | null = null;
|
||||
for (const o of odds) {
|
||||
const hn = normName(o.homeName);
|
||||
const an = normName(o.awayName);
|
||||
const homeId = idByName.get(hn) ?? idByCode.get(o.homeCode);
|
||||
const awayId = idByName.get(an) ?? idByCode.get(o.awayCode);
|
||||
if (!homeId || !awayId) continue;
|
||||
if ((homeId === pairing.homeTeamId && awayId === pairing.awayTeamId) ||
|
||||
(homeId === pairing.awayTeamId && awayId === pairing.homeTeamId)) {
|
||||
matchedEvent = o;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!matchedEvent) continue;
|
||||
|
||||
// Ziel-Feed-Match identifizieren
|
||||
let targetMatch: Match | undefined;
|
||||
|
||||
// Stufe 1: bereits nummeriertes R32-Match (via assignKONumbersBySlots Pass 1)
|
||||
targetMatch = matches.find(m =>
|
||||
m.stage === "R32" && m.group == null && m.matchNumber === matchNum,
|
||||
);
|
||||
|
||||
// Stufe 2: Datums-Lookup aus Polymarket-Slug für unnummerierte Matches
|
||||
if (!targetMatch) {
|
||||
const slugDate = slugToDate(matchedEvent.slug);
|
||||
if (slugDate) {
|
||||
const candidates = matches.filter(m =>
|
||||
m.stage === "R32" && m.group == null && m.matchNumber === 0 &&
|
||||
m.utcDate.slice(0, 10) === slugDate,
|
||||
);
|
||||
|
||||
if (candidates.length === 1) {
|
||||
targetMatch = candidates[0];
|
||||
targetMatch.matchNumber = matchNum;
|
||||
} else if (candidates.length > 1) {
|
||||
// Tie-breaker: falls Polymarket-Event eine Startzeit hat, nächstgelegenes Feed-Match
|
||||
if (matchedEvent.startTime) {
|
||||
const eventTime = new Date(matchedEvent.startTime).getTime();
|
||||
let best: Match | undefined;
|
||||
let bestDiff = Infinity;
|
||||
for (const c of candidates) {
|
||||
const diff = Math.abs(new Date(c.utcDate).getTime() - eventTime);
|
||||
if (diff < bestDiff) { bestDiff = diff; best = c; }
|
||||
}
|
||||
// Nur zuordnen, wenn Zeitdifferenz plausibel (<4h)
|
||||
if (best && bestDiff < 4 * 60 * 60 * 1000) {
|
||||
targetMatch = best;
|
||||
targetMatch.matchNumber = matchNum;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!targetMatch) continue;
|
||||
|
||||
// prob nicht überschreiben, falls schon gesetzt
|
||||
if (targetMatch.prob) continue;
|
||||
|
||||
const homeIdFromEvent = idByName.get(normName(matchedEvent.homeName)) ??
|
||||
idByCode.get(matchedEvent.homeCode);
|
||||
const swapped = homeIdFromEvent === pairing.awayTeamId;
|
||||
|
||||
targetMatch.prob = {
|
||||
home: swapped ? matchedEvent.pAway : matchedEvent.pHome,
|
||||
draw: matchedEvent.pDraw,
|
||||
away: swapped ? matchedEvent.pHome : matchedEvent.pAway,
|
||||
};
|
||||
}
|
||||
|
||||
return matches;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// FIFA-API: Live-Scores, Elfmeterschießen, Spielminute
|
||||
// ----------------------------------------------------------------------------
|
||||
const FIFA_BASE = "https://api.fifa.com/api/v3";
|
||||
const FIFA_SEASON = "285023";
|
||||
|
||||
// FIFA-Code → App-Code (nur Abweichungen; sonst identisch)
|
||||
const FIFA_CODE_OVERRIDE: Record<string, string> = {
|
||||
CRO: "HRV", // Kroatien
|
||||
POR: "PRT", // Portugal
|
||||
SUI: "CHE", // Schweiz
|
||||
};
|
||||
function fifaCodeToAppCode(fifaCode: string): string {
|
||||
return FIFA_CODE_OVERRIDE[fifaCode] ?? fifaCode;
|
||||
}
|
||||
|
||||
interface FifaTeamBlock {
|
||||
IdTeam: string; // FIFA-Team-ID
|
||||
Abbreviation: string; // FIFA-Code (z.B. PAR, CRO)
|
||||
}
|
||||
|
||||
interface FifaMatch {
|
||||
MatchNumber: number;
|
||||
IdMatch?: string | null;
|
||||
IdStage?: string | null;
|
||||
Home: FifaTeamBlock | null;
|
||||
Away: FifaTeamBlock | null;
|
||||
HomeTeamScore: number | null;
|
||||
AwayTeamScore: number | null;
|
||||
HomeTeamPenaltyScore: number | null;
|
||||
AwayTeamPenaltyScore: number | null;
|
||||
MatchStatus: number; // 0=finished, 1=scheduled, else=live
|
||||
MatchTime: string | null; // z.B. "132'"
|
||||
ResultType: number | null; // 1=regular, 2=penalties
|
||||
Winner?: string | null; // Team-ID des Siegers
|
||||
}
|
||||
|
||||
interface FifaScores {
|
||||
homeScore: number | null;
|
||||
awayScore: number | null;
|
||||
homePenalty: number | null;
|
||||
awayPenalty: number | null;
|
||||
resultType: number | null;
|
||||
status: MatchStatus;
|
||||
matchTime: string | null;
|
||||
winnerTeamId: string | null;
|
||||
idMatch: string | null;
|
||||
idStage: string | null;
|
||||
}
|
||||
|
||||
// Holt Live-Scores von der FIFA-API. Gibt Map MatchNumber → Scores + FIFA-ID→App-Code-Map zurück.
|
||||
export async function fetchFifaScores(locale: string = "de"): Promise<{
|
||||
scores: Map<number, FifaScores>;
|
||||
fifaIdToAppCode: Map<string, string>;
|
||||
}> {
|
||||
return cached(`fifa:scores:${locale}`, 45_000, async () => {
|
||||
const lang = locale === "en" ? "en" : "de";
|
||||
const url = `${FIFA_BASE}/calendar/matches?language=${lang}&count=500&idSeason=${FIFA_SEASON}`;
|
||||
const res = await fetch(url, {
|
||||
cache: "no-store",
|
||||
headers: { "User-Agent": "wm2026-board/1.0" },
|
||||
signal: AbortSignal.timeout(5000),
|
||||
});
|
||||
if (!res.ok) throw new Error(`fifa ${res.status}`);
|
||||
const data = (await res.json()) as { Results: FifaMatch[] };
|
||||
const scores = new Map<number, FifaScores>();
|
||||
const fifaIdToAppCode = new Map<string, string>();
|
||||
|
||||
for (const fm of data.Results ?? []) {
|
||||
// Team-Mapping sammeln
|
||||
for (const tb of [fm.Home, fm.Away]) {
|
||||
if (tb && !fifaIdToAppCode.has(tb.IdTeam)) {
|
||||
fifaIdToAppCode.set(tb.IdTeam, fifaCodeToAppCode(tb.Abbreviation));
|
||||
}
|
||||
}
|
||||
|
||||
let status: MatchStatus;
|
||||
switch (fm.MatchStatus) {
|
||||
case 0: status = "FINISHED"; break;
|
||||
case 1: status = "SCHEDULED"; break;
|
||||
case 10: status = "POSTPONED"; break;
|
||||
default: status = "LIVE"; break;
|
||||
}
|
||||
scores.set(fm.MatchNumber, {
|
||||
homeScore: fm.HomeTeamScore,
|
||||
awayScore: fm.AwayTeamScore,
|
||||
homePenalty: fm.HomeTeamPenaltyScore,
|
||||
awayPenalty: fm.AwayTeamPenaltyScore,
|
||||
resultType: fm.ResultType,
|
||||
status,
|
||||
matchTime: fm.MatchTime,
|
||||
winnerTeamId: fm.Winner ?? null,
|
||||
idMatch: fm.IdMatch ?? null,
|
||||
idStage: fm.IdStage ?? null,
|
||||
});
|
||||
}
|
||||
return { scores, fifaIdToAppCode };
|
||||
});
|
||||
}
|
||||
|
||||
// Wendet FIFA-Live-Scores auf Matches an (MatchNumber als exakter Schlüssel).
|
||||
export function applyFifaScores(
|
||||
matches: Match[], teams: Team[],
|
||||
fifaData: { scores: Map<number, FifaScores>; fifaIdToAppCode: Map<string, string> },
|
||||
): Match[] {
|
||||
const { scores: fifaMap, fifaIdToAppCode } = fifaData;
|
||||
if (fifaMap.size === 0) return matches;
|
||||
// Baue App-Code → App-Team-ID Map
|
||||
const appCodeToId = new Map<string, string>();
|
||||
for (const t of teams) {
|
||||
if (t.code) appCodeToId.set(t.code.toLowerCase(), t.id);
|
||||
}
|
||||
let applied = 0;
|
||||
const result = matches.map((m) => {
|
||||
const fs = fifaMap.get(m.matchNumber);
|
||||
if (!fs) return m;
|
||||
const r = { ...m };
|
||||
if (fs.homeScore != null) r.homeScore = fs.homeScore;
|
||||
if (fs.awayScore != null) r.awayScore = fs.awayScore;
|
||||
if (fs.homePenalty != null) r.homePenalty = fs.homePenalty;
|
||||
if (fs.awayPenalty != null) r.awayPenalty = fs.awayPenalty;
|
||||
// FIFA-ID → App-Team-ID auflösen
|
||||
if (fs.winnerTeamId) {
|
||||
const appCode = fifaIdToAppCode.get(fs.winnerTeamId);
|
||||
if (appCode) {
|
||||
const appTeamId = appCodeToId.get(appCode.toLowerCase());
|
||||
if (appTeamId) {
|
||||
r.winnerTeamId = appTeamId;
|
||||
} else {
|
||||
console.warn("[fifa] Winner-Team-Code nicht in App-Teams:", appCode, "| matchNumber:", m.matchNumber);
|
||||
}
|
||||
} else {
|
||||
console.warn("[fifa] FIFA-Winner-ID nicht in Team-Map:", fs.winnerTeamId, "| matchNumber:", m.matchNumber);
|
||||
}
|
||||
}
|
||||
if (fs.matchTime) {
|
||||
const min = parseInt(fs.matchTime, 10);
|
||||
if (!isNaN(min)) r.minute = min;
|
||||
}
|
||||
r.status = fs.status;
|
||||
applied++;
|
||||
return r;
|
||||
});
|
||||
if (applied > 0) console.log("[fifa] scores angewandt:", applied);
|
||||
return result;
|
||||
}
|
||||
|
||||
// Holt Tor-Details pro Spiel vom FIFA-Detail-Endpoint.
|
||||
interface FifaGoalRaw { scorer: string; minute: string; team: "home" | "away"; type: number | null; }
|
||||
|
||||
function locName(arr: Array<{ Locale: string; Description: string }> | undefined): string {
|
||||
if (!arr || arr.length === 0) return "";
|
||||
return (arr.find(x => x.Locale === "de-DE")
|
||||
?? arr.find(x => x.Locale === "en-GB")
|
||||
?? arr[0])?.Description ?? "";
|
||||
}
|
||||
|
||||
function normMinuteStr(min: string | null | undefined): string {
|
||||
return (min ?? "").replace(/'/g, "").replace(/\s+/g, "").trim();
|
||||
}
|
||||
|
||||
async function fetchFifaGoals(idStage: string, idMatch: string, locale: string = "de"): Promise<FifaGoalRaw[]> {
|
||||
return cached(`fifa:detail:${locale}:${idMatch}`, 60_000, async () => {
|
||||
const lang = locale === "en" ? "en" : "de";
|
||||
const url = `${FIFA_BASE}/live/football/17/${FIFA_SEASON}/${idStage}/${idMatch}?language=${lang}`;
|
||||
const res = await fetch(url, {
|
||||
cache: "no-store",
|
||||
headers: { "User-Agent": "wm2026-board/1.0" },
|
||||
signal: AbortSignal.timeout(5000),
|
||||
});
|
||||
if (!res.ok) { console.warn("[fifa-detail] status", res.status, idMatch); return []; }
|
||||
const dj: any = await res.json();
|
||||
|
||||
const buildPlayerMap = (teamBlock: any): Map<string, string> => {
|
||||
const map = new Map<string, string>();
|
||||
for (const p of teamBlock?.Players ?? []) {
|
||||
map.set(String(p.IdPlayer), locName(p.PlayerName) || locName(p.ShortName));
|
||||
}
|
||||
return map;
|
||||
};
|
||||
const homeBlock = dj.HomeTeam, awayBlock = dj.AwayTeam;
|
||||
const homePlayers = buildPlayerMap(homeBlock);
|
||||
const awayPlayers = buildPlayerMap(awayBlock);
|
||||
|
||||
const goals: FifaGoalRaw[] = [];
|
||||
for (const [block, players, side] of [
|
||||
[homeBlock, homePlayers, "home"] as const,
|
||||
[awayBlock, awayPlayers, "away"] as const,
|
||||
]) {
|
||||
for (const g of block?.Goals ?? []) {
|
||||
const min = normMinuteStr(g.Minute);
|
||||
if (min === "" || isNaN(parseInt(min, 10))) continue;
|
||||
goals.push({
|
||||
scorer: players.get(String(g.IdPlayer)) || "?",
|
||||
minute: normMinuteStr(g.Minute),
|
||||
team: side,
|
||||
type: g.Type ?? null,
|
||||
});
|
||||
}
|
||||
}
|
||||
goals.sort((a, b) => parseInt(a.minute, 10) - parseInt(b.minute, 10));
|
||||
return goals;
|
||||
});
|
||||
}
|
||||
|
||||
// Lädt Tor-Details für beendete/laufende Spiele mit Toren und hängt sie an die Matches an.
|
||||
export async function attachFifaGoals(
|
||||
matches: Match[],
|
||||
fifaData: { scores: Map<number, FifaScores>; fifaIdToAppCode: Map<string, string> },
|
||||
locale: string = "de",
|
||||
): Promise<Match[]> {
|
||||
const targets = matches.filter(m =>
|
||||
(m.status === "FINISHED" || m.status === "LIVE" || m.status === "IN_PLAY") &&
|
||||
((m.homeScore ?? 0) + (m.awayScore ?? 0)) > 0,
|
||||
);
|
||||
const goalsByMatchId = new Map<string, GoalEvent[]>();
|
||||
await Promise.all(targets.map(async (m) => {
|
||||
const fs = fifaData.scores.get(m.matchNumber);
|
||||
if (!fs?.idMatch || !fs?.idStage) return;
|
||||
const goals = await fetchFifaGoals(fs.idStage, fs.idMatch, locale);
|
||||
if (goals.length) goalsByMatchId.set(m.id, goals);
|
||||
}));
|
||||
if (goalsByMatchId.size === 0) return matches;
|
||||
return matches.map(m => {
|
||||
const g = goalsByMatchId.get(m.id);
|
||||
return g ? { ...m, goals: g.map(({ scorer, minute, team }) => ({ scorer, minute, team })) } : m;
|
||||
});
|
||||
}
|
||||
140
lib/i18n/de.ts
Normal file
140
lib/i18n/de.ts
Normal file
@@ -0,0 +1,140 @@
|
||||
import { Dictionary } from "./types";
|
||||
|
||||
const de: Dictionary = {
|
||||
meta: {
|
||||
title: "WM 26 — Gruppen & K.o.-Baum",
|
||||
description:
|
||||
"Live-Gruppentabellen, Drittplatzierten-Wertung und der vollständige K.o.-Baum der FIFA WM 2026 mit Annex-C-Zuordnung und Polymarket-Wahrscheinlichkeiten.",
|
||||
},
|
||||
header: {
|
||||
hostCountries: "USA · Kanada · Mexiko",
|
||||
},
|
||||
status: {
|
||||
feedOffline: "Feed offline",
|
||||
updated: (time: string) => `Aktualisiert ${time}`,
|
||||
live: "Live",
|
||||
loading: "Lade Daten…",
|
||||
running: "läuft",
|
||||
halftime: "Halbzeit",
|
||||
finished: "Beendet",
|
||||
postponed: "Verzögert",
|
||||
},
|
||||
nav: {
|
||||
koFixtures: "K.O.-Spiele",
|
||||
groups: "Gruppen",
|
||||
groupFixtures: (group: string) => `Gruppenspiele – ${group}`,
|
||||
groupFixturesNoGroup: "Gruppenspiele",
|
||||
thirdPlace: "Drittplatzierte",
|
||||
bracket: "K.o.-Baum",
|
||||
simulation: "Simulation",
|
||||
},
|
||||
error: {
|
||||
feedUnreachable:
|
||||
"Die Live-Feeds sind gerade nicht erreichbar. Die Seite versucht es automatisch erneut.",
|
||||
unknown: "unbekannter Fehler",
|
||||
},
|
||||
footer: {
|
||||
dashboard: "WM 2026 Dashboard",
|
||||
dataSources: "Daten: football-data.org · Polymarket Gamma API · FIFA Annex C",
|
||||
},
|
||||
sim: {
|
||||
notice:
|
||||
"Simulation — alle ungespielten Spiele sind mit dem Polymarket-Favoriten vorbelegt. Die angezeigten Wahrscheinlichkeiten stammen von Polymarket.",
|
||||
heading: "Simulierter K.o.-Baum",
|
||||
},
|
||||
koFixtures: {
|
||||
noMatches: "Keine K.o.-Spiele mit bekannten Teams verfügbar.",
|
||||
liveBadge: "LIVE",
|
||||
nextMatch: "NÄCHSTES SPIEL",
|
||||
postponedBadge: "VERZÖGERT",
|
||||
match: (n: number) => `Spiel ${n}`,
|
||||
},
|
||||
label: {
|
||||
goals: "Tore",
|
||||
liveIndicator: "● LIVE",
|
||||
scrollToTop: "Nach oben scrollen",
|
||||
securelyQualified: "sicher qualifiziert",
|
||||
},
|
||||
stage: {
|
||||
r16: "Achtelfinale",
|
||||
qf: "Viertelfinale",
|
||||
sf: "Halbfinale",
|
||||
thirdPlace: "Platz 3",
|
||||
final: "Finale",
|
||||
},
|
||||
round: {
|
||||
r32: "Letzte 32",
|
||||
r16: "Achtelfinale",
|
||||
qf: "Viertelfinale",
|
||||
sf: "Halbfinale",
|
||||
final: "Finale",
|
||||
thirdPlace: "Spiel um Platz 3",
|
||||
},
|
||||
bracket: {
|
||||
provisionalTooltip: "vorläufig – Gruppe/Zuordnung noch nicht fix",
|
||||
match: (n: number) => `Spiel ${n}`,
|
||||
penaltyShootout: "i.E.",
|
||||
annexHeader: "Annex-C-Zuordnung der Drittplatzierten:",
|
||||
annexResolved:
|
||||
"aufgelöst — die acht Dritten sind den Gruppensiegern fest zugeteilt",
|
||||
annexPending:
|
||||
"noch offen — sobald die 8 besten Dritten feststehen, verbindet sich der Baum automatisch",
|
||||
winner: "Sieger",
|
||||
loser: "Verlierer",
|
||||
winnerFromMatch: (n: number) => `Sieger aus Spiel ${n}`,
|
||||
loserFromMatch: (n: number) => `Verlierer aus Spiel ${n}`,
|
||||
},
|
||||
legend: {
|
||||
winner: "Sieger / weiter",
|
||||
final: "Finale",
|
||||
fixed: "fix qualifiziert",
|
||||
provisional: "vorläufig (≈, nach aktueller Tabelle)",
|
||||
placeholder: "Platzhalter offen",
|
||||
probExplanation:
|
||||
"%-Werte: Polymarket-Wahrscheinlichkeit (falls verfügbar)",
|
||||
},
|
||||
tooltips: {
|
||||
provisionalPrefix: "aktuell",
|
||||
firstOfGroup: (group: string) => `1. Gruppe ${group}`,
|
||||
secondOfGroup: (group: string) => `2. Gruppe ${group}`,
|
||||
thirdOfGroup: (group: string) => `3. der Gruppe ${group}`,
|
||||
provisionalThird: (pool: string) => `aktuell 3. Gruppe ${pool}`,
|
||||
},
|
||||
slot: {
|
||||
winner: (group: string) => `Sieger ${group}`,
|
||||
runnerUp: (group: string) => `Zweiter ${group}`,
|
||||
thirdOfGroup: (group: string) => `3. der Gruppe ${group}`,
|
||||
thirdPlacePool: (pool: string) => `3. ${pool}`,
|
||||
},
|
||||
table: {
|
||||
rank: "#",
|
||||
team: "Mannschaft",
|
||||
group: "Gruppe",
|
||||
matches: "Sp",
|
||||
won: "S",
|
||||
drawn: "U",
|
||||
lost: "N",
|
||||
goals: "Tore",
|
||||
goalDiff: "±",
|
||||
points: "Pkt",
|
||||
status: "Status",
|
||||
},
|
||||
thirds: {
|
||||
explanation:
|
||||
"Acht der zwölf Gruppendritten erreichen die Runde der letzten 32. Gewertet wird gruppenübergreifend nach Punkten, Tordifferenz und Toren — der Direktvergleich entfällt, weil diese Teams nie gegeneinander gespielt haben. Die Trennlinie markiert den Schnitt zwischen Platz 8 und 9.",
|
||||
advances: "weiter",
|
||||
eliminated: "raus",
|
||||
},
|
||||
fixtures: {
|
||||
standingsTitle: (group: string) => `Tabelle – Gruppe ${group}`,
|
||||
noMatches: (group: string) =>
|
||||
`Für Gruppe ${group} liegen noch keine Spiele im Feed vor.`,
|
||||
},
|
||||
groups: {
|
||||
viewGroupGames: (group: string) => `Spiele der Gruppe ${group} ansehen`,
|
||||
groupLabel: (group: string) => `Gruppe ${group}`,
|
||||
viewGames: "Spiele ansehen →",
|
||||
},
|
||||
};
|
||||
|
||||
export default de;
|
||||
145
lib/i18n/en.ts
Normal file
145
lib/i18n/en.ts
Normal file
@@ -0,0 +1,145 @@
|
||||
import { Dictionary } from "./types";
|
||||
|
||||
function ordinal(n: number): string {
|
||||
const s = ["th", "st", "nd", "rd"];
|
||||
const v = n % 100;
|
||||
return n + (s[(v - 20) % 10] || s[v] || s[0]);
|
||||
}
|
||||
|
||||
const en: Dictionary = {
|
||||
meta: {
|
||||
title: "WC 26 — Groups & KO Bracket",
|
||||
description:
|
||||
"Live group tables, third-place ranking and the complete KO bracket for the FIFA World Cup 2026 with Annex C assignment and Polymarket probabilities.",
|
||||
},
|
||||
header: {
|
||||
hostCountries: "USA · Canada · Mexico",
|
||||
},
|
||||
status: {
|
||||
feedOffline: "Feed offline",
|
||||
updated: (time: string) => `Updated ${time}`,
|
||||
live: "Live",
|
||||
loading: "Loading…",
|
||||
running: "running",
|
||||
halftime: "Half time",
|
||||
finished: "Finished",
|
||||
postponed: "Postponed",
|
||||
},
|
||||
nav: {
|
||||
koFixtures: "KO Matches",
|
||||
groups: "Groups",
|
||||
groupFixtures: (group: string) => `Group Stage – ${group}`,
|
||||
groupFixturesNoGroup: "Group Stage",
|
||||
thirdPlace: "Third Place",
|
||||
bracket: "KO Bracket",
|
||||
simulation: "Simulation",
|
||||
},
|
||||
error: {
|
||||
feedUnreachable:
|
||||
"Live feeds are currently unavailable. The page will retry automatically.",
|
||||
unknown: "unknown error",
|
||||
},
|
||||
footer: {
|
||||
dashboard: "WC 2026 Dashboard",
|
||||
dataSources: "Data: football-data.org · Polymarket Gamma API · FIFA Annex C",
|
||||
},
|
||||
sim: {
|
||||
notice:
|
||||
"Simulation — all unplayed matches are pre-filled with the Polymarket favourite. Probabilities shown are from Polymarket.",
|
||||
heading: "Simulated KO Bracket",
|
||||
},
|
||||
koFixtures: {
|
||||
noMatches: "No KO matches with known teams available.",
|
||||
liveBadge: "LIVE",
|
||||
nextMatch: "NEXT MATCH",
|
||||
postponedBadge: "POSTPONED",
|
||||
match: (n: number) => `Match ${n}`,
|
||||
},
|
||||
label: {
|
||||
goals: "Goals",
|
||||
liveIndicator: "● LIVE",
|
||||
scrollToTop: "Scroll to top",
|
||||
securelyQualified: "securely qualified",
|
||||
},
|
||||
stage: {
|
||||
r16: "Round of 16",
|
||||
qf: "Quarter-finals",
|
||||
sf: "Semi-finals",
|
||||
thirdPlace: "3rd Place",
|
||||
final: "Final",
|
||||
},
|
||||
round: {
|
||||
r32: "Round of 32",
|
||||
r16: "Round of 16",
|
||||
qf: "Quarter-finals",
|
||||
sf: "Semi-finals",
|
||||
final: "Final",
|
||||
thirdPlace: "Third Place Match",
|
||||
},
|
||||
bracket: {
|
||||
provisionalTooltip: "provisional – group/assignment not yet fixed",
|
||||
match: (n: number) => `Match ${n}`,
|
||||
penaltyShootout: "PSO",
|
||||
annexHeader: "Annex C third-place assignment:",
|
||||
annexResolved:
|
||||
"resolved — the eight third-placed teams are permanently assigned to group winners",
|
||||
annexPending:
|
||||
"pending — once the 8 best third-placed teams are determined, the bracket auto-connects",
|
||||
winner: "Winner",
|
||||
loser: "Loser",
|
||||
winnerFromMatch: (n: number) => `Winner of match ${n}`,
|
||||
loserFromMatch: (n: number) => `Loser of match ${n}`,
|
||||
},
|
||||
legend: {
|
||||
winner: "Winner / advances",
|
||||
final: "Final",
|
||||
fixed: "securely qualified",
|
||||
provisional: "provisional (≈, current standings)",
|
||||
placeholder: "placeholder open",
|
||||
probExplanation: "% values: Polymarket probability (if available)",
|
||||
},
|
||||
tooltips: {
|
||||
provisionalPrefix: "currently",
|
||||
firstOfGroup: (group: string) => `${ordinal(1)} in Group ${group}`,
|
||||
secondOfGroup: (group: string) => `${ordinal(2)} in Group ${group}`,
|
||||
thirdOfGroup: (group: string) => `${ordinal(3)} in Group ${group}`,
|
||||
provisionalThird: (pool: string) => `currently 3rd of Group ${pool}`,
|
||||
},
|
||||
slot: {
|
||||
winner: (group: string) => `Winner ${group}`,
|
||||
runnerUp: (group: string) => `Runner-up ${group}`,
|
||||
thirdOfGroup: (group: string) => `3rd of Group ${group}`,
|
||||
thirdPlacePool: (pool: string) => `3rd ${pool}`,
|
||||
},
|
||||
table: {
|
||||
rank: "#",
|
||||
team: "Team",
|
||||
group: "Group",
|
||||
matches: "GP",
|
||||
won: "W",
|
||||
drawn: "D",
|
||||
lost: "L",
|
||||
goals: "Goals",
|
||||
goalDiff: "±",
|
||||
points: "Pts",
|
||||
status: "Status",
|
||||
},
|
||||
thirds: {
|
||||
explanation:
|
||||
"Eight of the twelve group third-placed teams advance to the Round of 32. Ranking is across all groups by points, goal difference and goals scored — head-to-head does not apply because these teams have never met. The separator marks the cut between 8th and 9th place.",
|
||||
advances: "advances",
|
||||
eliminated: "out",
|
||||
},
|
||||
fixtures: {
|
||||
standingsTitle: (group: string) => `Standings – Group ${group}`,
|
||||
noMatches: (group: string) =>
|
||||
`No matches available yet for Group ${group}.`,
|
||||
},
|
||||
groups: {
|
||||
viewGroupGames: (group: string) => `View Group ${group} matches`,
|
||||
groupLabel: (group: string) => `Group ${group}`,
|
||||
viewGames: "View matches →",
|
||||
},
|
||||
};
|
||||
|
||||
export default en;
|
||||
11
lib/i18n/index.ts
Normal file
11
lib/i18n/index.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
import { Locale, Dictionary } from "./types";
|
||||
import de from "./de";
|
||||
import en from "./en";
|
||||
|
||||
export const dictionaries: Record<Locale, Dictionary> = { de, en };
|
||||
|
||||
export function getDictionary(locale: Locale): Dictionary {
|
||||
return dictionaries[locale] ?? en;
|
||||
}
|
||||
|
||||
export { type Locale, type Dictionary } from "./types";
|
||||
130
lib/i18n/types.ts
Normal file
130
lib/i18n/types.ts
Normal file
@@ -0,0 +1,130 @@
|
||||
export type Locale = "de" | "en";
|
||||
|
||||
export interface Dictionary {
|
||||
meta: {
|
||||
title: string;
|
||||
description: string;
|
||||
};
|
||||
header: {
|
||||
hostCountries: string;
|
||||
};
|
||||
status: {
|
||||
feedOffline: string;
|
||||
updated: (time: string) => string;
|
||||
live: string;
|
||||
loading: string;
|
||||
running: string;
|
||||
halftime: string;
|
||||
finished: string;
|
||||
postponed: string;
|
||||
};
|
||||
nav: {
|
||||
koFixtures: string;
|
||||
groups: string;
|
||||
groupFixtures: (group: string) => string;
|
||||
groupFixturesNoGroup: string;
|
||||
thirdPlace: string;
|
||||
bracket: string;
|
||||
simulation: string;
|
||||
};
|
||||
error: {
|
||||
feedUnreachable: string;
|
||||
unknown: string;
|
||||
};
|
||||
footer: {
|
||||
dashboard: string;
|
||||
dataSources: string;
|
||||
};
|
||||
sim: {
|
||||
notice: string;
|
||||
heading: string;
|
||||
};
|
||||
koFixtures: {
|
||||
noMatches: string;
|
||||
liveBadge: string;
|
||||
nextMatch: string;
|
||||
postponedBadge: string;
|
||||
match: (n: number) => string;
|
||||
};
|
||||
label: {
|
||||
goals: string;
|
||||
liveIndicator: string;
|
||||
scrollToTop: string;
|
||||
securelyQualified: string;
|
||||
};
|
||||
stage: {
|
||||
r16: string;
|
||||
qf: string;
|
||||
sf: string;
|
||||
thirdPlace: string;
|
||||
final: string;
|
||||
};
|
||||
round: {
|
||||
r32: string;
|
||||
r16: string;
|
||||
qf: string;
|
||||
sf: string;
|
||||
final: string;
|
||||
thirdPlace: string;
|
||||
};
|
||||
bracket: {
|
||||
provisionalTooltip: string;
|
||||
match: (n: number) => string;
|
||||
penaltyShootout: string;
|
||||
annexHeader: string;
|
||||
annexResolved: string;
|
||||
annexPending: string;
|
||||
winner: string;
|
||||
loser: string;
|
||||
winnerFromMatch: (n: number) => string;
|
||||
loserFromMatch: (n: number) => string;
|
||||
};
|
||||
legend: {
|
||||
winner: string;
|
||||
final: string;
|
||||
fixed: string;
|
||||
provisional: string;
|
||||
placeholder: string;
|
||||
probExplanation: string;
|
||||
};
|
||||
tooltips: {
|
||||
provisionalPrefix: string;
|
||||
firstOfGroup: (group: string) => string;
|
||||
secondOfGroup: (group: string) => string;
|
||||
thirdOfGroup: (group: string) => string;
|
||||
provisionalThird: (pool: string) => string;
|
||||
};
|
||||
slot: {
|
||||
winner: (group: string) => string;
|
||||
runnerUp: (group: string) => string;
|
||||
thirdOfGroup: (group: string) => string;
|
||||
thirdPlacePool: (pool: string) => string;
|
||||
};
|
||||
table: {
|
||||
rank: string;
|
||||
team: string;
|
||||
group: string;
|
||||
matches: string;
|
||||
won: string;
|
||||
drawn: string;
|
||||
lost: string;
|
||||
goals: string;
|
||||
goalDiff: string;
|
||||
points: string;
|
||||
status: string;
|
||||
};
|
||||
thirds: {
|
||||
explanation: string;
|
||||
advances: string;
|
||||
eliminated: string;
|
||||
};
|
||||
fixtures: {
|
||||
standingsTitle: (group: string) => string;
|
||||
noMatches: (group: string) => string;
|
||||
};
|
||||
groups: {
|
||||
viewGroupGames: (group: string) => string;
|
||||
groupLabel: (group: string) => string;
|
||||
viewGames: string;
|
||||
};
|
||||
}
|
||||
@@ -4,6 +4,8 @@ import {
|
||||
ThirdAssignment, slotLabel,
|
||||
} from "@/lib/bracket";
|
||||
import { placeIsSecure } from "@/lib/secure-places";
|
||||
import { thirdSlotIsSecure, securelyQualifiedThirdTeams } from "@/lib/third-place-security";
|
||||
import { Dictionary } from "@/lib/i18n";
|
||||
|
||||
// Ein aufgelöster Teilnehmer einer K.o.-Begegnung.
|
||||
export interface ResolvedSide {
|
||||
@@ -23,6 +25,8 @@ export interface ResolvedTie {
|
||||
away: ResolvedSide;
|
||||
status: string;
|
||||
prob?: { home: number; draw: number | null; away: number } | null;
|
||||
homePenalty?: number | null;
|
||||
awayPenalty?: number | null;
|
||||
}
|
||||
|
||||
// Findet das tatsächliche Spiel (aus dem Feed) zu einer FIFA-Match-Nummer.
|
||||
@@ -33,28 +37,42 @@ function feedMatch(matches: Match[], num: number): Match | undefined {
|
||||
// Bestimmt den Sieger eines abgeschlossenen Spiels (Feed) als Team-ID.
|
||||
function winnerOf(m: Match | undefined): string | null {
|
||||
if (!m || m.status !== "FINISHED") return null;
|
||||
if (m.winnerTeamId) return m.winnerTeamId;
|
||||
if (m.homeScore == null || m.awayScore == null) return null;
|
||||
if (m.homeScore > m.awayScore) return m.homeTeamId;
|
||||
if (m.awayScore > m.homeScore) return m.awayTeamId;
|
||||
return null; // Unentschieden -> Elfmeter; Feed liefert i.d.R. Sieger separat
|
||||
return null;
|
||||
}
|
||||
// Bestimmt im Sim-Modus die Sieger-Slot-ID.
|
||||
// Real gespielte Spiele: echtes winnerTeamId (inkl. Elfmeter) auf die
|
||||
// aufgelöste Slot-Seite mappen. Simulierte Spiele: Score-Vergleich.
|
||||
function simWinnerSlotId(feed: Match, homeSlotId: string, awaySlotId: string): string {
|
||||
if (feed.status === "FINISHED" && feed.winnerTeamId) {
|
||||
if (feed.winnerTeamId === homeSlotId) return homeSlotId;
|
||||
if (feed.winnerTeamId === awaySlotId) return awaySlotId;
|
||||
if (feed.homePenalty != null && feed.awayPenalty != null
|
||||
&& feed.homePenalty !== feed.awayPenalty) {
|
||||
return feed.homePenalty > feed.awayPenalty ? homeSlotId : awaySlotId;
|
||||
}
|
||||
}
|
||||
if (feed.homeScore != null && feed.awayScore != null) {
|
||||
if (feed.homeScore > feed.awayScore) return homeSlotId;
|
||||
if (feed.awayScore > feed.homeScore) return awaySlotId;
|
||||
}
|
||||
return homeSlotId;
|
||||
}
|
||||
|
||||
function loserOf(m: Match | undefined): string | null {
|
||||
if (!m || m.status !== "FINISHED") return null;
|
||||
if (m.winnerTeamId) {
|
||||
return m.homeTeamId === m.winnerTeamId ? m.awayTeamId : m.homeTeamId;
|
||||
}
|
||||
if (m.homeScore == null || m.awayScore == null) return null;
|
||||
if (m.homeScore > m.awayScore) return m.awayTeamId;
|
||||
if (m.awayScore > m.homeScore) return m.homeTeamId;
|
||||
return null;
|
||||
}
|
||||
|
||||
// Prüft, ob die gesamte Gruppenphase abgeschlossen ist.
|
||||
// Erst dann stehen die Drittplatzierten-Rangliste und die
|
||||
// Annex-C-Zuordnung final fest.
|
||||
function groupStageComplete(matches: Match[]): boolean {
|
||||
const groupMatches = matches.filter((m) => m.group != null);
|
||||
if (groupMatches.length === 0) return false;
|
||||
return groupMatches.every((m) => m.status === "FINISHED");
|
||||
}
|
||||
|
||||
// Löst einen R32-Slot (W/R/3) zu einer Team-ID auf, sofern bereits bekannt.
|
||||
// provisional = true, solange die zugrunde liegende Gruppe/Zuordnung nicht fix ist.
|
||||
function resolveR32Slot(
|
||||
@@ -66,46 +84,52 @@ function resolveR32Slot(
|
||||
matches: Match[],
|
||||
teams: Team[],
|
||||
annexResolved: boolean,
|
||||
secureTeamIds: Set<string>,
|
||||
dict?: Dictionary,
|
||||
): { teamId: string | null; provisional: boolean; tooltip: string | null } {
|
||||
const t = dict?.tooltips;
|
||||
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;
|
||||
const tab = table(slot.group!);
|
||||
const teamId = tab?.rows.find((r) => r.rank === 1)?.teamId ?? null;
|
||||
// Sieger fix, sobald Platz 1 rechnerisch gesichert ist (auch vor Gruppenende).
|
||||
const provisional = !placeIsSecure(slot.group!, 1, teams, matches);
|
||||
const prefix = provisional ? "aktuell " : "";
|
||||
return { teamId, provisional, tooltip: `${prefix}1. Gruppe ${slot.group}` };
|
||||
const prefix = provisional ? (t?.provisionalPrefix ?? "aktuell") + " " : "";
|
||||
return { teamId, provisional, tooltip: `${prefix}${t?.firstOfGroup(slot.group!) ?? `1. Gruppe ${slot.group}`}` };
|
||||
}
|
||||
if (slot.type === "R") {
|
||||
const t = table(slot.group!);
|
||||
const teamId = t?.rows.find((r) => r.rank === 2)?.teamId ?? null;
|
||||
const tab = table(slot.group!);
|
||||
const teamId = tab?.rows.find((r) => r.rank === 2)?.teamId ?? null;
|
||||
// Zweiter fix, sobald Platz 2 rechnerisch gesichert ist.
|
||||
const provisional = !placeIsSecure(slot.group!, 2, teams, matches);
|
||||
const prefix = provisional ? "aktuell " : "";
|
||||
return { teamId, provisional, tooltip: `${prefix}2. Gruppe ${slot.group}` };
|
||||
const prefix = provisional ? (t?.provisionalPrefix ?? "aktuell") + " " : "";
|
||||
return { teamId, provisional, tooltip: `${prefix}${t?.secondOfGroup(slot.group!) ?? `2. Gruppe ${slot.group}`}` };
|
||||
}
|
||||
// 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 ALLE drei Bedingungen erfüllt sind:
|
||||
// Fix nur, wenn ALLE Bedingungen erfüllt sind:
|
||||
// 1. Annex C aufgelöst (8 Dritte zuweisbar)
|
||||
// 2. Komplette Gruppenphase beendet (Dritten-Rangliste final)
|
||||
// 3. Das Team gehört gesichert zu den besten 8
|
||||
const fix = annexResolved && groupStageComplete(matches) && row?.qualifies === true;
|
||||
// 2. Der Slot ist in allen noch möglichen Konstellationen stabil
|
||||
// 3. Das konkrete Team ist sicher qualifiziert (kann nicht aus Top 8 fallen)
|
||||
// 4. Die Gruppe hat alle Spiele gespielt (Team bekannt)
|
||||
const slotStable = thirdSlotIsSecure(winnerGroup, matches, teams);
|
||||
const teamSecure = row?.teamId ? secureTeamIds.has(row.teamId) : false;
|
||||
const fix = annexResolved && slotStable && teamSecure && row?.qualifies === true;
|
||||
const provisional = !fix;
|
||||
const prefix = provisional ? "aktuell " : "";
|
||||
const prefix = provisional ? (t?.provisionalPrefix ?? "aktuell") + " " : "";
|
||||
return {
|
||||
teamId: row?.teamId ?? null,
|
||||
provisional,
|
||||
tooltip: `${prefix}3. der Gruppe ${thirdGroup}`,
|
||||
tooltip: `${prefix}${t?.thirdOfGroup(thirdGroup) ?? `3. der Gruppe ${thirdGroup}`}`,
|
||||
};
|
||||
}
|
||||
}
|
||||
if (slot.type === "3") {
|
||||
const pool = slot.thirdPool?.join("") ?? "?";
|
||||
return { teamId: null, provisional: true, tooltip: `aktuell 3. Gruppe ${pool}` };
|
||||
return { teamId: null, provisional: true, tooltip: t?.provisionalThird(pool) ?? `aktuell 3. Gruppe ${pool}` };
|
||||
}
|
||||
return { teamId: null, provisional: true, tooltip: null };
|
||||
}
|
||||
@@ -142,12 +166,16 @@ export function resolveBracket(
|
||||
thirds: ThirdPlaceRow[], assignment: ThirdAssignment | null,
|
||||
annexResolved: boolean,
|
||||
resolveWinners = false,
|
||||
dict?: Dictionary,
|
||||
): { r32: ResolvedTie[]; later: Record<number, ResolvedTie> } {
|
||||
// Map: Match-Nummer -> Sieger-Team-ID (für Propagation in Folgerunden)
|
||||
const winners = new Map<number, string | null>();
|
||||
const losers = new Map<number, string | null>();
|
||||
// Map: Match-Nummer -> ist das Spiel beendet (Sieger fix)?
|
||||
const decided = new Map<number, boolean>();
|
||||
const secureTeamIds = securelyQualifiedThirdTeams(matches, teams);
|
||||
|
||||
const b = dict?.bracket;
|
||||
|
||||
const r32: ResolvedTie[] = R32.map((rm: R32Match) => {
|
||||
const feed = feedMatch(matches, rm.matchNumber);
|
||||
@@ -156,26 +184,18 @@ 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, 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, h.tooltip);
|
||||
const away = sideFrom(a.teamId, slotLabel(rm.away, assignment, winnerGroup), teams, feed, "away", a.provisional, a.tooltip);
|
||||
const h = resolveR32Slot(rm.home, winnerGroup, tables, assignment, thirds, matches, teams, annexResolved, secureTeamIds, dict);
|
||||
const a = resolveR32Slot(rm.away, winnerGroup, tables, assignment, thirds, matches, teams, annexResolved, secureTeamIds, dict);
|
||||
const home = sideFrom(h.teamId, slotLabel(rm.home, assignment, winnerGroup, dict), teams, feed, "home", h.provisional, h.tooltip);
|
||||
const away = sideFrom(a.teamId, slotLabel(rm.away, assignment, winnerGroup, dict), teams, feed, "away", a.provisional, a.tooltip);
|
||||
|
||||
const feedWinner = winnerOf(feed);
|
||||
if (resolveWinners && !feedWinner && feed && h.teamId && a.teamId
|
||||
if (resolveWinners && feed && h.teamId && a.teamId
|
||||
&& feed.homeScore != null && feed.awayScore != null) {
|
||||
// Simulation: Gewinner aus Scores und aufgelösten Team-IDs ableiten
|
||||
if (feed.homeScore > feed.awayScore) {
|
||||
winners.set(rm.matchNumber, h.teamId);
|
||||
losers.set(rm.matchNumber, loserOf(feed) ?? a.teamId);
|
||||
} else if (feed.awayScore > feed.homeScore) {
|
||||
winners.set(rm.matchNumber, a.teamId);
|
||||
losers.set(rm.matchNumber, loserOf(feed) ?? h.teamId);
|
||||
} else {
|
||||
// Unentschieden → Heim gewinnt
|
||||
winners.set(rm.matchNumber, h.teamId);
|
||||
losers.set(rm.matchNumber, loserOf(feed) ?? a.teamId);
|
||||
}
|
||||
const winnerId = simWinnerSlotId(feed, h.teamId, a.teamId);
|
||||
const loserId = winnerId === h.teamId ? a.teamId : h.teamId;
|
||||
winners.set(rm.matchNumber, winnerId);
|
||||
losers.set(rm.matchNumber, loserId);
|
||||
} else {
|
||||
winners.set(rm.matchNumber, feedWinner);
|
||||
losers.set(rm.matchNumber, loserOf(feed));
|
||||
@@ -184,6 +204,7 @@ export function resolveBracket(
|
||||
return {
|
||||
matchNumber: rm.matchNumber, stage: "R32",
|
||||
home, away, status: feed?.status ?? "SCHEDULED", prob: feed?.prob,
|
||||
homePenalty: feed?.homePenalty, awayPenalty: feed?.awayPenalty,
|
||||
};
|
||||
});
|
||||
|
||||
@@ -193,29 +214,44 @@ export function resolveBracket(
|
||||
const src = km.losers ? losers : winners;
|
||||
const homeId = src.get(km.fromHome) ?? null;
|
||||
const awayId = src.get(km.fromAway) ?? null;
|
||||
if (km.matchNumber === 89 || km.matchNumber === 90) {
|
||||
console.log("[PROPAGATE-R16]", {
|
||||
zielSlot: km.matchNumber,
|
||||
fromHome: km.fromHome,
|
||||
fromAway: km.fromAway,
|
||||
homeIdAusWinners: homeId,
|
||||
awayIdAusWinners: awayId,
|
||||
homeIdAusLosers: losers.get(km.fromHome) ?? null,
|
||||
awayIdAusLosers: losers.get(km.fromAway) ?? null,
|
||||
});
|
||||
}
|
||||
|
||||
// Ein Folgeteam ist fix, wenn das speisende Spiel beendet ist.
|
||||
const homeProv = !(decided.get(km.fromHome) ?? false);
|
||||
const awayProv = !(decided.get(km.fromAway) ?? false);
|
||||
const homeLabel = `${km.losers ? "Verlierer" : "Sieger"} ${km.fromHome}`;
|
||||
const awayLabel = `${km.losers ? "Verlierer" : "Sieger"} ${km.fromAway}`;
|
||||
const homeTtip = `${km.losers ? "Verlierer" : "Sieger"} aus Spiel ${km.fromHome}`;
|
||||
const awayTtip = `${km.losers ? "Verlierer" : "Sieger"} aus Spiel ${km.fromAway}`;
|
||||
const loserLabel = km.losers ? true : false;
|
||||
const homeLabel = loserLabel
|
||||
? (b?.loser ?? "Verlierer") + " " + km.fromHome
|
||||
: (b?.winner ?? "Sieger") + " " + km.fromHome;
|
||||
const awayLabel = loserLabel
|
||||
? (b?.loser ?? "Verlierer") + " " + km.fromAway
|
||||
: (b?.winner ?? "Sieger") + " " + km.fromAway;
|
||||
const homeTtip = loserLabel
|
||||
? (b?.loserFromMatch(km.fromHome) ?? `Verlierer aus Spiel ${km.fromHome}`)
|
||||
: (b?.winnerFromMatch(km.fromHome) ?? `Sieger aus Spiel ${km.fromHome}`);
|
||||
const awayTtip = loserLabel
|
||||
? (b?.loserFromMatch(km.fromAway) ?? `Verlierer aus Spiel ${km.fromAway}`)
|
||||
: (b?.winnerFromMatch(km.fromAway) ?? `Sieger aus Spiel ${km.fromAway}`);
|
||||
const home = sideFrom(homeId, homeLabel, teams, feed, "home", homeProv, homeTtip);
|
||||
const away = sideFrom(awayId, awayLabel, teams, feed, "away", awayProv, awayTtip);
|
||||
|
||||
const feedWinner = winnerOf(feed);
|
||||
if (resolveWinners && !feedWinner && feed && homeId && awayId
|
||||
if (resolveWinners && feed && homeId && awayId
|
||||
&& feed.homeScore != null && feed.awayScore != null) {
|
||||
if (feed.homeScore > feed.awayScore) {
|
||||
winners.set(km.matchNumber, homeId);
|
||||
losers.set(km.matchNumber, loserOf(feed) ?? awayId);
|
||||
} else if (feed.awayScore > feed.homeScore) {
|
||||
winners.set(km.matchNumber, awayId);
|
||||
losers.set(km.matchNumber, loserOf(feed) ?? homeId);
|
||||
} else {
|
||||
winners.set(km.matchNumber, homeId);
|
||||
losers.set(km.matchNumber, loserOf(feed) ?? awayId);
|
||||
}
|
||||
const winnerId = simWinnerSlotId(feed, homeId, awayId);
|
||||
const loserId = winnerId === homeId ? awayId : homeId;
|
||||
winners.set(km.matchNumber, winnerId);
|
||||
losers.set(km.matchNumber, loserId);
|
||||
} else {
|
||||
winners.set(km.matchNumber, feedWinner);
|
||||
losers.set(km.matchNumber, loserOf(feed));
|
||||
@@ -224,6 +260,7 @@ export function resolveBracket(
|
||||
later[km.matchNumber] = {
|
||||
matchNumber: km.matchNumber, stage: km.stage,
|
||||
home, away, status: feed?.status ?? "SCHEDULED", prob: feed?.prob,
|
||||
homePenalty: feed?.homePenalty, awayPenalty: feed?.awayPenalty,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
74
lib/stadiums.ts
Normal file
74
lib/stadiums.ts
Normal file
@@ -0,0 +1,74 @@
|
||||
// Statische Stadion-Daten für WM 2026.
|
||||
export const STADIUMS: Record<string, { name: string; city: string }> = {
|
||||
"1": { name: "Estadio Azteca", city: "Mexico City" },
|
||||
"2": { name: "Estadio Akron", city: "Guadalajara" },
|
||||
"3": { name: "Estadio BBVA", city: "Monterrey" },
|
||||
"4": { name: "AT&T Stadium", city: "Dallas" },
|
||||
"5": { name: "NRG Stadium", city: "Houston" },
|
||||
"6": { name: "GEHA Field at Arrowhead Stadium", city: "Kansas City" },
|
||||
"7": { name: "Mercedes-Benz Stadium", city: "Atlanta" },
|
||||
"8": { name: "Hard Rock Stadium", city: "Miami" },
|
||||
"9": { name: "Gillette Stadium", city: "Boston" },
|
||||
"10": { name: "Lincoln Financial Field", city: "Philadelphia" },
|
||||
"11": { name: "MetLife Stadium", city: "New York/New Jersey" },
|
||||
"12": { name: "BMO Field", city: "Toronto" },
|
||||
"13": { name: "BC Place", city: "Vancouver" },
|
||||
"14": { name: "Lumen Field", city: "Seattle" },
|
||||
"15": { name: "Levi's Stadium", city: "San Francisco Bay Area" },
|
||||
"16": { name: "SoFi Stadium", city: "Los Angeles" },
|
||||
};
|
||||
|
||||
// K.o.-Spielnummer → ISO-8601 UTC-Anstoßzeit (FIFA-Spielplan, statisch).
|
||||
export const MATCH_DATES: Record<number, string> = {
|
||||
// Letzte 32 (28.06. - 03.07.)
|
||||
73: "2026-06-28T19:00:00Z", // 28.06. 14:00
|
||||
74: "2026-06-29T20:30:00Z", // 29.06. 15:30
|
||||
75: "2026-06-30T01:00:00Z", // 29.06. 20:00 (UTC nächster Tag)
|
||||
76: "2026-06-29T17:00:00Z", // 29.06. 12:00
|
||||
77: "2026-06-30T21:00:00Z", // 30.06. 16:00
|
||||
78: "2026-06-30T17:00:00Z", // 30.06. 12:00
|
||||
79: "2026-07-01T01:00:00Z", // 30.06. 20:00 (UTC nächster Tag)
|
||||
80: "2026-07-01T16:00:00Z", // 01.07. 11:00
|
||||
81: "2026-07-02T00:00:00Z", // 01.07. 19:00 (UTC nächster Tag)
|
||||
82: "2026-07-01T20:00:00Z", // 01.07. 15:00
|
||||
83: "2026-07-02T23:00:00Z", // 02.07. 18:00
|
||||
84: "2026-07-02T19:00:00Z", // 02.07. 14:00
|
||||
85: "2026-07-03T03:00:00Z", // 02.07. 22:00 (UTC nächster Tag)
|
||||
86: "2026-07-03T22:00:00Z", // 03.07. 17:00
|
||||
87: "2026-07-04T01:30:00Z", // 03.07. 20:30 (UTC nächster Tag)
|
||||
88: "2026-07-03T18:00:00Z", // 03.07. 13:00
|
||||
|
||||
// Achtelfinale (04.07. - 07.07.)
|
||||
89: "2026-07-04T21:00:00Z", // 04.07. 16:00
|
||||
90: "2026-07-04T17:00:00Z", // 04.07. 12:00
|
||||
91: "2026-07-05T20:00:00Z", // 05.07. 15:00
|
||||
92: "2026-07-06T00:00:00Z", // 05.07. 19:00 (UTC nächster Tag)
|
||||
93: "2026-07-06T19:00:00Z", // 06.07. 14:00
|
||||
94: "2026-07-07T00:00:00Z", // 06.07. 19:00 (UTC nächster Tag)
|
||||
95: "2026-07-07T16:00:00Z", // 07.07. 11:00
|
||||
96: "2026-07-07T20:00:00Z", // 07.07. 15:00
|
||||
|
||||
// Viertelfinale (09.07. - 11.07.)
|
||||
97: "2026-07-09T20:00:00Z", // 09.07. 15:00
|
||||
98: "2026-07-10T19:00:00Z", // 10.07. 14:00
|
||||
99: "2026-07-11T21:00:00Z", // 11.07. 16:00
|
||||
100: "2026-07-12T01:00:00Z",// 11.07. 20:00 (UTC nächster Tag)
|
||||
|
||||
// Halbfinale (14.07. - 15.07.)
|
||||
101: "2026-07-14T19:00:00Z",// 14.07. 14:00
|
||||
102: "2026-07-15T19:00:00Z",// 15.07. 14:00
|
||||
|
||||
// Spiel um Platz 3 (18.07.)
|
||||
103: "2026-07-18T21:00:00Z",// 18.07. 16:00
|
||||
|
||||
// Finale (19.07.)
|
||||
104: "2026-07-19T19:00:00Z",// 19.07. 14:00
|
||||
};
|
||||
|
||||
// K.o.-Spielnummer → stadium_id (FIFA-Quelle, statisch).
|
||||
export const MATCH_STADIUMS: Record<number, string> = {
|
||||
73: "16", 74: "9", 75: "3", 76: "5", 77: "11", 78: "4", 79: "1", 80: "7",
|
||||
81: "15", 82: "14", 83: "12", 84: "16", 85: "13", 86: "8", 87: "6", 88: "4",
|
||||
89: "10", 90: "5", 91: "11", 92: "1", 93: "4", 94: "14", 95: "7", 96: "13",
|
||||
97: "9", 98: "16", 99: "8", 100: "6", 101: "4", 102: "7", 103: "8", 104: "11",
|
||||
};
|
||||
252
lib/third-place-security.ts
Normal file
252
lib/third-place-security.ts
Normal file
@@ -0,0 +1,252 @@
|
||||
import { GroupId, GROUP_IDS, Match, Team } from "./types";
|
||||
import { computeGroupTables, computeThirdPlaceTable } from "./standings";
|
||||
import { resolveAnnexC, qualifiedThirdGroups } from "./bracket";
|
||||
|
||||
// Repräsentative Ergebnis-Varianten je Restspiel (decken alle Punktkombinationen ab).
|
||||
const OUTCOMES: Array<[number, number]> = [
|
||||
[1, 0], // Heimsieg
|
||||
[0, 1], // Auswärtssieg
|
||||
[0, 0], // Unentschieden
|
||||
];
|
||||
|
||||
interface ThirdInfo {
|
||||
teamId: string;
|
||||
points: number;
|
||||
goalsFor: number;
|
||||
goalsAgainst: number;
|
||||
goalDiff: number;
|
||||
}
|
||||
|
||||
interface GroupThirdState {
|
||||
finished: boolean;
|
||||
third: ThirdInfo | null;
|
||||
minPoints: number;
|
||||
maxPoints: number;
|
||||
possibleTeamIds: Set<string>;
|
||||
}
|
||||
|
||||
function openMatches(group: GroupId, matches: Match[]): Match[] {
|
||||
return matches.filter(
|
||||
(m) => m.group === group && m.status !== "FINISHED"
|
||||
&& m.homeTeamId != null && m.awayTeamId != null,
|
||||
);
|
||||
}
|
||||
|
||||
function enumerateThirdPossibilities(
|
||||
group: GroupId, teams: Team[], matches: Match[],
|
||||
): { minPoints: number; maxPoints: number; teamIds: Set<string> } {
|
||||
const open = openMatches(group, matches);
|
||||
const played = matches.filter(
|
||||
(m) => m.group === group && (m.status === "FINISHED" || m.homeTeamId == null || m.awayTeamId == null),
|
||||
);
|
||||
|
||||
let minP = Infinity, maxP = -Infinity;
|
||||
const teamIds = new Set<string>();
|
||||
|
||||
if (open.length === 0) {
|
||||
const table = computeGroupTables(teams, matches).find((t) => t.group === group);
|
||||
const third = table?.rows.find((r) => r.rank === 3);
|
||||
if (third) { minP = maxP = third.points; teamIds.add(third.teamId); }
|
||||
return { minPoints: minP, maxPoints: maxP, teamIds };
|
||||
}
|
||||
|
||||
const totalCombos = Math.pow(OUTCOMES.length, open.length);
|
||||
if (totalCombos > 500) return { minPoints: 0, maxPoints: 9, teamIds };
|
||||
|
||||
for (let combo = 0; combo < totalCombos; combo++) {
|
||||
let c = combo;
|
||||
const simulated: Match[] = open.map((m) => {
|
||||
const variantIdx = c % OUTCOMES.length;
|
||||
c = Math.floor(c / OUTCOMES.length);
|
||||
const [hg, ag] = OUTCOMES[variantIdx];
|
||||
return { ...m, status: "FINISHED" as const, homeScore: hg, awayScore: ag };
|
||||
});
|
||||
const all = [...played, ...simulated];
|
||||
const table = computeGroupTables(teams, all).find((t) => t.group === group);
|
||||
const third = table?.rows.find((r) => r.rank === 3);
|
||||
if (third) { minP = Math.min(minP, third.points); maxP = Math.max(maxP, third.points); teamIds.add(third.teamId); }
|
||||
}
|
||||
|
||||
return { minPoints: minP === Infinity ? 0 : minP, maxPoints: maxP === -Infinity ? 9 : maxP, teamIds };
|
||||
}
|
||||
|
||||
function buildThirdStates(matches: Match[], teams: Team[]): Map<GroupId, GroupThirdState> {
|
||||
const states = new Map<GroupId, GroupThirdState>();
|
||||
for (const g of GROUP_IDS) {
|
||||
const gm = matches.filter((m) => m.group === g);
|
||||
const allDone = gm.length > 0 && gm.every((m) => m.status === "FINISHED");
|
||||
const table = computeGroupTables(teams, matches).find((t) => t.group === g);
|
||||
const thirdRow = table?.rows.find((r) => r.rank === 3);
|
||||
let third: ThirdInfo | null = null;
|
||||
if (thirdRow) third = { teamId: thirdRow.teamId, points: thirdRow.points, goalsFor: thirdRow.goalsFor, goalsAgainst: thirdRow.goalsAgainst, goalDiff: thirdRow.goalDiff };
|
||||
if (allDone && third) {
|
||||
states.set(g, { finished: true, third, minPoints: third.points, maxPoints: third.points, possibleTeamIds: new Set([third.teamId]) });
|
||||
} else {
|
||||
const { minPoints, maxPoints, teamIds } = enumerateThirdPossibilities(g, teams, matches);
|
||||
states.set(g, { finished: false, third, minPoints, maxPoints, possibleTeamIds: teamIds });
|
||||
}
|
||||
}
|
||||
return states;
|
||||
}
|
||||
|
||||
function classifyGroups(states: Map<GroupId, GroupThirdState>): {
|
||||
lockedIn: Set<GroupId>; lockedOut: Set<GroupId>; contested: Set<GroupId>;
|
||||
} {
|
||||
const lockedIn = new Set<GroupId>();
|
||||
const lockedOut = new Set<GroupId>();
|
||||
const contested = new Set<GroupId>();
|
||||
|
||||
for (const g of GROUP_IDS) {
|
||||
const st = states.get(g)!;
|
||||
if (st.finished && !st.third) { lockedOut.add(g); continue; }
|
||||
|
||||
let countCouldBeBetter = 0;
|
||||
for (const other of GROUP_IDS) {
|
||||
if (other === g) continue;
|
||||
const os = states.get(other)!;
|
||||
if (os.maxPoints > st.minPoints) countCouldBeBetter++;
|
||||
else if (os.maxPoints === st.minPoints && !st.finished && os.finished) countCouldBeBetter++;
|
||||
}
|
||||
const alwaysTop8 = countCouldBeBetter <= 7;
|
||||
|
||||
let countDefinitelyBetter = 0;
|
||||
for (const other of GROUP_IDS) {
|
||||
if (other === g) continue;
|
||||
const os = states.get(other)!;
|
||||
if (os.minPoints > st.maxPoints) countDefinitelyBetter++;
|
||||
else if (os.minPoints === st.maxPoints && os.finished && !st.finished) countDefinitelyBetter++;
|
||||
}
|
||||
const neverTop8 = countDefinitelyBetter >= 8;
|
||||
|
||||
if (alwaysTop8) lockedIn.add(g);
|
||||
else if (neverTop8) lockedOut.add(g);
|
||||
else contested.add(g);
|
||||
}
|
||||
return { lockedIn, lockedOut, contested };
|
||||
}
|
||||
|
||||
// --- Public API ---
|
||||
|
||||
// Liefert die Team-IDs der Dritten, die mathematisch sicher unter den Top 8
|
||||
// der gruppenübergreifenden Dritten-Tabelle sind. Prüft für jedes Team aus
|
||||
// einer FERTIGEN Gruppe (played === 3), ob es in ALLEN noch möglichen
|
||||
// Restspiel-Konstellationen von maximal 7 anderen Dritten überholt werden kann.
|
||||
export function securelyQualifiedThirdTeams(matches: Match[], teams: Team[]): Set<string> {
|
||||
const states = buildThirdStates(matches, teams);
|
||||
const secureTeams = new Set<string>();
|
||||
|
||||
for (const g of GROUP_IDS) {
|
||||
const st = states.get(g)!;
|
||||
if (!st.finished || !st.third || st.possibleTeamIds.size !== 1) continue;
|
||||
|
||||
const my = st.third;
|
||||
let couldBeBetter = 0;
|
||||
for (const og of GROUP_IDS) {
|
||||
if (og === g) continue;
|
||||
const os = states.get(og)!;
|
||||
if (os.finished && os.third) {
|
||||
if (os.third.points > my.points) couldBeBetter++;
|
||||
else if (os.third.points === my.points && os.third.goalDiff > my.goalDiff) couldBeBetter++;
|
||||
else if (os.third.points === my.points && os.third.goalDiff === my.goalDiff && os.third.goalsFor > my.goalsFor) couldBeBetter++;
|
||||
} else {
|
||||
if (os.maxPoints > my.points) couldBeBetter++;
|
||||
else if (os.maxPoints === my.points && !os.finished) couldBeBetter++;
|
||||
}
|
||||
}
|
||||
|
||||
if (couldBeBetter <= 7) secureTeams.add(my.teamId);
|
||||
}
|
||||
|
||||
return secureTeams;
|
||||
}
|
||||
|
||||
// Liefert die Gruppen, deren Dritter mathematisch sicher unter den Top 8 ist.
|
||||
// (Gruppen-Ebene — für Fix-Markierung im Baum, nicht für Team-Häkchen.)
|
||||
export function securelyQualifiedThirdGroups(matches: Match[], teams: Team[]): GroupId[] {
|
||||
const states = buildThirdStates(matches, teams);
|
||||
const { lockedIn } = classifyGroups(states);
|
||||
return [...lockedIn];
|
||||
}
|
||||
|
||||
// Prüft, ob ein bestimmter Dritten-Slot (Gegner des Siegers von `winnerGroup`)
|
||||
// in ALLEN noch möglichen Konstellationen identisch bleibt.
|
||||
export function thirdSlotIsSecure(winnerGroup: GroupId, matches: Match[], teams: Team[]): boolean {
|
||||
const states = buildThirdStates(matches, teams);
|
||||
const { lockedIn, contested } = classifyGroups(states);
|
||||
|
||||
if (lockedIn.size > 8) {
|
||||
// Alle Gruppen fertig oder zu viele lockedIn → die 8 tatsächlich qualifizierten
|
||||
// Dritten bestimmen (nicht die 12 lockedIn-Gruppen).
|
||||
const tables = computeGroupTables(teams, matches);
|
||||
const thirds = computeThirdPlaceTable(tables);
|
||||
const qGroups = qualifiedThirdGroups(thirds);
|
||||
if (qGroups.length !== 8) return false;
|
||||
const assignment = resolveAnnexC(qGroups);
|
||||
if (!assignment) return false;
|
||||
const ag = assignment[winnerGroup];
|
||||
if (!ag) return false;
|
||||
const ss = states.get(ag);
|
||||
if (!ss) return false;
|
||||
return ss.finished && ss.third != null && ss.possibleTeamIds.size === 1;
|
||||
}
|
||||
|
||||
if (lockedIn.size === 8) {
|
||||
const assignment = resolveAnnexC([...lockedIn]);
|
||||
if (!assignment) return false;
|
||||
const ag = assignment[winnerGroup];
|
||||
if (!ag) return false;
|
||||
const ss = states.get(ag);
|
||||
if (!ss) return false;
|
||||
const result = ss.finished && ss.third != null && ss.possibleTeamIds.size === 1;
|
||||
return result;
|
||||
}
|
||||
|
||||
if (lockedIn.size + contested.size < 8) return false;
|
||||
|
||||
const contestedArr = [...contested];
|
||||
const need = 8 - lockedIn.size;
|
||||
const combos = combinations(contestedArr.length, need);
|
||||
if (combos > 200) return false;
|
||||
|
||||
let stableGroup: GroupId | null = null;
|
||||
for (const indices of enumerateCombinations(contestedArr.length, need)) {
|
||||
const qGroups: GroupId[] = [...lockedIn, ...indices.map((i) => contestedArr[i])];
|
||||
if (qGroups.length !== 8) continue;
|
||||
const assignment = resolveAnnexC(qGroups);
|
||||
if (!assignment) continue;
|
||||
const ag = assignment[winnerGroup];
|
||||
if (!ag) return false;
|
||||
if (stableGroup === null) stableGroup = ag;
|
||||
else if (stableGroup !== ag) return false;
|
||||
}
|
||||
|
||||
if (stableGroup === null) return false;
|
||||
const ss = states.get(stableGroup);
|
||||
if (!ss) return false;
|
||||
const result = ss.finished && ss.third != null && ss.possibleTeamIds.size === 1;
|
||||
return result;
|
||||
}
|
||||
|
||||
// --- Combinatorics helpers ---
|
||||
|
||||
function combinations(n: number, k: number): number {
|
||||
if (k < 0 || k > n) return 0;
|
||||
if (k === 0 || k === n) return 1;
|
||||
let r = 1;
|
||||
for (let i = 1; i <= k; i++) r = r * (n - i + 1) / i;
|
||||
return Math.round(r);
|
||||
}
|
||||
|
||||
function* enumerateCombinations(n: number, k: number): Generator<number[]> {
|
||||
if (k === 0) { yield []; return; }
|
||||
if (k > n) return;
|
||||
const idx = Array.from({ length: k }, (_, i) => i);
|
||||
while (true) {
|
||||
yield [...idx];
|
||||
let i = k - 1;
|
||||
while (i >= 0 && idx[i] === n - k + i) i--;
|
||||
if (i < 0) break;
|
||||
idx[i]++;
|
||||
for (let j = i + 1; j < k; j++) idx[j] = idx[j - 1] + 1;
|
||||
}
|
||||
}
|
||||
19
lib/types.ts
19
lib/types.ts
@@ -16,10 +16,23 @@ export interface Team {
|
||||
group: GroupId;
|
||||
crest?: string | null; // URL zur Flagge / zum Wappen (football-data: crest)
|
||||
localisedName: string; // Lokalisierter Anzeigename (z.B. "Deutschland")
|
||||
localisedNames?: { de: string; en: string };
|
||||
}
|
||||
|
||||
export function teamName(team: Team | undefined, locale: string): string {
|
||||
if (!team) return "—";
|
||||
if (locale === "en") return team.localisedNames?.en ?? team.name ?? "—";
|
||||
return team.localisedNames?.de ?? team.name ?? "—";
|
||||
}
|
||||
|
||||
export type MatchStatus =
|
||||
| "SCHEDULED" | "LIVE" | "IN_PLAY" | "PAUSED" | "FINISHED";
|
||||
| "SCHEDULED" | "LIVE" | "IN_PLAY" | "PAUSED" | "FINISHED" | "POSTPONED";
|
||||
|
||||
export interface GoalEvent {
|
||||
scorer: string; // Torschützen-Name
|
||||
minute: string; // Spielminute (z.B. "72", "90+1")
|
||||
team: "home" | "away";
|
||||
}
|
||||
|
||||
export interface Match {
|
||||
id: string;
|
||||
@@ -33,10 +46,14 @@ export interface Match {
|
||||
awayTeamId: string | null;
|
||||
homeScore: number | null;
|
||||
awayScore: number | null;
|
||||
homePenalty?: number | null; // Elfmeterschießen (FIFA-API)
|
||||
awayPenalty?: number | null;
|
||||
winnerTeamId?: string | null; // FIFA-Winner (auch bei Elfmeterschießen)
|
||||
// Wahrscheinlichkeiten 0..1 (Polymarket), falls vorhanden
|
||||
prob?: { home: number; draw: number; away: number } | null;
|
||||
venue?: string | null; // Austragungsort
|
||||
attendance?: number | null; // Zuschauerzahl, falls verfügbar
|
||||
goals?: GoalEvent[] | null; // Torereignisse
|
||||
}
|
||||
|
||||
// Eine berechnete Tabellenzeile innerhalb einer Gruppe.
|
||||
|
||||
42
middleware.ts
Normal file
42
middleware.ts
Normal file
@@ -0,0 +1,42 @@
|
||||
import { NextResponse } from "next/server";
|
||||
import type { NextRequest } from "next/server";
|
||||
|
||||
const SUPPORTED_LOCALES = ["en", "de"] as const;
|
||||
|
||||
function getLocale(request: NextRequest): string {
|
||||
const acceptLang = request.headers.get("accept-language") ?? "";
|
||||
const preferred = acceptLang.split(",")[0]?.trim().slice(0, 2);
|
||||
if (preferred && SUPPORTED_LOCALES.includes(preferred as any)) return preferred;
|
||||
return "en";
|
||||
}
|
||||
|
||||
export function middleware(request: NextRequest) {
|
||||
const { pathname } = request.nextUrl;
|
||||
|
||||
// API routes and static files pass through
|
||||
if (
|
||||
pathname.startsWith("/api/") ||
|
||||
pathname.includes(".") ||
|
||||
pathname.startsWith("/_next")
|
||||
) {
|
||||
return NextResponse.next();
|
||||
}
|
||||
|
||||
// Check if pathname already has a supported locale
|
||||
const hasLocale = SUPPORTED_LOCALES.some(
|
||||
(l) => pathname === `/${l}` || pathname.startsWith(`/${l}/`),
|
||||
);
|
||||
|
||||
if (!hasLocale) {
|
||||
const locale = getLocale(request);
|
||||
const url = request.nextUrl.clone();
|
||||
url.pathname = `/${locale}${pathname === "/" ? "" : pathname}`;
|
||||
return NextResponse.redirect(url);
|
||||
}
|
||||
|
||||
return NextResponse.next();
|
||||
}
|
||||
|
||||
export const config = {
|
||||
matcher: ["/((?!_next|api|favicon.ico).*)"],
|
||||
};
|
||||
Reference in New Issue
Block a user