feat(mls): MLS 리그 추가 — ESPN 비공식 API 연동
- 일정·결과·컨퍼런스 순위·프리뷰(폼/시즌전적/맞대결/머니라인) 수집 - 라이브 카드: 스코어·경기시간·득점/카드·선발 라인업(피치 뷰)·교체 현황 - 문자중계: ESPN commentary 규칙 기반 한글 변환 (미지원 템플릿은 팀명만 한글화) - MLS 레코드는 야구와 키 구조가 같아 sync_baseball_schedule/settle 재사용 - AI 예측 데이터 블록에 MLS 전용 컨텍스트 추가 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
ad5bbec82e
commit
74de57fc1c
22 files changed
+1723
-83
No files matched your search
@@ -95,8 +95,11 @@ export default function Arena({
|
||||
const t = dict(lang);
|
||||
const aShort = teamShort(match.teamA, lang);
|
||||
const bShort = teamShort(match.teamB, lang);
|
||||
// 한국을 항상 왼쪽에 표시(요청). 상태·투표 제출은 원본 A/B 프레임 그대로, 화면 좌우만 교체.
|
||||
const flip = match.teamB.code === "KOR" && match.teamA.code !== "KOR";
|
||||
// 월드컵: 한국을 항상 왼쪽에. MLS: 홈 팀을 왼쪽에(축구 관례).
|
||||
// 상태·투표 제출은 원본 A/B 프레임 그대로, 화면 좌우만 교체.
|
||||
const flip =
|
||||
match.league === "mls" ||
|
||||
(match.teamB.code === "KOR" && match.teamA.code !== "KOR");
|
||||
const leftShort = flip ? bShort : aShort;
|
||||
const rightShort = flip ? aShort : bShort;
|
||||
// 마스코트(사자·버튼 양옆 캐릭터)는 모든 경기에서 노출.
|
||||
@@ -230,8 +233,8 @@ export default function Arena({
|
||||
|
||||
{/* ===== 레이어드 화이트 시트 (002) ===== */}
|
||||
<section className="sheet relative mt-4 p-5 text-[var(--ink)]">
|
||||
{/* AI 박스 오른쪽 위 사자 — 축구 전용 */}
|
||||
{!isBaseball && (
|
||||
{/* AI 박스 오른쪽 위 사자 — 월드컵 전용 (야구·MLS 미노출) */}
|
||||
{match.league === "wc" && (
|
||||
<div className="absolute right-1 -top-4 z-10 h-20 sm:h-24">
|
||||
<TalkingMascot
|
||||
src="/assets/mascots/lion_point.webp"
|
||||
@@ -390,7 +393,7 @@ export default function Arena({
|
||||
)}
|
||||
{/* 투표하기 버튼 — 모든 경기에서 양옆에 캐릭터(자동 말풍선) */}
|
||||
<div className="mt-3.5 flex items-end justify-center gap-1">
|
||||
{!isBaseball && <TalkingMascot
|
||||
{match.league === "wc" && <TalkingMascot
|
||||
src="/assets/mascots/dog_point.webp"
|
||||
lines={DOG_LINES}
|
||||
className="h-16 w-auto select-none sm:h-20"
|
||||
@@ -405,7 +408,7 @@ export default function Arena({
|
||||
>
|
||||
{submitting ? "…" : <>{t.submit} <span aria-hidden>→</span></>}
|
||||
</button>
|
||||
{!isBaseball && <TalkingMascot
|
||||
{match.league === "wc" && <TalkingMascot
|
||||
src="/assets/mascots/tiger_point.webp"
|
||||
lines={TIGER_LINES}
|
||||
className="h-16 w-auto select-none sm:h-20"
|
||||
@@ -502,7 +505,9 @@ export default function Arena({
|
||||
<ul className="flex flex-col gap-2">
|
||||
{(votesExpanded ? myPreds : myPreds.slice(0, 1)).map((p) => {
|
||||
const isThis = p.matchId === match.matchId;
|
||||
const pFlip = p.teamB.code === "KOR" && p.teamA.code !== "KOR";
|
||||
const pFlip =
|
||||
/^MLS_/.test(p.matchId) ||
|
||||
(p.teamB.code === "KOR" && p.teamA.code !== "KOR");
|
||||
const pA = teamShort(p.teamA, lang);
|
||||
const pB = teamShort(p.teamB, lang);
|
||||
const pLeft = pFlip ? pB : pA;
|
||||
@@ -566,11 +571,11 @@ export default function Arena({
|
||||
</section>
|
||||
)}
|
||||
|
||||
{/* ===== 누적 랭킹 TOP 10 (골드 카드 위 · 폴딩) — 야구(KBO/MLB)는 임시 비노출(운영 방침 미확정) ===== */}
|
||||
{!isBaseball && <RankingBoard lang={lang} league={match.league} />}
|
||||
{/* ===== 누적 랭킹 TOP 10 (골드 카드 위 · 폴딩) — 월드컵 외 리그는 임시 비노출(운영 방침 미확정) ===== */}
|
||||
{match.league === "wc" && <RankingBoard lang={lang} league={match.league} />}
|
||||
|
||||
{/* ===== 골드 상금 (003) — 야구(KBO/MLB)는 임시 비노출 ===== */}
|
||||
{!isBaseball && (
|
||||
{/* ===== 골드 상금 (003) — 월드컵 외 리그는 임시 비노출 ===== */}
|
||||
{match.league === "wc" && (
|
||||
<section className="gold-card mt-5 rounded-2xl p-5">
|
||||
<div className="flex items-center justify-between gap-3">
|
||||
<div className="min-w-0">
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { type Lang, dict } from "@/lib/i18n";
|
||||
|
||||
// league 를 주면 비제휴 고지를 리그에 맞게 표시 (야구 = KBO/MLB, 기본 = 월드컵)
|
||||
// league 를 주면 비제휴 고지를 리그에 맞게 표시 (클럽 리그 = KBO/MLB/MLS, 기본 = 월드컵)
|
||||
export default function Footer({
|
||||
lang = "ko",
|
||||
league = "wc",
|
||||
@@ -9,7 +9,7 @@ export default function Footer({
|
||||
league?: string;
|
||||
}) {
|
||||
const t = dict(lang);
|
||||
const isBaseball = league === "kbo" || league === "mlb";
|
||||
const isBaseball = league !== "wc";
|
||||
return (
|
||||
<footer className="mt-6 text-center">
|
||||
<p className="text-[10.5px] font-semibold text-white/75">
|
||||
|
||||
@@ -65,7 +65,11 @@ export default function Hero({
|
||||
? lang === "en"
|
||||
? "AI-powered 2026 MLB game predictions"
|
||||
: "AI와 함께하는 2026 MLB 승부예측 챌린지"
|
||||
: t.heroPill}
|
||||
: league === "mls"
|
||||
? lang === "en"
|
||||
? "AI-powered 2026 MLS game predictions"
|
||||
: "AI와 함께하는 2026 MLS 승부예측 챌린지"
|
||||
: t.heroPill}
|
||||
</div>
|
||||
<LeagueTabs lang={lang} current={league} />
|
||||
</header>
|
||||
@@ -79,6 +83,7 @@ function LeagueTabs({ lang, current }: { lang: Lang; current: League }) {
|
||||
{ key: "wc", label: lang === "en" ? "World Cup" : "월드컵" },
|
||||
{ key: "kbo", label: "KBO" },
|
||||
{ key: "mlb", label: "MLB" },
|
||||
{ key: "mls", label: "MLS" },
|
||||
];
|
||||
return (
|
||||
<div className="mt-3 flex justify-center">
|
||||
|
||||
@@ -0,0 +1,563 @@
|
||||
import { useEffect, useMemo, useState } from "react";
|
||||
import type { Lang } from "@/lib/i18n";
|
||||
import { teamShort } from "@/lib/i18n";
|
||||
import { getLive, type LiveData, type SoccerLineup, type SoccerPlayer } from "@/lib/api";
|
||||
import type { Match } from "@/lib/types";
|
||||
|
||||
const POLL_MS = 20_000;
|
||||
// 라인업은 보통 킥오프 60~75분 전 발표 — 이 시간부터 경기 전 폴링 시작
|
||||
const PREGAME_MIN = 90;
|
||||
// 자책골 마커 — 빨간 축구공 (이모지는 색 변경이 안 돼 인라인 SVG 로 그린다)
|
||||
function OgBall() {
|
||||
return (
|
||||
<svg viewBox="0 0 12 12" className="inline h-[11px] w-[11px] align-[-1.5px]">
|
||||
<circle cx="6" cy="6" r="5.4" fill="#E5484D" stroke="#fff" strokeWidth="0.9" />
|
||||
<path d="M6 3.1 4.2 4.4l.7 2.1h2.2l.7-2.1z" fill="#fff" />
|
||||
</svg>
|
||||
);
|
||||
}
|
||||
|
||||
// MLS 라이브 카드 — 경기 분·스코어·득점·선발 라인업·실시간 교체 현황.
|
||||
// 경기 전(킥오프 90분 이내, 라인업 발표 시)·경기 중·종료 후(경기 기록) 렌더. (서버 15초 캐시)
|
||||
export default function LiveSoccer({ match, lang = "ko" }: { match: Match; lang?: Lang }) {
|
||||
const isMls = match.league === "mls";
|
||||
const isLive = match.phase === "live";
|
||||
const isDone = match.phase === "finished";
|
||||
// 경기 전 폴링 여부 — 킥오프까지 90분 이내
|
||||
const nearKickoff = useMemo(() => {
|
||||
const diff = new Date(match.kickoffKst).getTime() - Date.now();
|
||||
return diff > 0 && diff <= PREGAME_MIN * 60_000;
|
||||
}, [match.kickoffKst]);
|
||||
const active = isMls && (isLive || isDone || nearKickoff);
|
||||
|
||||
const [live, setLive] = useState<LiveData | null>(null);
|
||||
const [showBench, setShowBench] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
if (!active) return;
|
||||
let alive = true;
|
||||
const load = () =>
|
||||
getLive(match.matchId)
|
||||
.then((d) => {
|
||||
if (alive && d.available) setLive(d);
|
||||
})
|
||||
.catch(() => {});
|
||||
load();
|
||||
if (isDone) return () => { alive = false; }; // 종료 경기는 1회 조회로 충분
|
||||
const t = setInterval(load, POLL_MS);
|
||||
return () => {
|
||||
alive = false;
|
||||
clearInterval(t);
|
||||
};
|
||||
}, [active, isDone, match.matchId]);
|
||||
|
||||
if (!active || !live?.available) return null;
|
||||
|
||||
const inPlay = live.state !== "pre";
|
||||
const ended = live.state === "post";
|
||||
const awayGoals = (live.goals ?? []).filter((g) => g.team === match.teamA.code);
|
||||
const homeGoals = (live.goals ?? []).filter((g) => g.team === match.teamB.code);
|
||||
// 득점 표기: 첫 줄 득점자 ⚽ / 둘째 줄(들여쓰기) 도움 선수 👟 — 줄바꿈 어색함 방지
|
||||
const goalLine = (
|
||||
g: {
|
||||
clock: string;
|
||||
player: string;
|
||||
assist?: string;
|
||||
ownGoal?: boolean;
|
||||
penalty?: boolean;
|
||||
},
|
||||
right = false,
|
||||
) => (
|
||||
<>
|
||||
<div>
|
||||
{g.clock} {g.player}
|
||||
{g.penalty ? " (PK)" : ""}
|
||||
{g.ownGoal ? " (OG)" : ""}{" "}
|
||||
{g.ownGoal ? <OgBall /> : "⚽"}
|
||||
</div>
|
||||
{g.assist && (
|
||||
<div className={`text-white/35 ${right ? "pr-4" : "pl-4"}`}>
|
||||
{g.assist} 👟
|
||||
</div>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
// 교체 시각 매핑 (선수명 → 분) — 라인업 옆에 표시
|
||||
const subClock = new Map<string, string>();
|
||||
// 나간 선수 → 들어온 선수 매핑 — 피치에서 투입 선수가 그 자리를 대체
|
||||
const outToIn = new Map<string, { inName: string; clock: string }>();
|
||||
for (const s of live.subs ?? []) {
|
||||
if (s.inName) subClock.set(s.inName, s.clock);
|
||||
if (s.outName) subClock.set(s.outName, s.clock);
|
||||
if (s.outName && s.inName) outToIn.set(s.outName, { inName: s.inName, clock: s.clock });
|
||||
}
|
||||
// 득점(⚽)·도움(👟)·자책골(빨간 ⚽) 횟수 — 피치 이름표에 표시
|
||||
const goalsBy = new Map<string, number>();
|
||||
const assistsBy = new Map<string, number>();
|
||||
const ogBy = new Map<string, number>();
|
||||
for (const g of live.goals ?? []) {
|
||||
if (g.player && !g.ownGoal) goalsBy.set(g.player, (goalsBy.get(g.player) ?? 0) + 1);
|
||||
if (g.player && g.ownGoal) ogBy.set(g.player, (ogBy.get(g.player) ?? 0) + 1);
|
||||
if (g.assist) assistsBy.set(g.assist, (assistsBy.get(g.assist) ?? 0) + 1);
|
||||
}
|
||||
// 카드(🟨/🟥) 누적 — 피치·교체 명단 이름표에 표시
|
||||
const cardsBy = new Map<string, { y: number; red: boolean }>();
|
||||
for (const c of live.cards ?? []) {
|
||||
if (!c.player) continue;
|
||||
const cur = cardsBy.get(c.player) ?? { y: 0, red: false };
|
||||
if (c.red) cur.red = true;
|
||||
else cur.y += 1;
|
||||
cardsBy.set(c.player, cur);
|
||||
}
|
||||
|
||||
return (
|
||||
<section
|
||||
className={`mt-5 rounded-2xl border bg-[var(--bg2)] p-4 ${
|
||||
inPlay && !ended ? "border-[#FF5B5B]/40" : "border-[var(--line-d)]"
|
||||
}`}
|
||||
>
|
||||
{/* 헤더: LIVE/경기 기록/선발 라인업 + 경기 시간 */}
|
||||
<div className="flex items-center justify-between">
|
||||
{ended ? (
|
||||
<span className="text-[13px] font-extrabold text-white">
|
||||
{lang === "en" ? "Match recap" : "경기 기록"}
|
||||
</span>
|
||||
) : inPlay ? (
|
||||
<span className="flex items-center gap-1.5 text-[12px] font-extrabold text-[#FF5B5B]">
|
||||
<span className="inline-block h-2 w-2 animate-pulse rounded-full bg-[#FF5B5B]" />
|
||||
LIVE
|
||||
</span>
|
||||
) : (
|
||||
<span className="text-[13px] font-extrabold text-white">
|
||||
{lang === "en" ? "Starting lineups" : "선발 라인업"}
|
||||
</span>
|
||||
)}
|
||||
{inPlay && (
|
||||
<span className="font-mono text-[13px] font-extrabold text-white/80">
|
||||
{ended ? (
|
||||
<span className="text-[11px] font-bold text-white/40">
|
||||
{lang === "en" ? "FT" : "경기 종료"}
|
||||
</span>
|
||||
) : (
|
||||
<>
|
||||
{live.clock}
|
||||
{live.period != null && (
|
||||
<span className="ml-1.5 text-[11px] font-bold text-white/40">
|
||||
{live.period === 1
|
||||
? lang === "en" ? "1st half" : "전반"
|
||||
: live.period === 2
|
||||
? lang === "en" ? "2nd half" : "후반"
|
||||
: lang === "en" ? "ET" : "연장"}
|
||||
</span>
|
||||
)}
|
||||
</>
|
||||
)}
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* 스코어 (경기 중에만) — 홈 팀 먼저 (축구 관례) */}
|
||||
{inPlay && (
|
||||
<div className="mt-3 grid grid-cols-[1fr_auto_1fr] items-center gap-2">
|
||||
<span className="truncate text-[15px] font-extrabold">{teamShort(match.teamB, lang)}</span>
|
||||
<span className="whitespace-nowrap font-mono text-[26px] font-extrabold tabular-nums text-white">
|
||||
{live.score?.home ?? 0}
|
||||
<span className="px-2 text-[#FF5B5B]">:</span>
|
||||
{live.score?.away ?? 0}
|
||||
</span>
|
||||
<span className="truncate text-right text-[15px] font-extrabold">
|
||||
{teamShort(match.teamA, lang)}
|
||||
</span>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* 득점 이벤트 (양 팀 분리, 시간순) — 좌=홈 / 우=원정 */}
|
||||
{(awayGoals.length > 0 || homeGoals.length > 0) && (
|
||||
<div className="mt-3 grid grid-cols-2 gap-2 border-t border-white/10 pt-2.5 text-[11px] font-semibold text-white/60">
|
||||
<div className="space-y-0.5">
|
||||
{homeGoals.map((g, i) => (
|
||||
<div key={i}>{goalLine(g)}</div>
|
||||
))}
|
||||
</div>
|
||||
<div className="space-y-0.5 text-right">
|
||||
{awayGoals.map((g, i) => (
|
||||
<div key={i}>{goalLine(g, true)}</div>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
|
||||
{/* 문자중계 (최신순) — 세로 스크롤 (다크 스크롤바, 흰 배경 없음) */}
|
||||
{(live.commentary?.length ?? 0) > 0 && (
|
||||
<div className="mt-3 border-t border-white/10 pt-2.5">
|
||||
<div className="mb-1 flex items-baseline justify-between">
|
||||
<span className="text-[10px] font-bold text-white/35">
|
||||
{lang === "en" ? "PLAY-BY-PLAY" : "문자중계"}
|
||||
</span>
|
||||
<span className="text-[9px] text-white/25">ESPN</span>
|
||||
</div>
|
||||
<ul className="max-h-[200px] space-y-1 overflow-y-auto pr-1 text-[11px] leading-snug [scrollbar-width:thin] [scrollbar-color:rgba(255,255,255,.22)_transparent] [&::-webkit-scrollbar]:w-1.5 [&::-webkit-scrollbar-track]:bg-transparent [&::-webkit-scrollbar-thumb]:rounded-full [&::-webkit-scrollbar-thumb]:bg-white/20">
|
||||
{live.commentary!.map((c, i) => (
|
||||
<li
|
||||
key={`${c.clock}-${i}`}
|
||||
className={`flex gap-1.5 ${
|
||||
c.goal
|
||||
? "rounded-lg border border-[#94FBE0]/30 bg-[#94FBE0]/10 px-1.5 py-1"
|
||||
: ""
|
||||
}`}
|
||||
>
|
||||
<span
|
||||
className={`w-7 shrink-0 text-right font-mono font-bold ${
|
||||
c.goal ? "text-[#94FBE0]" : "text-white/40"
|
||||
}`}
|
||||
>
|
||||
{c.clock}
|
||||
</span>
|
||||
<span
|
||||
className={
|
||||
c.goal ? "font-extrabold text-[#94FBE0]" : "font-medium text-white/65"
|
||||
}
|
||||
>
|
||||
{c.text}
|
||||
</span>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* 선발 라인업 — 축구장 하나에 반코트씩 (위=홈 · 아래=원정), 교체 아웃은 흐리게 */}
|
||||
{live.lineups?.away && live.lineups?.home && (
|
||||
<div className="mt-3 border-t border-white/10 pt-2.5">
|
||||
<div className="mb-1.5 flex items-center justify-between text-[11px] font-extrabold text-white/85">
|
||||
<span>
|
||||
{teamShort(match.teamB, lang)}
|
||||
{live.lineups.home.formation && (
|
||||
<span className="ml-1 font-mono text-[10px] font-bold text-white/40">
|
||||
{live.lineups.home.formation}
|
||||
</span>
|
||||
)}
|
||||
</span>
|
||||
<span className="text-[10px] font-bold text-white/35">
|
||||
{lang === "en" ? "STARTING XI" : "선발 라인업"}
|
||||
</span>
|
||||
<span className="text-right">
|
||||
{live.lineups.away.formation && (
|
||||
<span className="mr-1 font-mono text-[10px] font-bold text-white/40">
|
||||
{live.lineups.away.formation}
|
||||
</span>
|
||||
)}
|
||||
{teamShort(match.teamA, lang)}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<Pitch
|
||||
away={live.lineups.away}
|
||||
home={live.lineups.home}
|
||||
outToIn={outToIn}
|
||||
goalsBy={goalsBy}
|
||||
assistsBy={assistsBy}
|
||||
ogBy={ogBy}
|
||||
cardsBy={cardsBy}
|
||||
/>
|
||||
|
||||
{/* 교체 명단 (벤치) — 투입된 선수는 ▲분 표시 */}
|
||||
<button
|
||||
onClick={() => setShowBench((v) => !v)}
|
||||
className="mt-2.5 flex w-full items-center justify-center gap-1 rounded-xl border border-[var(--line-d)] py-2 text-[12px] font-bold text-[var(--ink-muted)] transition active:scale-[0.99]"
|
||||
>
|
||||
{showBench
|
||||
? lang === "en" ? "Hide bench" : "교체 명단 접기"
|
||||
: lang === "en" ? "Show bench" : "교체 명단 보기"}
|
||||
<span aria-hidden>{showBench ? "▲" : "▼"}</span>
|
||||
</button>
|
||||
{showBench && (
|
||||
<div className="mt-2 grid grid-cols-2 gap-3 text-[11px]">
|
||||
<BenchList
|
||||
lu={live.lineups.home}
|
||||
subClock={subClock}
|
||||
goalsBy={goalsBy}
|
||||
assistsBy={assistsBy}
|
||||
ogBy={ogBy}
|
||||
cardsBy={cardsBy}
|
||||
/>
|
||||
<BenchList
|
||||
lu={live.lineups.away}
|
||||
subClock={subClock}
|
||||
goalsBy={goalsBy}
|
||||
assistsBy={assistsBy}
|
||||
ogBy={ogBy}
|
||||
cardsBy={cardsBy}
|
||||
right
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
</section>
|
||||
);
|
||||
}
|
||||
|
||||
// 포메이션 문자열("4-2-3-1") → 줄별 인원. 합이 필드 플레이어 수와 다르면 4-4-2 폴백.
|
||||
function parseRows(formation: string | null | undefined, n: number): number[] {
|
||||
const rows = (formation ?? "").split("-").map(Number).filter((x) => x > 0);
|
||||
if (rows.length && rows.reduce((a, b) => a + b, 0) === n) return rows;
|
||||
return n === 10 ? [4, 4, 2] : [n];
|
||||
}
|
||||
|
||||
// 포지션 약어 → 세로 라인 가중치 (작을수록 수비 라인)
|
||||
// F/ST 는 CF 보다 반 칸 앞 — 3-4-2-1 의 섀도 투톱(CF-R/CF-L) 뒤 원톱(F) 구분.
|
||||
// 실제로 같은 줄인 4-3-3 등은 아래 병합 단계가 포메이션 숫자에 맞춰 다시 합친다.
|
||||
const POS_LINE: Record<string, number> = {
|
||||
G: 0,
|
||||
RB: 1, LB: 1, CD: 1, CB: 1, SW: 1,
|
||||
RWB: 1.5, LWB: 1.5,
|
||||
DM: 2,
|
||||
CM: 2.5,
|
||||
RM: 3, LM: 3,
|
||||
AM: 3.5,
|
||||
RW: 3.7, LW: 3.7,
|
||||
RF: 4, LF: 4, CF: 4,
|
||||
F: 4.2, ST: 4.2,
|
||||
};
|
||||
const posBase = (pos: string) => pos.toUpperCase().replace(/-[RL]$/, "");
|
||||
// 줄 안 좌→우 정렬 키 (상단 팀 기준; 하단 팀은 미러로 좌우 반전)
|
||||
function posX(pos: string): number {
|
||||
const P = pos.toUpperCase();
|
||||
if (P.startsWith("L")) return 0;
|
||||
if (P.startsWith("R")) return 4;
|
||||
if (P.endsWith("-L")) return 1;
|
||||
if (P.endsWith("-R")) return 3;
|
||||
return 2;
|
||||
}
|
||||
|
||||
// ESPN formationPlace 는 줄 순서가 아니라 전통 등번호식 슬롯(2=RB, 3=LB, 4=CM…)이라
|
||||
// 순서대로 줄에 채우면 배치가 어긋난다 → 포지션 약어(CD-R, CM-L…) 기반으로 줄 구성.
|
||||
function layoutRows(field: SoccerPlayer[], formation?: string | null): SoccerPlayer[][] {
|
||||
const lines = field.map((p) => POS_LINE[posBase(p.pos || "")]);
|
||||
let rows: SoccerPlayer[][];
|
||||
if (lines.some((l) => l == null)) {
|
||||
// 포지션 불명 선수가 있으면 formationPlace 순 폴백
|
||||
const cnts = parseRows(formation, field.length);
|
||||
let i = 0;
|
||||
rows = cnts.map((c) => field.slice(i, (i += c)));
|
||||
} else {
|
||||
const groups = new Map<number, SoccerPlayer[]>();
|
||||
field.forEach((p, i) => {
|
||||
const arr = groups.get(lines[i]) ?? [];
|
||||
arr.push(p);
|
||||
groups.set(lines[i], arr);
|
||||
});
|
||||
rows = [...groups.entries()].sort((a, b) => a[0] - b[0]).map(([, ps]) => ps);
|
||||
// 포메이션 숫자에 줄 수 맞추기 — 앞 줄부터 인원수대로 병합 (4-4-2 의 중미+윙미 등)
|
||||
const target = parseRows(formation, field.length);
|
||||
if (target.reduce((a, b) => a + b, 0) === field.length && target.length < rows.length) {
|
||||
const merged: SoccerPlayer[][] = [];
|
||||
let gi = 0;
|
||||
let ok = true;
|
||||
for (const cnt of target) {
|
||||
let acc: SoccerPlayer[] = [];
|
||||
while (acc.length < cnt && gi < rows.length) acc = acc.concat(rows[gi++]);
|
||||
if (acc.length !== cnt) { ok = false; break; }
|
||||
merged.push(acc);
|
||||
}
|
||||
if (ok && gi === rows.length) rows = merged;
|
||||
}
|
||||
}
|
||||
return rows.map((r) => r.slice().sort((a, b) => posX(a.pos || "") - posX(b.pos || "")));
|
||||
}
|
||||
|
||||
// 축구장 피치 — 세로형 풀피치, 위 반코트=홈 / 아래 반코트=원정 (홈 먼저 — 축구 관례).
|
||||
// 각 포메이션 라인이 화면 가로폭 전체를 쓰므로 이름 공간이 넓다.
|
||||
// 현재 그라운드 기준: 교체 투입 선수가 나간 선수 자리를 대체(빨간 ▲분),
|
||||
// 나간 선수는 교체 명단(BenchList)에 ▼로 표시된다.
|
||||
function Pitch({
|
||||
away,
|
||||
home,
|
||||
outToIn,
|
||||
goalsBy,
|
||||
assistsBy,
|
||||
ogBy,
|
||||
cardsBy,
|
||||
}: {
|
||||
away: SoccerLineup;
|
||||
home: SoccerLineup;
|
||||
outToIn?: Map<string, { inName: string; clock: string }>;
|
||||
goalsBy?: Map<string, number>;
|
||||
assistsBy?: Map<string, number>;
|
||||
ogBy?: Map<string, number>;
|
||||
cardsBy?: Map<string, { y: number; red: boolean }>;
|
||||
}) {
|
||||
const place = (lu: SoccerLineup, half: "top" | "bottom") => {
|
||||
const [gk, ...field] = lu.starters;
|
||||
const out: { p: SoccerPlayer; x: number; y: number }[] = [];
|
||||
if (gk) out.push({ p: gk, x: 0.5, y: 0.055 });
|
||||
const rows = layoutRows(field, lu.formation);
|
||||
rows.forEach((row, r) => {
|
||||
// 반코트(0.055~0.45) 안에서 줄을 균등 배치, 마지막 줄이 센터라인 쪽
|
||||
const y = 0.055 + ((r + 1) / (rows.length + 1)) * (0.45 - 0.055);
|
||||
row.forEach((p, i) => out.push({ p, x: (i + 0.5) / row.length, y }));
|
||||
});
|
||||
// 위 팀은 아래로 공격 → 뷰어 기준 좌우 반전. 아래 팀은 위로 공격 → 좌우 그대로, 상하만 미러.
|
||||
return half === "top"
|
||||
? out.map((o) => ({ ...o, x: 1 - o.x }))
|
||||
: out.map((o) => ({ ...o, y: 1 - o.y }));
|
||||
};
|
||||
const markers = [
|
||||
...place(home, "top").map((o) => ({ ...o, side: "home" as const })),
|
||||
...place(away, "bottom").map((o) => ({ ...o, side: "away" as const })),
|
||||
];
|
||||
const lastName = (name: string) => name.split(" ").slice(-1)[0];
|
||||
|
||||
return (
|
||||
<div
|
||||
className="relative w-full overflow-hidden rounded-xl border border-white/10"
|
||||
style={{
|
||||
aspectRatio: "3 / 4",
|
||||
background:
|
||||
"repeating-linear-gradient(0deg, #2e7d46 0 12.5%, #2a7340 12.5% 25%)",
|
||||
}}
|
||||
>
|
||||
{/* 피치 라인: 외곽·센터라인·센터서클·페널티박스 (세로형) */}
|
||||
<div className="pointer-events-none absolute inset-[2.5%] rounded-sm border border-white/30" />
|
||||
<div className="pointer-events-none absolute inset-x-[2.5%] top-1/2 h-px -translate-y-1/2 bg-white/30" />
|
||||
<div className="pointer-events-none absolute left-1/2 top-1/2 w-[22%] aspect-square -translate-x-1/2 -translate-y-1/2 rounded-full border border-white/30" />
|
||||
<div className="pointer-events-none absolute left-1/2 top-[2.5%] h-[10%] w-[46%] -translate-x-1/2 border border-t-0 border-white/30" />
|
||||
<div className="pointer-events-none absolute bottom-[2.5%] left-1/2 h-[10%] w-[46%] -translate-x-1/2 border border-b-0 border-white/30" />
|
||||
|
||||
{markers.map(({ p, x, y, side }) => {
|
||||
// 교체됐으면 투입 선수가 그 자리를 대체 (빨간 ▲분). 매핑 없으면 기존 흐림 표시.
|
||||
const sub = p.out ? outToIn?.get(p.name) : undefined;
|
||||
const lu = side === "away" ? away : home;
|
||||
const shown = sub
|
||||
? lu.bench.find((b) => b.name === sub.inName) ?? { ...p, name: sub.inName, jersey: "" }
|
||||
: p;
|
||||
const dimmed = p.out && !sub;
|
||||
const nGoals = goalsBy?.get(shown.name) ?? 0;
|
||||
const nAssists = assistsBy?.get(shown.name) ?? 0;
|
||||
const nOgs = ogBy?.get(shown.name) ?? 0;
|
||||
const card = cardsBy?.get(shown.name);
|
||||
return (
|
||||
<div
|
||||
key={`${side}-${p.name}`}
|
||||
className={`absolute flex -translate-x-1/2 -translate-y-1/2 flex-col items-center ${
|
||||
dimmed ? "opacity-45" : ""
|
||||
}`}
|
||||
style={{ left: `${x * 100}%`, top: `${y * 100}%` }}
|
||||
>
|
||||
<span
|
||||
className={`grid h-[24px] w-[24px] place-items-center rounded-full font-mono text-[11px] font-extrabold shadow ${
|
||||
side === "away"
|
||||
? "bg-[#0f1216] text-[#94FBE0] ring-1 ring-[#94FBE0]/60"
|
||||
: "bg-white text-black ring-1 ring-black/20"
|
||||
}`}
|
||||
>
|
||||
{shown.jersey || "·"}
|
||||
</span>
|
||||
<span className="mt-0.5 max-w-[96px] truncate rounded bg-black/45 px-1 py-px text-[10px] font-bold leading-tight text-white">
|
||||
{nGoals > 0 && <span>{"⚽".repeat(Math.min(nGoals, 3))} </span>}
|
||||
{nOgs > 0 && (
|
||||
<span>
|
||||
{Array.from({ length: Math.min(nOgs, 2) }, (_, i) => (
|
||||
<OgBall key={i} />
|
||||
))}{" "}
|
||||
</span>
|
||||
)}
|
||||
{nAssists > 0 && <span>👟 </span>}
|
||||
{card && (
|
||||
<span>{"🟨".repeat(Math.min(card.y, 2))}{card.red ? "🟥" : ""} </span>
|
||||
)}
|
||||
{lastName(shown.name)}
|
||||
{sub && <span className="text-[#FF7B7B]"> ▲{sub.clock}</span>}
|
||||
{dimmed && <span className="text-[#ffb3b3]"> ▼</span>}
|
||||
</span>
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
// 교체 명단 — 교체 아웃된 선수(▼분)를 먼저, 이어서 미투입 벤치.
|
||||
// 투입된 선수는 피치 위로 올라가므로 여기서는 제외.
|
||||
function BenchList({
|
||||
lu,
|
||||
subClock,
|
||||
goalsBy,
|
||||
assistsBy,
|
||||
ogBy,
|
||||
cardsBy,
|
||||
right = false,
|
||||
}: {
|
||||
lu: SoccerLineup;
|
||||
subClock: Map<string, string>;
|
||||
goalsBy?: Map<string, number>;
|
||||
assistsBy?: Map<string, number>;
|
||||
ogBy?: Map<string, number>;
|
||||
cardsBy?: Map<string, { y: number; red: boolean }>;
|
||||
right?: boolean;
|
||||
}) {
|
||||
const rows = [
|
||||
...lu.starters.filter((p) => p.out).map((p) => ({ p, kind: "out" as const })),
|
||||
...lu.bench.filter((p) => !p.in).map((p) => ({ p, kind: "bench" as const })),
|
||||
];
|
||||
return (
|
||||
<ul className={`space-y-0.5 ${right ? "text-right" : "text-left"}`}>
|
||||
{rows.map(({ p, kind }, i) => {
|
||||
const clock = subClock.get(p.name);
|
||||
const mark =
|
||||
kind === "out" ? (
|
||||
<span className="text-[#FF7B7B]"> ▼{clock ? ` ${clock}` : ""}</span>
|
||||
) : null;
|
||||
// 교체 아웃 전 기록한 득점·자책골·도움·카드도 표시
|
||||
const nGoals = goalsBy?.get(p.name) ?? 0;
|
||||
const nAssists = assistsBy?.get(p.name) ?? 0;
|
||||
const nOgs = ogBy?.get(p.name) ?? 0;
|
||||
const card = cardsBy?.get(p.name);
|
||||
const feats = (
|
||||
<>
|
||||
{nGoals > 0 && <span>{"⚽".repeat(Math.min(nGoals, 3))} </span>}
|
||||
{nOgs > 0 && (
|
||||
<span>
|
||||
{Array.from({ length: Math.min(nOgs, 2) }, (_, i) => (
|
||||
<OgBall key={i} />
|
||||
))}{" "}
|
||||
</span>
|
||||
)}
|
||||
{nAssists > 0 && <span>👟 </span>}
|
||||
{card && (
|
||||
<span>{"🟨".repeat(Math.min(card.y, 2))}{card.red ? "🟥" : ""} </span>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
return (
|
||||
<li
|
||||
key={`${p.name}-${i}`}
|
||||
className={`truncate ${kind === "out" ? "text-white/75" : "text-white/45"}`}
|
||||
>
|
||||
{right ? (
|
||||
<>
|
||||
{mark}
|
||||
{feats}
|
||||
<span className="font-semibold">{p.name}</span>{" "}
|
||||
<span className="font-mono text-[10px] text-white/35">
|
||||
{p.jersey}{p.pos ? ` ${p.pos}` : ""}
|
||||
</span>
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
<span className="font-mono text-[10px] text-white/35">
|
||||
{p.jersey}{p.pos ? ` ${p.pos}` : ""}
|
||||
</span>{" "}
|
||||
{feats}
|
||||
<span className="font-semibold">{p.name}</span>
|
||||
{mark}
|
||||
</>
|
||||
)}
|
||||
</li>
|
||||
);
|
||||
})}
|
||||
</ul>
|
||||
);
|
||||
}
|
||||
@@ -1,7 +1,8 @@
|
||||
import type { Match } from "@/lib/types";
|
||||
import type { Match, TeamStanding } from "@/lib/types";
|
||||
import { kickoffDisplay } from "@/lib/format";
|
||||
import { type Lang, dict, teamShort, roundLabel as tRound } from "@/lib/i18n";
|
||||
import BallIcon from "./BallIcon";
|
||||
import { FormBadges } from "./ScheduleBoard";
|
||||
import TeamFlag from "./TeamFlag";
|
||||
import WaveStrip from "./WaveStrip";
|
||||
|
||||
@@ -17,13 +18,36 @@ function standingLine(
|
||||
return `${rank} · ${rec}${st.wra ? ` (${st.wra})` : ""}`;
|
||||
}
|
||||
|
||||
// MLS 순위 캐시 → "동부 3위 · 8승2무4패 (승점 26)" 한 줄
|
||||
function mlsStandingLine(st: TeamStanding & { div?: string | null } | null | undefined, lang: Lang): string | null {
|
||||
if (!st?.rank) return null;
|
||||
const conf =
|
||||
st.div === "EAST"
|
||||
? lang === "en" ? "East" : "동부"
|
||||
: st.div === "WEST"
|
||||
? lang === "en" ? "West" : "서부"
|
||||
: "";
|
||||
const rank = lang === "en" ? `#${st.rank}` : `${st.rank}위`;
|
||||
const rec =
|
||||
st.w != null && st.l != null
|
||||
? lang === "en"
|
||||
? ` · ${st.w}W-${st.d ?? 0}D-${st.l}L`
|
||||
: ` · ${st.w}승${st.d ?? 0}무${st.l}패`
|
||||
: "";
|
||||
const pts = st.pts != null ? (lang === "en" ? ` (${st.pts}pts)` : ` (승점 ${st.pts})`) : "";
|
||||
return `${conf} ${rank}${rec}${pts}`.trim();
|
||||
}
|
||||
|
||||
export default function MatchupHUD({ match, lang = "ko" }: { match: Match; lang?: Lang }) {
|
||||
const t = dict(lang);
|
||||
const { group } = match;
|
||||
const finished = !!match.result;
|
||||
const isBaseball = match.league === "kbo" || match.league === "mlb";
|
||||
// 축구: 한국을 항상 왼쪽에. 야구: A=원정(좌), B=홈(우) 고정.
|
||||
const flip = !isBaseball && match.teamB.code === "KOR" && match.teamA.code !== "KOR";
|
||||
const isMls = match.league === "mls";
|
||||
const isClub = isBaseball || isMls; // 클럽 리그 공통 분기 (로고·venue 등)
|
||||
// 월드컵: 한국을 항상 왼쪽에. 야구: 원정-홈. MLS: 홈-원정 (축구 관례 — 화면만 교체).
|
||||
const flip =
|
||||
isMls || (!isClub && match.teamB.code === "KOR" && match.teamA.code !== "KOR");
|
||||
const left = flip ? match.teamB : match.teamA;
|
||||
const right = flip ? match.teamA : match.teamB;
|
||||
const leftScore = flip ? match.result?.scoreB : match.result?.scoreA;
|
||||
@@ -36,7 +60,11 @@ export default function MatchupHUD({ match, lang = "ko" }: { match: Match; lang?
|
||||
const stR = standingLine(ex?.standings?.b, lang);
|
||||
const vs = ex?.seasonVs;
|
||||
const hasVs = !!vs && vs.aWin != null && vs.bWin != null;
|
||||
const flagCls = isBaseball ? "mx-auto h-[72px] w-[72px]" : "mx-auto h-[68px] w-[104px]";
|
||||
// MLS 프리뷰 (폼·시즌 전적·순위·맞대결) — 왼쪽=홈(teamB) 기준으로 교체
|
||||
const mlsStL = mlsStandingLine(ex?.standings?.b, lang);
|
||||
const mlsStR = mlsStandingLine(ex?.standings?.a, lang);
|
||||
const h2h = ex?.h2h ?? [];
|
||||
const flagCls = isClub ? "mx-auto h-[72px] w-[72px]" : "mx-auto h-[68px] w-[104px]";
|
||||
|
||||
return (
|
||||
<section className="mt-6">
|
||||
@@ -45,8 +73,8 @@ export default function MatchupHUD({ match, lang = "ko" }: { match: Match; lang?
|
||||
className="relative rounded-3xl border-2 border-[var(--green)] bg-[#171b21] p-5"
|
||||
style={{ boxShadow: "0 0 28px rgba(74,255,160,0.35), inset 0 0 24px rgba(74,255,160,0.06)" }}
|
||||
>
|
||||
{/* 파도타기 마스코트 — 축구 전용 (야구는 미노출) */}
|
||||
{!isBaseball && (
|
||||
{/* 파도타기 마스코트 — 월드컵 전용 (야구·MLS 미노출) */}
|
||||
{!isClub && (
|
||||
<div className="absolute right-2 top-2 z-10">
|
||||
<WaveStrip />
|
||||
</div>
|
||||
@@ -66,9 +94,9 @@ export default function MatchupHUD({ match, lang = "ko" }: { match: Match; lang?
|
||||
</div>
|
||||
<div className="mt-0.5 text-[12px] text-white/65">
|
||||
{match.venue}
|
||||
{isBaseball && (
|
||||
{isClub && (
|
||||
<span className="text-white/40">
|
||||
{" "}· {lang === "en" ? "Home: " : "홈 "}{teamShort(right, lang)}
|
||||
{" "}· {lang === "en" ? "Home: " : "홈 "}{teamShort(match.teamB, lang)}
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
@@ -167,6 +195,57 @@ export default function MatchupHUD({ match, lang = "ko" }: { match: Match; lang?
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* MLS 정보 패널: 최근 5경기 폼 · 컨퍼런스 순위 · 최근 맞대결 (캐시 있을 때만) */}
|
||||
{isMls && (ex?.formA || ex?.formB || mlsStL || mlsStR || h2h.length > 0) && (
|
||||
<div className="mt-4 rounded-2xl bg-white/[0.04] p-3.5 text-[12px]">
|
||||
{(ex?.formA || ex?.formB) && (
|
||||
<div className="grid grid-cols-[1fr_auto_1fr] items-center gap-2">
|
||||
<div className="min-w-0">
|
||||
<FormBadges form={ex?.formB} />
|
||||
{ex?.recordB && (
|
||||
<span className="ml-1.5 text-white/45">{ex.recordB}</span>
|
||||
)}
|
||||
</div>
|
||||
<span className="text-[11px] font-bold text-[var(--green)]">
|
||||
{lang === "en" ? "Last 5 · W-L-D" : "최근 5경기 · 시즌"}
|
||||
</span>
|
||||
<div className="min-w-0 text-right">
|
||||
{ex?.recordA && (
|
||||
<span className="mr-1.5 text-white/45">{ex.recordA}</span>
|
||||
)}
|
||||
<FormBadges form={ex?.formA} />
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{(mlsStL || mlsStR) && (
|
||||
<div className="mt-2.5 flex items-center justify-between border-t border-white/10 pt-2.5 text-white/55">
|
||||
<span className="truncate">{mlsStL ?? "—"}</span>
|
||||
<span className="px-2 text-[10px] text-white/30">{lang === "en" ? "STANDINGS" : "순위"}</span>
|
||||
<span className="truncate text-right">{mlsStR ?? "—"}</span>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{h2h.length > 0 && (
|
||||
<div className="mt-2.5 border-t border-white/10 pt-2.5">
|
||||
<div className="mb-1 text-center text-[10px] text-white/35">
|
||||
{lang === "en" ? "RECENT H2H" : "최근 맞대결"}
|
||||
</div>
|
||||
<ul className="space-y-0.5 text-center font-mono text-[11px] text-white/60">
|
||||
{h2h.slice(0, 3).map((g, i) => (
|
||||
<li key={i}>
|
||||
<span className="text-white/35">{g.date.slice(5).replace("-", ".")}</span>{" "}
|
||||
{g.home} {g.scoreH}
|
||||
<span className="px-1 text-white/30">:</span>
|
||||
{g.scoreA} {g.away}
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
|
||||
{finished && (
|
||||
<div className="mt-3 text-center text-[12px] font-bold text-[var(--green)]">
|
||||
{t.matchEnded}
|
||||
|
||||
@@ -379,7 +379,30 @@ function Chip({
|
||||
);
|
||||
}
|
||||
|
||||
// 팀명 옆 순위 배지 (야구 — 순위 캐시 없으면 렌더 안 함)
|
||||
// MLS 최근 5경기 폼 — "WWLDW" 를 W/D/L 색으로 표시
|
||||
export function FormBadges({ form }: { form?: string | null }) {
|
||||
if (!form) return <span className="text-white/35">?</span>;
|
||||
return (
|
||||
<span className="inline-flex gap-px font-mono font-extrabold tracking-tight">
|
||||
{form.split("").map((c, i) => (
|
||||
<span
|
||||
key={i}
|
||||
className={
|
||||
c === "W"
|
||||
? "text-[#94FBE0]"
|
||||
: c === "L"
|
||||
? "text-[#FF5B5B]/80"
|
||||
: "text-white/45"
|
||||
}
|
||||
>
|
||||
{c}
|
||||
</span>
|
||||
))}
|
||||
</span>
|
||||
);
|
||||
}
|
||||
|
||||
// 팀명 옆 순위 배지 (야구·MLS — 순위 캐시 없으면 렌더 안 함)
|
||||
function RankBadge({ rank, lang = "ko" }: { rank?: number | null; lang?: Lang }) {
|
||||
if (!rank) return null;
|
||||
return (
|
||||
@@ -402,11 +425,13 @@ function MatchCard({
|
||||
const phase = match.phase;
|
||||
const finished = !!match.result;
|
||||
const isBaseball = match.league === "kbo" || match.league === "mlb";
|
||||
const isMls = match.league === "mls";
|
||||
const isClub = isBaseball || isMls; // 클럽 리그 공통 UI (원정-홈 고정·로고·순위 뱃지)
|
||||
|
||||
// 야구 진행 중: 회차·스코어 표시 (서버 15초 캐시라 부담 없음, 30초 폴링)
|
||||
// 진행 중: 회차(야구)/경기 분(MLS)·스코어 표시 (서버 15초 캐시, 30초 폴링)
|
||||
const [live, setLive] = useState<LiveData | null>(null);
|
||||
useEffect(() => {
|
||||
if (phase !== "live" || !isBaseball) return;
|
||||
if (phase !== "live" || !isClub) return;
|
||||
let alive = true;
|
||||
const load = () =>
|
||||
getLive(match.matchId)
|
||||
@@ -420,21 +445,27 @@ function MatchCard({
|
||||
alive = false;
|
||||
clearInterval(id);
|
||||
};
|
||||
}, [match.matchId, phase, isBaseball]);
|
||||
// "6회초" / "Top 6"
|
||||
const inning =
|
||||
live?.inn != null
|
||||
}, [match.matchId, phase, isClub]);
|
||||
// 야구 "6회초" / "Top 6" · MLS 경기 분 "45'"
|
||||
const liveBadge = isMls
|
||||
? live?.clock || null
|
||||
: live?.inn != null
|
||||
? lang === "en"
|
||||
? `${live.half === "B" ? "Bot" : "Top"} ${live.inn}`
|
||||
: `${live.inn}회${live.half === "B" ? "말" : "초"}`
|
||||
: null;
|
||||
// 한국을 항상 왼쪽에 표시(상세 페이지와 동일 규칙). 데이터는 원본 A/B 유지, 화면 좌우만 교체.
|
||||
const flip = !isBaseball && match.teamB.code === "KOR" && match.teamA.code !== "KOR";
|
||||
// 킥오프 시각은 지났지만 소스가 아직 시작 전(state=pre)이라는 경기 — 지연 등
|
||||
const notStarted = isMls && phase === "live" && live?.state === "pre";
|
||||
// 월드컵: 한국을 항상 왼쪽에. MLS: 홈 팀을 왼쪽에(축구 관례). 데이터는 원본 A/B 유지, 화면 좌우만 교체.
|
||||
const flip =
|
||||
isMls || (!isClub && match.teamB.code === "KOR" && match.teamA.code !== "KOR");
|
||||
const left = flip ? match.teamB : match.teamA;
|
||||
const right = flip ? match.teamA : match.teamB;
|
||||
const leftScore = flip ? match.result?.scoreB : match.result?.scoreA;
|
||||
const rightScore = flip ? match.result?.scoreA : match.result?.scoreB;
|
||||
const flagCls = isBaseball ? "h-7 w-7 shrink-0" : "h-6 w-9 shrink-0";
|
||||
const leftSt = flip ? match.extras?.standings?.b : match.extras?.standings?.a;
|
||||
const rightSt = flip ? match.extras?.standings?.a : match.extras?.standings?.b;
|
||||
const flagCls = isClub ? "h-7 w-7 shrink-0" : "h-6 w-9 shrink-0";
|
||||
|
||||
// 비투표(타 조)는 클릭 비활성, 투표 가능 조(A)는 상세로 이동
|
||||
const inner = (
|
||||
@@ -445,14 +476,14 @@ function MatchCard({
|
||||
<span className="text-white/55">{shortDate(dateKey(match.kickoffKst), lang)} </span>
|
||||
)}
|
||||
{timeOnly(match.kickoffKst)} <span className="text-white/40">KST</span>
|
||||
{isBaseball && match.venue ? (
|
||||
{isClub && match.venue ? (
|
||||
<span className="text-white/40"> · {match.venue}</span>
|
||||
) : match.group && match.roundLabel ? (
|
||||
<> · {tRound(match.roundLabel, lang)}</>
|
||||
) : null}
|
||||
</span>
|
||||
<span className="flex items-center gap-1.5">
|
||||
{!isBaseball && (
|
||||
{!isClub && (
|
||||
<span className="text-[11px] font-bold text-white/45">
|
||||
{match.group
|
||||
? lang === "en"
|
||||
@@ -461,8 +492,16 @@ function MatchCard({
|
||||
: tRound(match.roundLabel, lang)}
|
||||
</span>
|
||||
)}
|
||||
<span className={`rounded-md border px-2 py-0.5 font-semibold ${PHASE_CLS[phase]}`}>
|
||||
{phase === "live" && inning ? inning : t.phase[phase]}
|
||||
<span
|
||||
className={`rounded-md border px-2 py-0.5 font-semibold ${
|
||||
notStarted ? PHASE_CLS.scheduled : PHASE_CLS[phase]
|
||||
}`}
|
||||
>
|
||||
{notStarted
|
||||
? lang === "en" ? "Not started" : "시작 전"
|
||||
: phase === "live" && liveBadge
|
||||
? liveBadge
|
||||
: t.phase[phase]}
|
||||
</span>
|
||||
</span>
|
||||
</div>
|
||||
@@ -471,7 +510,7 @@ function MatchCard({
|
||||
<div className="flex items-center gap-2">
|
||||
<TeamFlag team={left} className={flagCls} />
|
||||
<span className="truncate text-[15px] font-extrabold">{teamShort(left, lang)}</span>
|
||||
{isBaseball && <RankBadge rank={match.extras?.standings?.a?.rank} lang={lang} />}
|
||||
{isClub && <RankBadge rank={leftSt?.rank} lang={lang} />}
|
||||
</div>
|
||||
{match.result ? (
|
||||
<span className="whitespace-nowrap font-mono text-[18px] font-extrabold tabular-nums text-white">
|
||||
@@ -480,17 +519,17 @@ function MatchCard({
|
||||
{rightScore}
|
||||
</span>
|
||||
) : phase === "live" && live?.score ? (
|
||||
// 진행 중 실시간 스코어 (A=원정, B=홈)
|
||||
// 진행 중 실시간 스코어 — flip 시(MLS) 홈 먼저
|
||||
<span className="whitespace-nowrap font-mono text-[18px] font-extrabold tabular-nums text-white">
|
||||
{live.score.away ?? 0}
|
||||
{(flip ? live.score.home : live.score.away) ?? 0}
|
||||
<span className="px-1.5 text-[#FF5B5B]">:</span>
|
||||
{live.score.home ?? 0}
|
||||
{(flip ? live.score.away : live.score.home) ?? 0}
|
||||
</span>
|
||||
) : (
|
||||
<span className="font-impact text-[18px] italic text-[#94FBE0]">VS</span>
|
||||
)}
|
||||
<div className="flex items-center justify-end gap-2">
|
||||
{isBaseball && <RankBadge rank={match.extras?.standings?.b?.rank} lang={lang} />}
|
||||
{isClub && <RankBadge rank={rightSt?.rank} lang={lang} />}
|
||||
<span className="truncate text-right text-[15px] font-extrabold">{teamShort(right, lang)}</span>
|
||||
<TeamFlag team={right} className={flagCls} />
|
||||
</div>
|
||||
@@ -506,6 +545,16 @@ function MatchCard({
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* MLS: 최근 5경기 폼 (프리뷰 캐시 있을 때만) — 홈(왼쪽) 먼저 */}
|
||||
{isMls && !match.result && (match.extras?.formA || match.extras?.formB) && (
|
||||
<div className="mt-2 text-center text-[11px] font-semibold text-white/50">
|
||||
<span className="text-white/35">{lang === "en" ? "Last 5" : "최근 5경기"}</span>{" "}
|
||||
<FormBadges form={match.extras?.formB} />
|
||||
<span className="px-1 text-white/30">vs</span>
|
||||
<FormBadges form={match.extras?.formA} />
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* 투표 가능 조만: AI 픽 갈림 + 참여수 + 이동 화살표 (취소 경기는 숨김) */}
|
||||
{match.votable && phase !== "cancelled" && (
|
||||
<div className="mt-3 flex items-center justify-between text-[11px] font-bold text-[#F4F3FE]">
|
||||
@@ -556,9 +605,12 @@ function aiSplit(match: Match, lang: Lang): string[] {
|
||||
else if (p.outcome === "DRAW") tally.d++;
|
||||
else tally.b++;
|
||||
}
|
||||
const out: string[] = [];
|
||||
if (tally.a) out.push(`${teamShort(match.teamA, lang)} ${tally.a}`);
|
||||
if (tally.d) out.push(`${t.draw} ${tally.d}`);
|
||||
if (tally.b) out.push(`${teamShort(match.teamB, lang)} ${tally.b}`);
|
||||
const entA = tally.a ? `${teamShort(match.teamA, lang)} ${tally.a}` : null;
|
||||
const entD = tally.d ? `${t.draw} ${tally.d}` : null;
|
||||
const entB = tally.b ? `${teamShort(match.teamB, lang)} ${tally.b}` : null;
|
||||
// MLS 는 홈 팀 먼저 (카드 좌우 표시와 동일 순서)
|
||||
const out = (match.league === "mls" ? [entB, entD, entA] : [entA, entD, entB]).filter(
|
||||
(x): x is string => !!x,
|
||||
);
|
||||
return out.length ? out : ["-"];
|
||||
}
|
||||
@@ -4,7 +4,7 @@ import { type Lang, teamShort } from "@/lib/i18n";
|
||||
import type { StandingRow, StandingsOut } from "@/lib/types";
|
||||
import TeamFlag from "./TeamFlag";
|
||||
|
||||
// 야구 리그 순위표 — KBO: 단일 테이블 · MLB: 디비전 6그룹.
|
||||
// 리그 순위표 — KBO: 단일 테이블 · MLB: 디비전 6그룹 · MLS: 컨퍼런스 2그룹(승점제).
|
||||
// 데이터는 워커가 캐싱한 시즌 순위(/api/standings)로, 하루 수회 갱신된다.
|
||||
const DIV_LABEL: Record<string, { ko: string; en: string }> = {
|
||||
ALE: { ko: "AL 동부", en: "AL East" },
|
||||
@@ -13,6 +13,8 @@ const DIV_LABEL: Record<string, { ko: string; en: string }> = {
|
||||
NLE: { ko: "NL 동부", en: "NL East" },
|
||||
NLC: { ko: "NL 중부", en: "NL Central" },
|
||||
NLW: { ko: "NL 서부", en: "NL West" },
|
||||
EAST: { ko: "동부 컨퍼런스", en: "Eastern Conference" },
|
||||
WEST: { ko: "서부 컨퍼런스", en: "Western Conference" },
|
||||
};
|
||||
|
||||
function fmtWra(v: StandingRow["wra"]): string {
|
||||
@@ -71,7 +73,8 @@ export default function StandingsTable({
|
||||
);
|
||||
}
|
||||
|
||||
const hasDraw = league === "kbo"; // KBO 만 무승부 존재
|
||||
const hasDraw = league === "kbo" || league === "mls"; // 무승부 존재 리그
|
||||
const isPoints = league === "mls"; // 승점제 (승률/게임차 대신 승점/득실차)
|
||||
|
||||
return (
|
||||
<div className="flex flex-col gap-4">
|
||||
@@ -87,13 +90,25 @@ export default function StandingsTable({
|
||||
<tr className="text-[11px] font-bold text-white/40">
|
||||
<th className="w-7 py-1 text-center font-bold">{lang === "en" ? "#" : "순위"}</th>
|
||||
<th className="py-1 text-left font-bold">{lang === "en" ? "Team" : "팀"}</th>
|
||||
{isPoints && (
|
||||
<th className="w-8 py-1 text-center font-bold">{lang === "en" ? "GP" : "경기"}</th>
|
||||
)}
|
||||
<th className="w-8 py-1 text-center font-bold">{lang === "en" ? "W" : "승"}</th>
|
||||
{hasDraw && (
|
||||
<th className="w-8 py-1 text-center font-bold">{lang === "en" ? "D" : "무"}</th>
|
||||
)}
|
||||
<th className="w-8 py-1 text-center font-bold">{lang === "en" ? "L" : "패"}</th>
|
||||
<th className="w-12 py-1 text-center font-bold">{lang === "en" ? "PCT" : "승률"}</th>
|
||||
<th className="w-10 py-1 text-center font-bold">{lang === "en" ? "GB" : "게임차"}</th>
|
||||
{isPoints ? (
|
||||
<>
|
||||
<th className="w-10 py-1 text-center font-bold">{lang === "en" ? "Pts" : "승점"}</th>
|
||||
<th className="w-10 py-1 text-center font-bold">{lang === "en" ? "GD" : "득실"}</th>
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
<th className="w-12 py-1 text-center font-bold">{lang === "en" ? "PCT" : "승률"}</th>
|
||||
<th className="w-10 py-1 text-center font-bold">{lang === "en" ? "GB" : "게임차"}</th>
|
||||
</>
|
||||
)}
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@@ -112,13 +127,25 @@ export default function StandingsTable({
|
||||
<span className="truncate font-bold">{teamShort(r, lang)}</span>
|
||||
</span>
|
||||
</td>
|
||||
{isPoints && (
|
||||
<td className="py-1.5 text-center font-mono text-white/60">{r.gp ?? "-"}</td>
|
||||
)}
|
||||
<td className="py-1.5 text-center font-mono text-white/80">{r.w ?? "-"}</td>
|
||||
{hasDraw && (
|
||||
<td className="py-1.5 text-center font-mono text-white/50">{r.d ?? "-"}</td>
|
||||
)}
|
||||
<td className="py-1.5 text-center font-mono text-white/80">{r.l ?? "-"}</td>
|
||||
<td className="py-1.5 text-center font-mono font-bold text-white">{fmtWra(r.wra)}</td>
|
||||
<td className="py-1.5 text-center font-mono text-white/60">{fmtGb(r.gb)}</td>
|
||||
{isPoints ? (
|
||||
<>
|
||||
<td className="py-1.5 text-center font-mono font-bold text-white">{r.pts ?? "-"}</td>
|
||||
<td className="py-1.5 text-center font-mono text-white/60">{r.diff ?? "-"}</td>
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
<td className="py-1.5 text-center font-mono font-bold text-white">{fmtWra(r.wra)}</td>
|
||||
<td className="py-1.5 text-center font-mono text-white/60">{fmtGb(r.gb)}</td>
|
||||
</>
|
||||
)}
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
|
||||
@@ -60,6 +60,22 @@ export interface LiveBatter {
|
||||
sub?: boolean;
|
||||
}
|
||||
|
||||
export interface LiveGoal {
|
||||
clock: string; // "9'"
|
||||
team: string; // 팀 코드
|
||||
player: string;
|
||||
assist?: string; // 어시스트 선수 (없으면 "")
|
||||
ownGoal?: boolean;
|
||||
penalty?: boolean;
|
||||
}
|
||||
|
||||
export interface LiveCard {
|
||||
clock: string;
|
||||
team: string; // 팀 코드
|
||||
player: string;
|
||||
red?: boolean; // true=레드(퇴장), false=옐로
|
||||
}
|
||||
|
||||
export interface LiveData {
|
||||
available: boolean;
|
||||
inn?: number;
|
||||
@@ -72,6 +88,46 @@ export interface LiveData {
|
||||
vsRecord?: string;
|
||||
defense?: { pos?: string; name: string }[];
|
||||
offenseLineup?: LiveBatter[];
|
||||
// MLS(축구) 라이브 — soccer=true 일 때만
|
||||
soccer?: boolean;
|
||||
clock?: string; // "45'"
|
||||
period?: number; // 1=전반 2=후반
|
||||
state?: string; // pre | in | post
|
||||
goals?: LiveGoal[];
|
||||
cards?: LiveCard[];
|
||||
subs?: LiveSub[];
|
||||
lineups?: {
|
||||
away?: SoccerLineup;
|
||||
home?: SoccerLineup;
|
||||
} | null;
|
||||
commentary?: LiveCommentary[]; // 문자중계 (ESPN 영문, 최신순)
|
||||
}
|
||||
|
||||
export interface LiveCommentary {
|
||||
clock: string;
|
||||
text: string;
|
||||
goal?: boolean;
|
||||
}
|
||||
|
||||
export interface LiveSub {
|
||||
clock: string;
|
||||
team: string;
|
||||
inName: string;
|
||||
outName: string;
|
||||
}
|
||||
|
||||
export interface SoccerPlayer {
|
||||
name: string;
|
||||
pos: string;
|
||||
jersey: string;
|
||||
in: boolean; // 교체 투입됨
|
||||
out: boolean; // 교체 아웃됨
|
||||
}
|
||||
|
||||
export interface SoccerLineup {
|
||||
formation?: string | null;
|
||||
starters: SoccerPlayer[];
|
||||
bench: SoccerPlayer[];
|
||||
}
|
||||
|
||||
export function getLive(matchId: string): Promise<LiveData> {
|
||||
|
||||
@@ -229,8 +229,8 @@ export const DICT: Record<Lang, Dict> = {
|
||||
"Independent AI prediction game — not affiliated with, endorsed by, or sponsored by FIFA or the official World Cup.",
|
||||
footerDisc1: "FIFA 및 공식 월드컵과 무관한 독립 AI 예측 게임입니다 (제휴·후원·운영 아님).",
|
||||
footerNotOfficialBB:
|
||||
"Independent AI prediction game — not affiliated with, endorsed by, or sponsored by KBO, MLB, or any club.",
|
||||
footerDisc1BB: "KBO·MLB 리그 및 각 구단과 무관한 독립 AI 예측 게임입니다 (제휴·후원·운영 아님).",
|
||||
"Independent AI prediction game — not affiliated with, endorsed by, or sponsored by KBO, MLB, MLS, or any club.",
|
||||
footerDisc1BB: "KBO·MLB·MLS 리그 및 각 구단과 무관한 독립 AI 예측 게임입니다 (제휴·후원·운영 아님).",
|
||||
footerDisc2: "스포츠 분석·엔터테인먼트 목적의 예측 게임이며 베팅·도박을 권유하지 않습니다. AI 예측은 실제 결과를 보장하지 않습니다.",
|
||||
footerDisc3: "100만 원 이벤트는 무료 참여형 챌린지입니다. 지급·동점 처리 조건은 별도 약관에 따릅니다. 이메일은 결과·이벤트 알림 목적으로만 사용됩니다.",
|
||||
hook: (a, b) => `${a} vs ${b}, AI의 선택은 갈렸다`,
|
||||
@@ -337,7 +337,7 @@ export const DICT: Record<Lang, Dict> = {
|
||||
"Independent AI prediction game — not affiliated with, endorsed by, or sponsored by FIFA or the official World Cup.",
|
||||
footerDisc1: "A fan-run prediction game using public match schedules; all picks are independent.",
|
||||
footerNotOfficialBB:
|
||||
"Independent AI prediction game — not affiliated with, endorsed by, or sponsored by KBO, MLB, or any club.",
|
||||
"Independent AI prediction game — not affiliated with, endorsed by, or sponsored by KBO, MLB, MLS, or any club.",
|
||||
footerDisc1BB: "A fan-run prediction game using public match schedules; all picks are independent.",
|
||||
footerDisc2: "A sports-analysis & entertainment prediction game. No betting or gambling. AI predictions do not guarantee real outcomes.",
|
||||
footerDisc3: "The ₩1,000,000 event is a free-to-enter challenge. Payout & tie-break terms follow separate rules. Email is used only for result & event alerts.",
|
||||
|
||||
@@ -42,8 +42,8 @@ export interface CrowdStats {
|
||||
teamBWin: number;
|
||||
}
|
||||
|
||||
// 리그: wc(월드컵 축구) | kbo | mlb
|
||||
export type League = "wc" | "kbo" | "mlb";
|
||||
// 리그: wc(월드컵 축구) | kbo | mlb | mls
|
||||
export type League = "wc" | "kbo" | "mlb" | "mls";
|
||||
|
||||
// 야구 부가정보 (프리뷰·순위 캐시 — 없으면 undefined)
|
||||
export interface StarterInfo {
|
||||
@@ -63,11 +63,18 @@ export interface TeamStanding {
|
||||
wra?: string | number;
|
||||
gb?: string | number;
|
||||
last5?: string | null;
|
||||
// MLS(승점제) 전용
|
||||
gp?: number;
|
||||
pts?: number;
|
||||
gf?: number;
|
||||
ga?: number;
|
||||
diff?: string | null;
|
||||
}
|
||||
|
||||
// /standings 응답 — 팀 정보(Team) + 시즌 성적 한 행
|
||||
export interface StandingRow extends Team, TeamStanding {
|
||||
div?: string | null; // MLB 디비전 키 (ALE/ALC/ALW/NLE/NLC/NLW)
|
||||
// MLB 디비전(ALE/ALC/ALW/NLE/NLC/NLW) 또는 MLS 컨퍼런스(EAST/WEST) 키
|
||||
div?: string | null;
|
||||
}
|
||||
|
||||
export interface StandingsOut {
|
||||
@@ -81,6 +88,18 @@ export interface MatchExtras {
|
||||
starterB?: StarterInfo | null;
|
||||
seasonVs?: { aWin?: number; draw?: number; bWin?: number } | null;
|
||||
standings?: { a?: TeamStanding | null; b?: TeamStanding | null };
|
||||
// MLS 프리뷰 (ESPN) — 최근5 폼("WWLDW")·시즌 전적("8-2-4")·맞대결
|
||||
formA?: string | null;
|
||||
formB?: string | null;
|
||||
recordA?: string | null;
|
||||
recordB?: string | null;
|
||||
h2h?: {
|
||||
date: string;
|
||||
home: string;
|
||||
away: string;
|
||||
scoreH: number;
|
||||
scoreA: number;
|
||||
}[];
|
||||
}
|
||||
|
||||
export interface Match {
|
||||
|
||||
@@ -9,7 +9,9 @@ export function useLeague(): [League, (l: League) => void] {
|
||||
const [params, setParams] = useSearchParams();
|
||||
const raw = params.get("league");
|
||||
const league: League =
|
||||
raw === "wc" || raw === "kbo" || raw === "mlb" ? raw : DEFAULT_LEAGUE;
|
||||
raw === "wc" || raw === "kbo" || raw === "mlb" || raw === "mls"
|
||||
? raw
|
||||
: DEFAULT_LEAGUE;
|
||||
const setLeague = (l: League) => {
|
||||
const next = new URLSearchParams(params);
|
||||
next.set("league", l);
|
||||
|
||||
@@ -9,8 +9,8 @@ import { useLeague } from "@/lib/useLeague";
|
||||
export default function Leaderboard() {
|
||||
const lang = useLang();
|
||||
const [league] = useLeague();
|
||||
// 야구(KBO/MLB)는 랭킹 운영 방침(상금 등) 미확정 — 임시 비노출
|
||||
const isBaseball = league === "kbo" || league === "mlb";
|
||||
// 월드컵 외 리그(KBO/MLB/MLS)는 랭킹 운영 방침(상금 등) 미확정 — 임시 비노출
|
||||
const isBaseball = league !== "wc";
|
||||
|
||||
return (
|
||||
<main className="shell">
|
||||
|
||||
@@ -3,6 +3,7 @@ import { Link, useParams } from "react-router-dom";
|
||||
import Hero from "@/components/Hero";
|
||||
import MatchupHUD from "@/components/MatchupHUD";
|
||||
import LiveField from "@/components/LiveField";
|
||||
import LiveSoccer from "@/components/LiveSoccer";
|
||||
import Arena from "@/components/Arena";
|
||||
import Comments from "@/components/Comments";
|
||||
import Footer from "@/components/Footer";
|
||||
@@ -58,11 +59,17 @@ export default function MatchDetail() {
|
||||
|
||||
const aShort = teamShort(match.teamA, lang);
|
||||
const bShort = teamShort(match.teamB, lang);
|
||||
// 한국을 항상 왼쪽에 표시(요청)와 동일하게 공유 제목/후킹 카피도 한국 먼저.
|
||||
const flip = match.teamB.code === "KOR" && match.teamA.code !== "KOR";
|
||||
// 월드컵: 한국을 항상 왼쪽에. MLS: 홈 팀 먼저(축구 관례) — 제목/후킹 카피 동일 순서.
|
||||
const isMls = match.league === "mls";
|
||||
const flip = isMls || (match.teamB.code === "KOR" && match.teamA.code !== "KOR");
|
||||
const leftShort = flip ? bShort : aShort;
|
||||
const rightShort = flip ? aShort : bShort;
|
||||
const hook = lang === "en" ? t.hook(leftShort, rightShort) : match.hookText;
|
||||
const hook =
|
||||
lang === "en"
|
||||
? t.hook(leftShort, rightShort)
|
||||
: isMls
|
||||
? `${leftShort} vs ${rightShort}` // 저장된 hookText 는 원정-홈 순이라 재구성
|
||||
: match.hookText;
|
||||
const url = matchUrl(match.matchId);
|
||||
|
||||
return (
|
||||
@@ -90,6 +97,8 @@ export default function MatchDetail() {
|
||||
|
||||
<MatchupHUD match={match} lang={lang} />
|
||||
<LiveField match={match} lang={lang} />
|
||||
{/* MLS 라이브 (축구) — 경기중에만 렌더, 야구 리그에선 null */}
|
||||
<LiveSoccer match={match} lang={lang} />
|
||||
<Arena
|
||||
match={match}
|
||||
predictions={match.predictions}
|
||||
|
||||
Reference in new issue
Block a user