Compare commits
5
Commits
b115072005
...
release/86
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2004ea03fe | ||
|
|
8ec9edc35f | ||
|
|
61f1db0e6a | ||
|
|
c9140b8622 | ||
|
|
4e10998794 |
No files matched your search
@@ -0,0 +1,4 @@
|
||||
[mcp_servers.playwright_macos]
|
||||
url = "http://100.96.0.26:8931/mcp"
|
||||
tool_timeout_sec = 120
|
||||
startup_timeout_sec = 30
|
||||
@@ -28,6 +28,8 @@ website/LICENSE
|
||||
!AGENTS.md
|
||||
!docs/specs/internal-match-game-analysis.md
|
||||
!docs/plans/internal-match-game-analysis-p0-p1.md
|
||||
!docs/specs/double-elimination-connector-routing.md
|
||||
!docs/plans/double-elimination-connector-routing.md
|
||||
!agents/**/*.md
|
||||
!skills/**/*.md
|
||||
/tmp/
|
||||
|
||||
@@ -51,6 +51,11 @@ export interface SeriesDefinition {
|
||||
{ position: 'B'; source: ParticipantSource },
|
||||
];
|
||||
rule: SeriesRule;
|
||||
schedule?: {
|
||||
date: string;
|
||||
time: string | null;
|
||||
timeZone: 'Asia/Seoul';
|
||||
};
|
||||
activation?: {
|
||||
type: 'grand-final-reset-required';
|
||||
grandFinalSeriesId: string;
|
||||
|
||||
@@ -1,6 +1,110 @@
|
||||
import { projectSeries } from './series-projector';
|
||||
|
||||
describe('projectSeries', () => {
|
||||
it.each([
|
||||
['a known local time', '21:30'],
|
||||
['an unknown local time', null],
|
||||
] as const)('preserves an optional Series schedule with %s', (_, time) => {
|
||||
const schedule = {
|
||||
date: '2026-07-15',
|
||||
time,
|
||||
timeZone: 'Asia/Seoul' as const,
|
||||
};
|
||||
const definition = {
|
||||
...seriesDefinition({
|
||||
id: `series-scheduled-${time ?? 'unknown'}`,
|
||||
stage: 'upper',
|
||||
rule: { type: 'first-to' as const, winsRequired: 1, maxGames: 1 },
|
||||
}),
|
||||
schedule,
|
||||
};
|
||||
|
||||
const projection = projectSeries({
|
||||
definition,
|
||||
participants: ['team-8', 'team-3'],
|
||||
facts: [],
|
||||
});
|
||||
|
||||
expect(projection).toMatchObject({
|
||||
status: 'ready',
|
||||
schedule,
|
||||
});
|
||||
});
|
||||
|
||||
it('keeps an existing definition without a schedule explicitly unscheduled', () => {
|
||||
const definition = seriesDefinition({
|
||||
id: 'series-unscheduled',
|
||||
stage: 'upper',
|
||||
rule: { type: 'first-to', winsRequired: 1, maxGames: 1 },
|
||||
});
|
||||
|
||||
const projection = projectSeries({
|
||||
definition,
|
||||
participants: ['team-8', 'team-3'],
|
||||
facts: [],
|
||||
});
|
||||
|
||||
expect(projection).not.toHaveProperty('schedule');
|
||||
});
|
||||
|
||||
it.each([
|
||||
[
|
||||
'an impossible calendar date',
|
||||
{ date: '2026-02-30', time: '21:30', timeZone: 'Asia/Seoul' },
|
||||
],
|
||||
[
|
||||
'an out-of-range local time',
|
||||
{ date: '2026-07-15', time: '24:00', timeZone: 'Asia/Seoul' },
|
||||
],
|
||||
[
|
||||
'a non-canonical time zone',
|
||||
{ date: '2026-07-15', time: '21:30', timeZone: 'UTC' },
|
||||
],
|
||||
])('rejects a Series schedule with %s', (_, schedule) => {
|
||||
const definition = {
|
||||
...seriesDefinition({
|
||||
id: `series-invalid-schedule-${schedule.date}-${schedule.time}`,
|
||||
stage: 'upper',
|
||||
rule: { type: 'first-to' as const, winsRequired: 1, maxGames: 1 },
|
||||
}),
|
||||
schedule,
|
||||
} as unknown as Parameters<typeof projectSeries>[0]['definition'];
|
||||
|
||||
expectInvariant(
|
||||
() =>
|
||||
projectSeries({
|
||||
definition,
|
||||
participants: ['team-8', 'team-3'],
|
||||
facts: [],
|
||||
}),
|
||||
'SERIES_DEFINITION_INVALID',
|
||||
);
|
||||
});
|
||||
|
||||
it.each([null, false, ''])(
|
||||
'rejects a non-object Series schedule value %p',
|
||||
(schedule) => {
|
||||
const definition = {
|
||||
...seriesDefinition({
|
||||
id: 'series-invalid-schedule-shape',
|
||||
stage: 'upper',
|
||||
rule: { type: 'first-to' as const, winsRequired: 1, maxGames: 1 },
|
||||
}),
|
||||
schedule,
|
||||
} as unknown as Parameters<typeof projectSeries>[0]['definition'];
|
||||
|
||||
expectInvariant(
|
||||
() =>
|
||||
projectSeries({
|
||||
definition,
|
||||
participants: ['team-8', 'team-3'],
|
||||
facts: [],
|
||||
}),
|
||||
'SERIES_DEFINITION_INVALID',
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
it('keeps a fixed-games pair in progress until every game slot is filled', () => {
|
||||
const definition = seriesDefinition({
|
||||
id: 'series-pair',
|
||||
|
||||
@@ -13,6 +13,12 @@ export type SeriesRule =
|
||||
drawPolicy: 'allow' | 'tiebreak-required';
|
||||
};
|
||||
|
||||
export interface SeriesSchedule {
|
||||
date: string;
|
||||
time: string | null;
|
||||
timeZone: 'Asia/Seoul';
|
||||
}
|
||||
|
||||
export interface SeriesDefinitionLike {
|
||||
id: string;
|
||||
code?: string;
|
||||
@@ -26,6 +32,7 @@ export interface SeriesDefinitionLike {
|
||||
source: Readonly<Record<string, unknown>>;
|
||||
}>;
|
||||
rule: SeriesRule;
|
||||
schedule?: SeriesSchedule;
|
||||
gameSlots: ReadonlyArray<{
|
||||
id: string;
|
||||
seriesId: string;
|
||||
@@ -75,6 +82,7 @@ interface SeriesProjectionBase {
|
||||
code?: string;
|
||||
stage: SeriesDefinitionLike['stage'];
|
||||
rule: SeriesRule;
|
||||
schedule?: SeriesSchedule;
|
||||
entries: [SeriesProjectionEntry, SeriesProjectionEntry];
|
||||
}
|
||||
|
||||
@@ -311,6 +319,15 @@ function validateDefinition(definition: SeriesDefinitionLike): void {
|
||||
`Series ${definition.id} must define exactly the local A and B slots`,
|
||||
);
|
||||
|
||||
const schedule: unknown = definition.schedule;
|
||||
if (schedule !== undefined) {
|
||||
assertCompetitionInvariant(
|
||||
isSeriesSchedule(schedule),
|
||||
'SERIES_DEFINITION_INVALID',
|
||||
`Series ${definition.id} has an invalid schedule`,
|
||||
);
|
||||
}
|
||||
|
||||
const requiredSlots =
|
||||
definition.rule.type === 'fixed-games'
|
||||
? definition.rule.gameCount
|
||||
@@ -753,6 +770,7 @@ function projectionBase(
|
||||
...(definition.code ? { code: definition.code } : {}),
|
||||
stage: definition.stage,
|
||||
rule: definition.rule,
|
||||
...(definition.schedule ? { schedule: { ...definition.schedule } } : {}),
|
||||
entries: [
|
||||
{ slot: 'A', teamId: participants[0], gameWins: 0 },
|
||||
{ slot: 'B', teamId: participants[1], gameWins: 0 },
|
||||
@@ -760,6 +778,35 @@ function projectionBase(
|
||||
};
|
||||
}
|
||||
|
||||
function isValidLocalDate(value: string): boolean {
|
||||
const match = /^(\d{4})-(\d{2})-(\d{2})$/.exec(value);
|
||||
if (!match) return false;
|
||||
const year = Number(match[1]);
|
||||
const month = Number(match[2]);
|
||||
const day = Number(match[3]);
|
||||
const date = new Date(Date.UTC(year, month - 1, day));
|
||||
return (
|
||||
date.getUTCFullYear() === year &&
|
||||
date.getUTCMonth() === month - 1 &&
|
||||
date.getUTCDate() === day
|
||||
);
|
||||
}
|
||||
|
||||
function isSeriesSchedule(value: unknown): value is SeriesSchedule {
|
||||
if (typeof value !== 'object' || value === null || Array.isArray(value)) {
|
||||
return false;
|
||||
}
|
||||
const schedule = value as Record<string, unknown>;
|
||||
return (
|
||||
typeof schedule.date === 'string' &&
|
||||
isValidLocalDate(schedule.date) &&
|
||||
(schedule.time === null ||
|
||||
(typeof schedule.time === 'string' &&
|
||||
/^(?:[01]\d|2[0-3]):[0-5]\d$/.test(schedule.time))) &&
|
||||
schedule.timeZone === 'Asia/Seoul'
|
||||
);
|
||||
}
|
||||
|
||||
function entriesFor(
|
||||
participants: [string, string],
|
||||
winsByTeam: Map<string, number>,
|
||||
|
||||
@@ -3,7 +3,7 @@ VITE_DEFAULT_COMMUNITY_ID=69ebe0adf627c11be2f020a1
|
||||
VITE_MSAL_CLIENT_ID=66dadf46-418c-43c8-a908-3c15dcc0465d
|
||||
VITE_MSAL_AUTHORITY=https://login.microsoftonline.com/5ef88004-e953-4b04-93db-64bbf49c6863
|
||||
VITE_MSAL_API_SCOPE=api://15fb5a20-47e0-44fa-9a41-b50ca9d0e7e3/lolympus-tournament-support-dev
|
||||
VITE_MSAL_REDIRECT_URI=https://release-83.lolympus.pages.dev/auth/callback
|
||||
VITE_MSAL_REDIRECT_URI=https://release-86.lolympus.pages.dev/auth/callback
|
||||
VITE_NEW_RELIC_ENABLED=true
|
||||
VITE_NEW_RELIC_APPLICATION_ID=601654991
|
||||
VITE_NEW_RELIC_ACCOUNT_ID=8100154
|
||||
@@ -11,6 +11,6 @@ VITE_NEW_RELIC_AGENT_ID=601654991
|
||||
VITE_NEW_RELIC_LICENSE_KEY=NRJS-caad7f6e90b92fe88de
|
||||
VITE_NEW_RELIC_TRUST_KEY=8100154
|
||||
VITE_NEW_RELIC_BEACON=bam.nr-data.net
|
||||
VITE_NEW_RELIC_APPLICATION_VERSION=83
|
||||
VITE_NEW_RELIC_RELEASE_ID=release-83
|
||||
VITE_NEW_RELIC_APPLICATION_VERSION=86
|
||||
VITE_NEW_RELIC_RELEASE_ID=release-86
|
||||
VITE_NEW_RELIC_RELEASE_NAME=lolympus-web
|
||||
@@ -55,14 +55,14 @@ export function CompetitionGameHistory({
|
||||
to={detailPath}
|
||||
state={{
|
||||
backTo: historyBackTo,
|
||||
backLabel: "경기 결과로 돌아가기",
|
||||
backLabel: "경기 일정·결과로 돌아가기",
|
||||
}}
|
||||
className="block min-h-11 border-l-2 border-l-transparent px-2 py-2 text-xs text-base-content transition-colors hover:border-l-primary hover:bg-primary/[0.06] active:bg-primary/10 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-primary motion-reduce:transition-none"
|
||||
className="grid min-h-14 items-center px-2 py-2 text-xs leading-5 text-base-content transition-colors hover:bg-primary/[0.06] active:bg-primary/10 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-primary motion-reduce:transition-none"
|
||||
>
|
||||
{content}
|
||||
</Link>
|
||||
) : (
|
||||
<div className="min-h-11 border-l-2 border-l-transparent px-2 py-2 text-xs text-base-content">
|
||||
<div className="grid min-h-14 items-center px-2 py-2 text-xs leading-5 text-base-content">
|
||||
{content}
|
||||
</div>
|
||||
)}
|
||||
@@ -84,50 +84,57 @@ function GameHistoryRowContent({
|
||||
duration: string | null;
|
||||
linked: boolean;
|
||||
}) {
|
||||
const startedAt = formatCompetitionHistoryTime(game.startedAt);
|
||||
|
||||
return (
|
||||
<span
|
||||
className={
|
||||
linked
|
||||
? "grid grid-cols-[3.75rem_3.25rem_minmax(0,1fr)_3.5rem] items-center gap-2 md:grid-cols-[4.5rem_4rem_minmax(0,1fr)_4.5rem_6rem] md:gap-4"
|
||||
: "grid grid-cols-[3.75rem_3.25rem_minmax(0,1fr)_3.5rem] items-center gap-2 md:grid-cols-[4.5rem_4rem_minmax(0,1fr)_4.5rem] md:gap-4"
|
||||
}
|
||||
>
|
||||
<span className="font-bold text-content-muted">
|
||||
{game.ordinal}게임
|
||||
</span>
|
||||
<time
|
||||
dateTime={game.startedAt}
|
||||
className="font-mono tabular-nums text-content-muted"
|
||||
>
|
||||
{formatCompetitionHistoryTime(game.startedAt) ?? "—"}
|
||||
</time>
|
||||
<span className="min-w-0 break-words font-semibold">
|
||||
<span className="grid w-full min-w-0 grid-cols-[minmax(0,1fr)_auto] items-center gap-x-3 gap-y-1.5 md:grid-cols-[minmax(10rem,1fr)_minmax(12rem,2fr)_minmax(10rem,1fr)] md:gap-4">
|
||||
<span className="col-span-2 row-start-1 min-w-0 break-words text-center font-semibold leading-5 md:col-span-1 md:col-start-2 md:row-start-1">
|
||||
{winnerName} 승
|
||||
</span>
|
||||
<span
|
||||
className="text-right font-mono tabular-nums text-content-muted"
|
||||
>
|
||||
{duration ? (
|
||||
<>
|
||||
<span className="sr-only">경기 시간 </span>
|
||||
{duration}
|
||||
</>
|
||||
|
||||
<span className="col-start-1 row-start-2 flex min-w-0 items-center gap-3 text-content-muted md:col-start-1 md:row-start-1">
|
||||
<span className="shrink-0 font-bold leading-5">
|
||||
{game.ordinal}게임
|
||||
</span>
|
||||
{startedAt ? (
|
||||
<time
|
||||
dateTime={game.startedAt}
|
||||
className="shrink-0 font-mono leading-5 tabular-nums"
|
||||
>
|
||||
{startedAt}
|
||||
</time>
|
||||
) : (
|
||||
<>
|
||||
<span className="shrink-0 font-mono leading-5 tabular-nums">
|
||||
<span aria-hidden="true">—</span>
|
||||
<span className="sr-only">경기 시간 기록 없음</span>
|
||||
</>
|
||||
<span className="sr-only">시작 시각 기록 없음</span>
|
||||
</span>
|
||||
)}
|
||||
</span>
|
||||
{linked && (
|
||||
<span className="col-span-4 mt-1 flex items-center justify-end gap-0.5 font-bold text-content-subtle md:col-span-1 md:mt-0">
|
||||
<span>상세 분석</span>
|
||||
<ChevronRight
|
||||
className="h-3.5 w-3.5 shrink-0 text-primary"
|
||||
aria-hidden="true"
|
||||
/>
|
||||
|
||||
<span className="col-start-2 row-start-2 flex min-w-0 items-center justify-end gap-3 leading-5 md:col-start-3 md:row-start-1">
|
||||
<span className="shrink-0 text-right font-mono tabular-nums text-content-muted">
|
||||
{duration ? (
|
||||
<>
|
||||
<span className="sr-only">경기 시간 </span>
|
||||
{duration}
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
<span aria-hidden="true">—</span>
|
||||
<span className="sr-only">경기 시간 기록 없음</span>
|
||||
</>
|
||||
)}
|
||||
</span>
|
||||
)}
|
||||
{linked && (
|
||||
<span className="flex shrink-0 items-center justify-end gap-0.5 font-bold text-content-subtle">
|
||||
<span>상세 분석</span>
|
||||
<ChevronRight
|
||||
className="h-3.5 w-3.5 shrink-0 text-primary"
|
||||
aria-hidden="true"
|
||||
/>
|
||||
</span>
|
||||
)}
|
||||
</span>
|
||||
</span>
|
||||
);
|
||||
}
|
||||
@@ -24,17 +24,18 @@ export function CompetitionResults({
|
||||
const teamById = new Map(
|
||||
competition.teams.map((team) => [team.teamId, team]),
|
||||
);
|
||||
const seriesHistory =
|
||||
view === "bracket" ? [] : createCompetitionSeriesHistory(projection);
|
||||
|
||||
if (view === "games") {
|
||||
const hasSeriesHistory =
|
||||
createCompetitionSeriesHistory(projection).length > 0;
|
||||
const hasSeriesHistory = seriesHistory.length > 0;
|
||||
return (
|
||||
<div className="mb-6">
|
||||
{hasSeriesHistory ? (
|
||||
<CompetitionSeriesHistory
|
||||
communityId={competition.communityId}
|
||||
matchId={competition.matchId}
|
||||
projection={projection}
|
||||
history={seriesHistory}
|
||||
teamById={teamById}
|
||||
/>
|
||||
) : (
|
||||
@@ -42,7 +43,7 @@ export function CompetitionResults({
|
||||
className="border border-dashed border-base-content/15 px-4 py-8 text-center text-sm text-base-content/45"
|
||||
role="status"
|
||||
>
|
||||
기록된 공식 경기가 없습니다.
|
||||
예정되거나 기록된 공식 경기가 없습니다.
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
@@ -62,7 +63,7 @@ export function CompetitionResults({
|
||||
Competition
|
||||
</p>
|
||||
<h2 id="competition-heading" className="mt-1 text-lg font-bold">
|
||||
공식 경기 결과
|
||||
공식 경기 일정·결과
|
||||
</h2>
|
||||
</div>
|
||||
<div className="flex items-center gap-3">
|
||||
@@ -114,7 +115,7 @@ export function CompetitionResults({
|
||||
<CompetitionSeriesHistory
|
||||
communityId={competition.communityId}
|
||||
matchId={competition.matchId}
|
||||
projection={projection}
|
||||
history={seriesHistory}
|
||||
teamById={teamById}
|
||||
/>
|
||||
)}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import type {
|
||||
CommunityId,
|
||||
CompetitionProjection,
|
||||
CompetitionTeamView,
|
||||
MatchId,
|
||||
TeamId,
|
||||
@@ -9,14 +8,16 @@ import { ChevronDown } from "lucide-react";
|
||||
import { useState } from "react";
|
||||
import { useLocation } from "react-router";
|
||||
import {
|
||||
createCompetitionSeriesHistory,
|
||||
formatCompetitionHistoryDayHeading,
|
||||
formatCompetitionHistoryTime,
|
||||
formatCompetitionHistoryDate,
|
||||
getSeriesHistoryRecordLabel,
|
||||
getSeriesHistoryResultLabel,
|
||||
getSeriesHistoryStatusLabel,
|
||||
getSeriesHistoryTimePresentation,
|
||||
isCompetitionHistoryCalendarDate,
|
||||
shouldDisplaySeriesHistoryScore,
|
||||
type CompetitionSeriesHistoryDay,
|
||||
type CompetitionSeriesHistoryRow,
|
||||
type CompetitionSeriesHistorySeries,
|
||||
} from "./competition-series-history";
|
||||
import { CompetitionGameHistory } from "./CompetitionGameHistory";
|
||||
import { bracketRoundLabel } from "./double-elimination-bracket-layout";
|
||||
@@ -25,22 +26,29 @@ import { isSeriesEntryWinner } from "./series-score-card-model";
|
||||
export function CompetitionSeriesHistory({
|
||||
communityId,
|
||||
matchId,
|
||||
projection,
|
||||
history,
|
||||
teamById,
|
||||
}: {
|
||||
communityId: CommunityId;
|
||||
matchId: MatchId;
|
||||
projection: CompetitionProjection;
|
||||
history: CompetitionSeriesHistoryDay[];
|
||||
teamById: ReadonlyMap<TeamId, CompetitionTeamView>;
|
||||
}) {
|
||||
const location = useLocation();
|
||||
const historyPath = `${location.pathname}${location.search}`;
|
||||
const history = createCompetitionSeriesHistory(projection);
|
||||
if (history.length === 0) return null;
|
||||
const resultCount = history.reduce(
|
||||
(count, day) => count + day.rows.length,
|
||||
0,
|
||||
);
|
||||
|
||||
const rows = history.flatMap((day) => day.rows);
|
||||
const anchorRow =
|
||||
rows.find((row) => row.series.status === "in-progress") ??
|
||||
rows.find((row) => isFutureSeries(row.series)) ??
|
||||
rows.at(-1);
|
||||
const jumpLabel =
|
||||
anchorRow?.series.status === "in-progress"
|
||||
? "진행 중 경기로"
|
||||
: anchorRow && isFutureSeries(anchorRow.series)
|
||||
? "다음 경기로"
|
||||
: "최근 결과로";
|
||||
|
||||
return (
|
||||
<section
|
||||
@@ -53,18 +61,18 @@ export function CompetitionSeriesHistory({
|
||||
id="competition-series-history-heading"
|
||||
className="text-sm font-bold"
|
||||
>
|
||||
경기 결과 기록
|
||||
경기 일정·결과
|
||||
</h3>
|
||||
<p className="mt-0.5 text-xs text-content-muted">
|
||||
진행 중인 시리즈와 최종 결과를 실제 경기 기록 순서로 보여줍니다.
|
||||
예정 경기부터 최종 결과까지 날짜순으로 보여줍니다.
|
||||
</p>
|
||||
</div>
|
||||
{resultCount > 1 && (
|
||||
{rows.length > 1 && anchorRow && (
|
||||
<a
|
||||
href="#competition-series-history-latest"
|
||||
href="#competition-series-history-current"
|
||||
className="inline-flex min-h-11 shrink-0 items-center gap-1 px-2 text-xs font-bold text-content-muted transition-colors hover:bg-base-content/[0.03] hover:text-base-content focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-primary"
|
||||
>
|
||||
최신 결과로
|
||||
{jumpLabel}
|
||||
<ChevronDown
|
||||
className="h-4 w-4 text-primary"
|
||||
aria-hidden="true"
|
||||
@@ -73,63 +81,50 @@ export function CompetitionSeriesHistory({
|
||||
)}
|
||||
</header>
|
||||
|
||||
<div
|
||||
className="hidden border-b border-base-content/10 bg-base-200/30 px-4 py-2 text-[11px] font-bold text-content-muted lg:grid lg:grid-cols-[minmax(0,1fr)_9rem_11rem_8rem] lg:gap-4"
|
||||
aria-hidden="true"
|
||||
>
|
||||
<span>경기 결과</span>
|
||||
<span>라운드</span>
|
||||
<span>기록 시각 · 상태</span>
|
||||
<span className="text-right">게임 상세</span>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
{history.map((day, dayIndex) => {
|
||||
{history.map((day) => {
|
||||
const headingId = historyDayHeadingId(day.dateKey);
|
||||
const dayHeading = formatCompetitionHistoryDayHeading(
|
||||
day.dateKey,
|
||||
day.rows.length,
|
||||
);
|
||||
const dateLabel = formatCompetitionHistoryDate(day.dateKey);
|
||||
return (
|
||||
<section key={day.dateKey} aria-labelledby={headingId}>
|
||||
<h4
|
||||
id={headingId}
|
||||
className="scroll-mt-24 border-b border-base-content/10 bg-base-200/60 px-4 py-3 text-sm font-bold"
|
||||
className="scroll-mt-24 flex items-center justify-between gap-3 border-b border-base-content/10 bg-base-200/60 px-4 py-3 text-sm font-bold"
|
||||
>
|
||||
{day.dateKey === "unknown" ? (
|
||||
dayHeading
|
||||
{isCompetitionHistoryCalendarDate(day.dateKey) ? (
|
||||
<time dateTime={day.dateKey}>{dateLabel}</time>
|
||||
) : (
|
||||
<time dateTime={day.dateKey}>
|
||||
{dayHeading}
|
||||
</time>
|
||||
<span>{dateLabel}</span>
|
||||
)}
|
||||
<span className="shrink-0 text-xs font-semibold text-content-muted">
|
||||
{day.rows.length}경기
|
||||
</span>
|
||||
</h4>
|
||||
<ol className="divide-y divide-base-content/10">
|
||||
{day.rows.map((row, rowIndex) => {
|
||||
const isLatestResult =
|
||||
dayIndex === history.length - 1 &&
|
||||
rowIndex === day.rows.length - 1;
|
||||
return (
|
||||
<li
|
||||
key={row.series.seriesId}
|
||||
id={
|
||||
isLatestResult
|
||||
? "competition-series-history-latest"
|
||||
: undefined
|
||||
}
|
||||
className={isLatestResult ? "scroll-mt-24" : undefined}
|
||||
>
|
||||
<SeriesHistoryRow
|
||||
row={row}
|
||||
teamById={teamById}
|
||||
communityId={communityId}
|
||||
matchId={matchId}
|
||||
historyPath={historyPath}
|
||||
currentHash={location.hash}
|
||||
/>
|
||||
</li>
|
||||
);
|
||||
})}
|
||||
{day.rows.map((row) => (
|
||||
<li
|
||||
key={row.series.seriesId}
|
||||
id={
|
||||
row.series.seriesId === anchorRow?.series.seriesId
|
||||
? "competition-series-history-current"
|
||||
: undefined
|
||||
}
|
||||
className={
|
||||
row.series.seriesId === anchorRow?.series.seriesId
|
||||
? "scroll-mt-24"
|
||||
: undefined
|
||||
}
|
||||
>
|
||||
<SeriesHistoryRow
|
||||
row={row}
|
||||
teamById={teamById}
|
||||
communityId={communityId}
|
||||
matchId={matchId}
|
||||
historyPath={historyPath}
|
||||
currentHash={location.hash}
|
||||
/>
|
||||
</li>
|
||||
))}
|
||||
</ol>
|
||||
</section>
|
||||
);
|
||||
@@ -204,8 +199,6 @@ function SeriesSummary({
|
||||
}) {
|
||||
const { series } = row;
|
||||
const statusLabel = getSeriesHistoryStatusLabel(series);
|
||||
const timeLabel = formatCompetitionHistoryTime(row.occurredAt);
|
||||
const timeKind = row.timestampSource === "game-start" ? "시작" : "결정";
|
||||
const roundLabel = bracketRoundLabel(
|
||||
series.stage.type,
|
||||
series.stage.roundNumber,
|
||||
@@ -215,89 +208,98 @@ function SeriesSummary({
|
||||
row.games.length,
|
||||
false,
|
||||
);
|
||||
const showRecordLabel = hasGameDetails || !isFutureSeries(series);
|
||||
|
||||
return (
|
||||
<span className="block px-4 py-3 lg:grid lg:min-h-20 lg:grid-cols-[minmax(0,1fr)_9rem_11rem_8rem] lg:items-center lg:gap-4">
|
||||
<span className="block">
|
||||
<span className="block px-4 py-3 lg:grid lg:min-h-20 lg:grid-cols-[minmax(13rem,1fr)_minmax(20rem,2fr)_minmax(13rem,1fr)] lg:items-center lg:gap-4">
|
||||
<span className="block min-w-0 lg:col-start-2 lg:row-start-1">
|
||||
<SeriesMatchup row={row} teamById={teamById} />
|
||||
</span>
|
||||
|
||||
<span className="mt-3 flex min-w-0 flex-wrap items-center gap-x-3 gap-y-2 lg:contents">
|
||||
<span className="mt-3 flex min-w-0 flex-wrap items-center gap-x-3 gap-y-2 lg:col-start-1 lg:row-start-1 lg:mt-0 lg:flex-col lg:items-start lg:gap-1.5">
|
||||
<span className="flex min-w-0 flex-wrap items-center gap-2">
|
||||
<HistoryTime row={row} />
|
||||
<StatusLabel series={series} label={statusLabel} />
|
||||
</span>
|
||||
<span className="min-w-0 break-words text-xs leading-4 text-content-muted">
|
||||
{roundLabel}
|
||||
</span>
|
||||
<span className="flex min-w-0 flex-wrap items-center gap-2">
|
||||
<HistoryTime
|
||||
occurredAt={row.occurredAt}
|
||||
timeKind={timeKind}
|
||||
timeLabel={timeLabel}
|
||||
/>
|
||||
<StatusLabel
|
||||
label={statusLabel}
|
||||
inProgress={series.status === "in-progress"}
|
||||
/>
|
||||
</span>
|
||||
</span>
|
||||
|
||||
<span className="mt-2 flex min-h-6 items-center justify-end text-xs font-bold text-content-muted lg:mt-0">
|
||||
{hasGameDetails ? (
|
||||
<>
|
||||
<span className="group-open:hidden">{closedRecordLabel}</span>
|
||||
<span className="hidden group-open:inline">
|
||||
{getSeriesHistoryRecordLabel(series, row.games.length, true)}
|
||||
</span>
|
||||
<ChevronDown
|
||||
className="ml-1 h-4 w-4 text-primary transition-transform group-open:rotate-180 motion-reduce:transition-none"
|
||||
aria-hidden="true"
|
||||
/>
|
||||
</>
|
||||
) : (
|
||||
<span>{closedRecordLabel}</span>
|
||||
)}
|
||||
</span>
|
||||
{showRecordLabel && (
|
||||
<span className="mt-2 flex min-h-6 items-center justify-end text-xs font-bold text-content-muted lg:col-start-3 lg:row-start-1 lg:mt-0">
|
||||
{hasGameDetails ? (
|
||||
<>
|
||||
<span className="group-open:hidden">{closedRecordLabel}</span>
|
||||
<span className="hidden group-open:inline">
|
||||
{getSeriesHistoryRecordLabel(series, row.games.length, true)}
|
||||
</span>
|
||||
<ChevronDown
|
||||
className="ml-1 h-4 w-4 text-primary transition-transform group-open:rotate-180 motion-reduce:transition-none"
|
||||
aria-hidden="true"
|
||||
/>
|
||||
</>
|
||||
) : (
|
||||
<span>{closedRecordLabel}</span>
|
||||
)}
|
||||
</span>
|
||||
)}
|
||||
</span>
|
||||
);
|
||||
}
|
||||
|
||||
function HistoryTime({
|
||||
occurredAt,
|
||||
timeKind,
|
||||
timeLabel,
|
||||
}: {
|
||||
occurredAt: string;
|
||||
timeKind: "시작" | "결정";
|
||||
timeLabel: string | null;
|
||||
}) {
|
||||
return timeLabel ? (
|
||||
<time
|
||||
dateTime={occurredAt}
|
||||
className="shrink-0 text-xs font-bold tabular-nums text-content-muted"
|
||||
>
|
||||
{timeKind} <span className="font-mono">{timeLabel}</span>
|
||||
</time>
|
||||
) : (
|
||||
<span className="shrink-0 text-xs font-bold text-content-muted">
|
||||
<span aria-hidden="true">{timeKind} —</span>
|
||||
<span className="sr-only">{timeKind} 시각 기록 없음</span>
|
||||
function HistoryTime({ row }: { row: CompetitionSeriesHistoryRow }) {
|
||||
const presentation = getSeriesHistoryTimePresentation(row);
|
||||
const kindLabel =
|
||||
row.timestampSource === "decision"
|
||||
? "결정"
|
||||
: row.timestampSource === "scheduled" ||
|
||||
row.timestampSource === "unavailable"
|
||||
? "예정"
|
||||
: "시작";
|
||||
|
||||
if (presentation.dateTime) {
|
||||
return (
|
||||
<time
|
||||
dateTime={presentation.dateTime}
|
||||
aria-label={`${kindLabel} 시각 ${presentation.text}`}
|
||||
className="shrink-0 text-sm font-bold tabular-nums text-base-content"
|
||||
>
|
||||
{row.timestampSource === "decision" && (
|
||||
<span className="mr-1 text-xs text-content-muted">결정</span>
|
||||
)}
|
||||
<span className="font-mono">{presentation.text}</span>
|
||||
</time>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<span className="shrink-0 text-sm font-bold text-content-muted">
|
||||
<span aria-hidden="true" className="font-mono tabular-nums">
|
||||
{presentation.text}
|
||||
</span>
|
||||
{presentation.screenReaderText && (
|
||||
<span className="sr-only">{presentation.screenReaderText}</span>
|
||||
)}
|
||||
</span>
|
||||
);
|
||||
}
|
||||
|
||||
function StatusLabel({
|
||||
series,
|
||||
label,
|
||||
inProgress,
|
||||
}: {
|
||||
series: CompetitionSeriesHistorySeries;
|
||||
label: string;
|
||||
inProgress: boolean;
|
||||
}) {
|
||||
const tone =
|
||||
series.status === "in-progress"
|
||||
? "bg-primary/10 text-base-content"
|
||||
: series.status === "inactive"
|
||||
? "bg-info/10 text-base-content"
|
||||
: "bg-base-200 text-content-muted";
|
||||
return (
|
||||
<span
|
||||
className={`shrink-0 px-1.5 py-0.5 text-xs font-bold ${
|
||||
inProgress
|
||||
? "border-l-2 border-primary bg-primary/10 text-base-content"
|
||||
: "border-l-2 border-base-content/15 bg-base-200 text-base-content"
|
||||
}`}
|
||||
>
|
||||
<span className={`shrink-0 px-1.5 py-0.5 text-xs font-bold ${tone}`}>
|
||||
{label}
|
||||
</span>
|
||||
);
|
||||
@@ -317,7 +319,6 @@ function SeriesMatchup({
|
||||
const teamBWon = isSeriesEntryWinner(row.series, entryB.teamId);
|
||||
const showScore = shouldDisplaySeriesHistoryScore(row.series);
|
||||
const resultLabel = getSeriesHistoryResultLabel(row.series);
|
||||
const statusLabel = getSeriesHistoryStatusLabel(row.series);
|
||||
const officialWinnerTeamId =
|
||||
row.series.status === "completed" && row.series.outcome.type !== "draw"
|
||||
? row.series.outcome.winnerTeamId
|
||||
@@ -327,11 +328,10 @@ function SeriesMatchup({
|
||||
: `${teamAName} 대 ${teamBName}`;
|
||||
const accessibleResult = [
|
||||
matchupAnnouncement,
|
||||
resultLabel,
|
||||
resultLabel === "VS" ? null : resultLabel,
|
||||
officialWinnerTeamId
|
||||
? `${teamName(officialWinnerTeamId, teamById)} 승`
|
||||
: null,
|
||||
statusLabel,
|
||||
]
|
||||
.filter((part): part is string => Boolean(part))
|
||||
.join(", ");
|
||||
@@ -339,7 +339,7 @@ function SeriesMatchup({
|
||||
return (
|
||||
<>
|
||||
<span
|
||||
className="grid grid-cols-[minmax(0,1fr)_5rem_minmax(0,1fr)] items-center gap-2"
|
||||
className="grid w-full grid-cols-[minmax(0,1fr)_4.5rem_minmax(0,1fr)] items-center gap-2 sm:grid-cols-[minmax(0,1fr)_5rem_minmax(0,1fr)]"
|
||||
aria-hidden="true"
|
||||
>
|
||||
<TeamName name={teamAName} winner={teamAWon} align="right" />
|
||||
@@ -367,8 +367,10 @@ function SeriesMatchup({
|
||||
<span
|
||||
className={
|
||||
showScore
|
||||
? "mt-0.5 text-[11px] font-bold leading-4 text-content-muted"
|
||||
: "text-sm font-bold leading-5 text-base-content"
|
||||
? "mt-0.5 text-xs font-bold leading-4 text-content-muted"
|
||||
: row.series.status === "completed"
|
||||
? "text-sm font-bold leading-5 text-base-content"
|
||||
: "text-sm font-bold leading-5 text-content-muted"
|
||||
}
|
||||
>
|
||||
{resultLabel}
|
||||
@@ -393,26 +395,35 @@ function TeamName({
|
||||
}) {
|
||||
return (
|
||||
<span
|
||||
className={`min-w-0 break-words text-sm leading-5 ${
|
||||
align === "right" ? "text-right" : "text-left"
|
||||
className={`flex min-h-10 min-w-0 items-center gap-1 text-sm leading-5 ${
|
||||
align === "right" ? "justify-end text-right" : "justify-start text-left"
|
||||
} ${winner ? "font-bold text-base-content" : "text-content-subtle"}`}
|
||||
aria-hidden="true"
|
||||
>
|
||||
{name}
|
||||
<span className="min-w-0 break-words">{name}</span>
|
||||
{winner && (
|
||||
<span className="ml-1 text-xs font-bold text-base-content">승</span>
|
||||
<span className="shrink-0 text-xs font-bold text-base-content">승</span>
|
||||
)}
|
||||
</span>
|
||||
);
|
||||
}
|
||||
|
||||
function teamName(
|
||||
teamId: TeamId,
|
||||
teamId: TeamId | null,
|
||||
teamById: ReadonlyMap<TeamId, CompetitionTeamView>,
|
||||
): string {
|
||||
if (teamId === null) return "미정";
|
||||
return teamById.get(teamId)?.name ?? "알 수 없는 팀";
|
||||
}
|
||||
|
||||
function isFutureSeries(series: CompetitionSeriesHistorySeries): boolean {
|
||||
return (
|
||||
series.status === "inactive" ||
|
||||
series.status === "waiting" ||
|
||||
series.status === "ready"
|
||||
);
|
||||
}
|
||||
|
||||
function historyDayHeadingId(dateKey: string): string {
|
||||
return `competition-series-history-day-${dateKey}`;
|
||||
}
|
||||
|
||||
@@ -104,7 +104,11 @@ export function SeriesScoreCard({
|
||||
{presentation.label}
|
||||
</span>
|
||||
</header>
|
||||
<div className="divide-y divide-base-content/8">
|
||||
<div
|
||||
className={
|
||||
isBracket ? "relative" : "divide-y divide-base-content/8"
|
||||
}
|
||||
>
|
||||
{series.entries.map((entry) => {
|
||||
const team = entry.teamId ? teamById.get(entry.teamId) : undefined;
|
||||
const isWinner = isSeriesEntryWinner(series, entry.teamId);
|
||||
@@ -129,6 +133,13 @@ export function SeriesScoreCard({
|
||||
/>
|
||||
);
|
||||
})}
|
||||
{isBracket && (
|
||||
<span
|
||||
className="pointer-events-none absolute inset-x-0 border-t border-base-content/8"
|
||||
style={{ top: SERIES_SCORE_CARD_GEOMETRY.entryHeight }}
|
||||
aria-hidden="true"
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
</article>
|
||||
);
|
||||
|
||||
@@ -3,19 +3,24 @@ import type {
|
||||
CompetitionProjection,
|
||||
IsoDateTime,
|
||||
SeriesProjection,
|
||||
SeriesSchedule,
|
||||
} from "@lolympus/contracts";
|
||||
import { internalMatchGamePath } from "../../lib/internal-match-routes.ts";
|
||||
|
||||
export type CompetitionSeriesHistorySeries = Extract<
|
||||
SeriesProjection,
|
||||
{ status: "in-progress" | "completed" }
|
||||
>;
|
||||
export type CompetitionSeriesHistorySeries = SeriesProjection;
|
||||
|
||||
export type CompetitionSeriesHistoryTimestampSource =
|
||||
| "game-start"
|
||||
| "decision"
|
||||
| "scheduled"
|
||||
| "unavailable";
|
||||
|
||||
export interface CompetitionSeriesHistoryRow {
|
||||
series: CompetitionSeriesHistorySeries;
|
||||
games: CompetitionGameView[];
|
||||
occurredAt: IsoDateTime;
|
||||
timestampSource: "game-start" | "decision";
|
||||
occurredAt: IsoDateTime | null;
|
||||
timestampSource: CompetitionSeriesHistoryTimestampSource;
|
||||
dateKey: string;
|
||||
}
|
||||
|
||||
export interface CompetitionSeriesHistoryDay {
|
||||
@@ -23,6 +28,12 @@ export interface CompetitionSeriesHistoryDay {
|
||||
rows: CompetitionSeriesHistoryRow[];
|
||||
}
|
||||
|
||||
export interface SeriesHistoryTimePresentation {
|
||||
text: string;
|
||||
dateTime: string | null;
|
||||
screenReaderText: string | null;
|
||||
}
|
||||
|
||||
type HistoryProjection = Pick<CompetitionProjection, "series" | "games">;
|
||||
|
||||
const KOREAN_WEEKDAYS = [
|
||||
@@ -35,6 +46,9 @@ const KOREAN_WEEKDAYS = [
|
||||
"토",
|
||||
] as const;
|
||||
|
||||
const UNKNOWN_DATE_KEY = "unknown";
|
||||
const UNKNOWN_RECORD_DATE_KEY = "record-unknown";
|
||||
|
||||
export function competitionHistoryGameDetailPath(
|
||||
communityId: string,
|
||||
matchId: string,
|
||||
@@ -62,38 +76,72 @@ export function createCompetitionSeriesHistory(
|
||||
const games = [...(gamesBySeriesId.get(series.seriesId) ?? [])].sort(
|
||||
compareGames,
|
||||
);
|
||||
if (series.status === "in-progress") {
|
||||
const occurredAt = earliestStartedAt(games);
|
||||
if (!occurredAt) continue;
|
||||
rows.push({
|
||||
series,
|
||||
games,
|
||||
occurredAt,
|
||||
timestampSource: "game-start",
|
||||
});
|
||||
continue;
|
||||
}
|
||||
if (series.status !== "completed") continue;
|
||||
|
||||
const gameStartedAt = earliestStartedAt(games);
|
||||
rows.push({
|
||||
series,
|
||||
games,
|
||||
occurredAt: gameStartedAt ?? series.outcome.completedAt,
|
||||
timestampSource: gameStartedAt ? "game-start" : "decision",
|
||||
});
|
||||
switch (series.status) {
|
||||
case "completed": {
|
||||
if (hasInvalidStartedAt(games)) {
|
||||
rows.push(missingRecordedGameTimeRow(series, games));
|
||||
break;
|
||||
}
|
||||
const gameStartedAt = earliestStartedAt(games);
|
||||
if (games.length > 0 && !gameStartedAt) {
|
||||
rows.push(missingRecordedGameTimeRow(series, games));
|
||||
break;
|
||||
}
|
||||
const occurredAt = gameStartedAt ?? series.outcome.completedAt;
|
||||
rows.push({
|
||||
series,
|
||||
games,
|
||||
occurredAt,
|
||||
timestampSource: gameStartedAt ? "game-start" : "decision",
|
||||
dateKey:
|
||||
dateKeyInTimeZone(occurredAt, timeZone) ??
|
||||
UNKNOWN_RECORD_DATE_KEY,
|
||||
});
|
||||
break;
|
||||
}
|
||||
case "in-progress": {
|
||||
if (hasInvalidStartedAt(games)) {
|
||||
rows.push(missingRecordedGameTimeRow(series, games));
|
||||
break;
|
||||
}
|
||||
const gameStartedAt = earliestStartedAt(games);
|
||||
if (gameStartedAt) {
|
||||
rows.push({
|
||||
series,
|
||||
games,
|
||||
occurredAt: gameStartedAt,
|
||||
timestampSource: "game-start",
|
||||
dateKey:
|
||||
dateKeyInTimeZone(gameStartedAt, timeZone) ??
|
||||
UNKNOWN_RECORD_DATE_KEY,
|
||||
});
|
||||
} else if (games.length > 0) {
|
||||
rows.push(missingRecordedGameTimeRow(series, games));
|
||||
} else if (series.schedule) {
|
||||
rows.push(scheduledRow(series, games));
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "ready":
|
||||
case "waiting":
|
||||
rows.push(scheduledRow(series, games));
|
||||
break;
|
||||
case "inactive":
|
||||
if (series.schedule) rows.push(scheduledRow(series, games));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
rows.sort(compareRows);
|
||||
|
||||
const days: CompetitionSeriesHistoryDay[] = [];
|
||||
for (const row of rows) {
|
||||
const dateKey = dateKeyInTimeZone(row.occurredAt, timeZone);
|
||||
const currentDay = days.at(-1);
|
||||
if (currentDay?.dateKey === dateKey) {
|
||||
if (currentDay?.dateKey === row.dateKey) {
|
||||
currentDay.rows.push(row);
|
||||
} else {
|
||||
days.push({ dateKey, rows: [row] });
|
||||
days.push({ dateKey: row.dateKey, rows: [row] });
|
||||
}
|
||||
}
|
||||
return days;
|
||||
@@ -102,13 +150,29 @@ export function createCompetitionSeriesHistory(
|
||||
export function getSeriesHistoryStatusLabel(
|
||||
series: CompetitionSeriesHistorySeries,
|
||||
): string {
|
||||
if (series.status === "in-progress") return "진행 중";
|
||||
return "최종";
|
||||
switch (series.status) {
|
||||
case "inactive":
|
||||
return "필요 시";
|
||||
case "waiting":
|
||||
case "ready":
|
||||
return "예정";
|
||||
case "in-progress":
|
||||
return "진행 중";
|
||||
case "completed":
|
||||
return "최종";
|
||||
}
|
||||
}
|
||||
|
||||
export function getSeriesHistoryResultLabel(
|
||||
series: CompetitionSeriesHistorySeries,
|
||||
): string | null {
|
||||
if (
|
||||
series.status === "inactive" ||
|
||||
series.status === "waiting" ||
|
||||
series.status === "ready"
|
||||
) {
|
||||
return "VS";
|
||||
}
|
||||
if (series.status === "in-progress") return null;
|
||||
switch (series.outcome.type) {
|
||||
case "played":
|
||||
@@ -134,6 +198,13 @@ export function getSeriesHistoryRecordLabel(
|
||||
if (gameCount > 0) {
|
||||
return expanded ? "게임 상세 접기" : `게임 상세 (${gameCount})`;
|
||||
}
|
||||
if (
|
||||
series.status === "inactive" ||
|
||||
series.status === "waiting" ||
|
||||
series.status === "ready"
|
||||
) {
|
||||
return "게임 전";
|
||||
}
|
||||
if (isGameLessDecision(series)) return "경기 없이 결정";
|
||||
return "게임 기록 미등록";
|
||||
}
|
||||
@@ -142,12 +213,58 @@ export function shouldDisplaySeriesHistoryScore(
|
||||
series: CompetitionSeriesHistorySeries,
|
||||
): boolean {
|
||||
if (series.status === "in-progress") return true;
|
||||
if (series.status !== "completed") return false;
|
||||
if (series.outcome.type === "played") return true;
|
||||
return (
|
||||
series.outcome.type === "draw" && series.outcome.basis.type === "played"
|
||||
);
|
||||
}
|
||||
|
||||
export function getSeriesHistoryTimePresentation(
|
||||
row: CompetitionSeriesHistoryRow,
|
||||
): SeriesHistoryTimePresentation {
|
||||
if (row.timestampSource === "scheduled") {
|
||||
const schedule = row.series.schedule;
|
||||
if (
|
||||
schedule?.time &&
|
||||
isValidLocalDate(schedule.date) &&
|
||||
isValidLocalTime(schedule.time)
|
||||
) {
|
||||
return {
|
||||
text: schedule.time,
|
||||
dateTime: localScheduleDateTime(schedule),
|
||||
screenReaderText: null,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
if (row.timestampSource === "unavailable") {
|
||||
return {
|
||||
text: "--:--",
|
||||
dateTime: null,
|
||||
screenReaderText: "시작 시간 미정",
|
||||
};
|
||||
}
|
||||
|
||||
const text = row.occurredAt
|
||||
? formatCompetitionHistoryTime(row.occurredAt)
|
||||
: null;
|
||||
if (text && row.occurredAt) {
|
||||
return {
|
||||
text,
|
||||
dateTime: row.occurredAt,
|
||||
screenReaderText: null,
|
||||
};
|
||||
}
|
||||
|
||||
const kind = row.timestampSource === "decision" ? "결정" : "시작";
|
||||
return {
|
||||
text: "—",
|
||||
dateTime: null,
|
||||
screenReaderText: `${kind} 시각 기록 없음`,
|
||||
};
|
||||
}
|
||||
|
||||
export function formatSeriesGameDuration(
|
||||
durationSeconds: number,
|
||||
): string | null {
|
||||
@@ -163,8 +280,9 @@ export function formatSeriesGameDuration(
|
||||
}
|
||||
|
||||
export function formatCompetitionHistoryDate(dateKey: string): string {
|
||||
if (dateKey === UNKNOWN_RECORD_DATE_KEY) return "기록 일시 미상";
|
||||
const match = /^(\d{4})-(\d{2})-(\d{2})$/.exec(dateKey);
|
||||
if (!match) return "일시 정보 없음";
|
||||
if (!match) return "일정 미정";
|
||||
const year = Number(match[1]);
|
||||
const month = Number(match[2]);
|
||||
const day = Number(match[3]);
|
||||
@@ -174,16 +292,13 @@ export function formatCompetitionHistoryDate(dateKey: string): string {
|
||||
date.getUTCMonth() !== month - 1 ||
|
||||
date.getUTCDate() !== day
|
||||
) {
|
||||
return "일시 정보 없음";
|
||||
return "일정 미정";
|
||||
}
|
||||
return `${month}월 ${day}일 (${KOREAN_WEEKDAYS[date.getUTCDay()]})`;
|
||||
return `${month}월 ${padNumber(day)}일 (${KOREAN_WEEKDAYS[date.getUTCDay()]})`;
|
||||
}
|
||||
|
||||
export function formatCompetitionHistoryDayHeading(
|
||||
dateKey: string,
|
||||
gameCount: number,
|
||||
): string {
|
||||
return `${formatCompetitionHistoryDate(dateKey)} · ${gameCount}경기`;
|
||||
export function isCompetitionHistoryCalendarDate(dateKey: string): boolean {
|
||||
return isValidLocalDate(dateKey);
|
||||
}
|
||||
|
||||
export function formatCompetitionHistoryTime(
|
||||
@@ -205,6 +320,47 @@ export function formatCompetitionHistoryTime(
|
||||
return hour && minute ? `${hour}:${minute}` : null;
|
||||
}
|
||||
|
||||
function scheduledRow(
|
||||
series: CompetitionSeriesHistorySeries,
|
||||
games: CompetitionGameView[],
|
||||
): CompetitionSeriesHistoryRow {
|
||||
const schedule = series.schedule;
|
||||
const dateKey =
|
||||
schedule && isValidLocalDate(schedule.date)
|
||||
? schedule.date
|
||||
: UNKNOWN_DATE_KEY;
|
||||
const occurredAt =
|
||||
schedule?.time &&
|
||||
isValidLocalTime(schedule.time) &&
|
||||
dateKey !== UNKNOWN_DATE_KEY
|
||||
? localScheduleDateTime(schedule)
|
||||
: null;
|
||||
return {
|
||||
series,
|
||||
games,
|
||||
occurredAt,
|
||||
timestampSource: occurredAt ? "scheduled" : "unavailable",
|
||||
dateKey,
|
||||
};
|
||||
}
|
||||
|
||||
function missingRecordedGameTimeRow(
|
||||
series: CompetitionSeriesHistorySeries,
|
||||
games: CompetitionGameView[],
|
||||
): CompetitionSeriesHistoryRow {
|
||||
return {
|
||||
series,
|
||||
games,
|
||||
occurredAt: null,
|
||||
timestampSource: "game-start",
|
||||
dateKey: UNKNOWN_RECORD_DATE_KEY,
|
||||
};
|
||||
}
|
||||
|
||||
function localScheduleDateTime(schedule: SeriesSchedule): IsoDateTime {
|
||||
return `${schedule.date}T${schedule.time}:00+09:00`;
|
||||
}
|
||||
|
||||
function compareGames(
|
||||
left: CompetitionGameView,
|
||||
right: CompetitionGameView,
|
||||
@@ -221,12 +377,32 @@ function compareRows(
|
||||
right: CompetitionSeriesHistoryRow,
|
||||
): number {
|
||||
return (
|
||||
timestampValue(left.occurredAt) - timestampValue(right.occurredAt) ||
|
||||
compareDateKeys(left.dateKey, right.dateKey) ||
|
||||
rowTimeValue(left) - rowTimeValue(right) ||
|
||||
left.series.stage.displayOrder - right.series.stage.displayOrder ||
|
||||
left.series.seriesId.localeCompare(right.series.seriesId)
|
||||
);
|
||||
}
|
||||
|
||||
function compareDateKeys(left: string, right: string): number {
|
||||
if (left === right) return 0;
|
||||
const leftRank = dateKeyRank(left);
|
||||
const rightRank = dateKeyRank(right);
|
||||
if (leftRank !== rightRank) return leftRank - rightRank;
|
||||
return left.localeCompare(right);
|
||||
}
|
||||
|
||||
function dateKeyRank(dateKey: string): number {
|
||||
if (dateKey === UNKNOWN_RECORD_DATE_KEY) return 1;
|
||||
if (dateKey === UNKNOWN_DATE_KEY) return 2;
|
||||
return 0;
|
||||
}
|
||||
|
||||
function rowTimeValue(row: CompetitionSeriesHistoryRow): number {
|
||||
if (!row.occurredAt) return Number.POSITIVE_INFINITY;
|
||||
return timestampValue(row.occurredAt);
|
||||
}
|
||||
|
||||
function earliestStartedAt(games: CompetitionGameView[]): IsoDateTime | null {
|
||||
let earliest: { value: number; startedAt: IsoDateTime } | null = null;
|
||||
for (const game of games) {
|
||||
@@ -239,9 +415,18 @@ function earliestStartedAt(games: CompetitionGameView[]): IsoDateTime | null {
|
||||
return earliest?.startedAt ?? null;
|
||||
}
|
||||
|
||||
function dateKeyInTimeZone(value: IsoDateTime, timeZone: string): string {
|
||||
function hasInvalidStartedAt(games: CompetitionGameView[]): boolean {
|
||||
return games.some(
|
||||
(game) => !Number.isFinite(timestampValue(game.startedAt)),
|
||||
);
|
||||
}
|
||||
|
||||
function dateKeyInTimeZone(
|
||||
value: IsoDateTime,
|
||||
timeZone: string,
|
||||
): string | null {
|
||||
const date = new Date(value);
|
||||
if (Number.isNaN(date.getTime())) return "unknown";
|
||||
if (Number.isNaN(date.getTime())) return null;
|
||||
const parts = new Intl.DateTimeFormat("en-US", {
|
||||
timeZone,
|
||||
year: "numeric",
|
||||
@@ -253,7 +438,7 @@ function dateKeyInTimeZone(value: IsoDateTime, timeZone: string): string {
|
||||
const year = part("year");
|
||||
const month = part("month");
|
||||
const day = part("day");
|
||||
return year && month && day ? `${year}-${month}-${day}` : "unknown";
|
||||
return year && month && day ? `${year}-${month}-${day}` : null;
|
||||
}
|
||||
|
||||
function timestampValue(value: IsoDateTime): number {
|
||||
@@ -264,13 +449,31 @@ function timestampValue(value: IsoDateTime): number {
|
||||
function isGameLessDecision(
|
||||
series: CompetitionSeriesHistorySeries,
|
||||
): boolean {
|
||||
if (series.status === "in-progress") return false;
|
||||
if (series.status !== "completed") return false;
|
||||
if (series.outcome.type === "draw") {
|
||||
return series.outcome.basis.type !== "played";
|
||||
}
|
||||
return series.outcome.type !== "played";
|
||||
}
|
||||
|
||||
function isValidLocalDate(value: string): boolean {
|
||||
const match = /^(\d{4})-(\d{2})-(\d{2})$/.exec(value);
|
||||
if (!match) return false;
|
||||
const year = Number(match[1]);
|
||||
const month = Number(match[2]);
|
||||
const day = Number(match[3]);
|
||||
const date = new Date(Date.UTC(year, month - 1, day));
|
||||
return (
|
||||
date.getUTCFullYear() === year &&
|
||||
date.getUTCMonth() === month - 1 &&
|
||||
date.getUTCDate() === day
|
||||
);
|
||||
}
|
||||
|
||||
function isValidLocalTime(value: string): boolean {
|
||||
return /^(?:[01]\d|2[0-3]):[0-5]\d$/.test(value);
|
||||
}
|
||||
|
||||
function padNumber(value: number): string {
|
||||
return value.toString().padStart(2, "0");
|
||||
}
|
||||
@@ -17,6 +17,8 @@ export const DOUBLE_ELIMINATION_BRACKET_GEOMETRY = {
|
||||
boardPadding: 12,
|
||||
columnWidth: 228,
|
||||
columnGap: 40,
|
||||
// Matches the widest focused connector underlay so parallel routes stay legible.
|
||||
connectorRailClearance: 5,
|
||||
cardBorderWidth: SERIES_SCORE_CARD_GEOMETRY.borderWidth,
|
||||
cardHeight: SERIES_SCORE_CARD_GEOMETRY.height,
|
||||
cardHeaderHeight: SERIES_SCORE_CARD_GEOMETRY.headerHeight,
|
||||
@@ -109,6 +111,29 @@ interface NormalizedRound {
|
||||
seriesIds: SeriesId[];
|
||||
}
|
||||
|
||||
interface ConnectorRoute {
|
||||
connector: SeriesConnectorView;
|
||||
key: string;
|
||||
kind: BracketConnectorKind;
|
||||
targetColumn: number;
|
||||
targetNodeY: number;
|
||||
sourceX: number;
|
||||
sourceY: number;
|
||||
targetX: number;
|
||||
targetY: number;
|
||||
}
|
||||
|
||||
interface SeparateWinnerRailChoice {
|
||||
verticalXs: [number, number];
|
||||
crossings: number;
|
||||
distanceFromBaseline: number;
|
||||
distanceFromCenter: number;
|
||||
}
|
||||
|
||||
type OrthogonalSegment =
|
||||
| { orientation: "horizontal"; fixed: number; start: number; end: number }
|
||||
| { orientation: "vertical"; fixed: number; start: number; end: number };
|
||||
|
||||
const STAGE_ORDER: Record<BracketStage, number> = {
|
||||
upper: 0,
|
||||
lower: 1,
|
||||
@@ -126,6 +151,9 @@ const CONNECTOR_SELECTION_ORDER: Record<
|
||||
"slot-b": 3,
|
||||
};
|
||||
|
||||
// A focused 5px underlay extends 2.5px from its centerline.
|
||||
const CONNECTOR_RAIL_EDGE_INSET = 3;
|
||||
|
||||
export function createDoubleEliminationBracketLayout(
|
||||
projection: DoubleEliminationCompetitionProjection,
|
||||
configuration: DoubleEliminationBracketConfiguration,
|
||||
@@ -540,56 +568,53 @@ function buildConnectors(
|
||||
nodeById: Map<SeriesId, BracketNodeLayout>,
|
||||
): BracketConnectorLayout[] | null {
|
||||
const geometry = DOUBLE_ELIMINATION_BRACKET_GEOMETRY;
|
||||
const connectorsByTargetColumn = new Map<
|
||||
number,
|
||||
Array<{
|
||||
connector: SeriesConnectorView;
|
||||
source: BracketNodeLayout;
|
||||
target: BracketNodeLayout;
|
||||
}>
|
||||
>();
|
||||
const routes: ConnectorRoute[] = [];
|
||||
const routesByTargetColumn = new Map<number, ConnectorRoute[]>();
|
||||
for (const connector of projection.connectors) {
|
||||
const source = nodeById.get(connector.from.seriesId);
|
||||
const target = nodeById.get(connector.to.seriesId);
|
||||
if (!source || !target || target.column <= source.column) return null;
|
||||
const routes = connectorsByTargetColumn.get(target.column) ?? [];
|
||||
routes.push({ connector, source, target });
|
||||
connectorsByTargetColumn.set(target.column, routes);
|
||||
const route = {
|
||||
connector,
|
||||
key: connectorKey(connector),
|
||||
kind: connectorKind(connector.from.select),
|
||||
targetColumn: target.column,
|
||||
targetNodeY: target.y,
|
||||
sourceX: source.x + source.width,
|
||||
sourceY: connectorAnchorY(source, connector.from.select),
|
||||
targetX: target.x,
|
||||
targetY: targetSlotY(target, connector.to.slot),
|
||||
} satisfies ConnectorRoute;
|
||||
routes.push(route);
|
||||
const columnRoutes = routesByTargetColumn.get(target.column) ?? [];
|
||||
columnRoutes.push(route);
|
||||
routesByTargetColumn.set(target.column, columnRoutes);
|
||||
}
|
||||
|
||||
const verticalXByConnector = new Map<string, number>();
|
||||
for (const routes of connectorsByTargetColumn.values()) {
|
||||
routes.sort(
|
||||
for (const columnRoutes of routesByTargetColumn.values()) {
|
||||
columnRoutes.sort(
|
||||
(left, right) =>
|
||||
connectorAnchorY(right.source, right.connector.from.select) -
|
||||
connectorAnchorY(left.source, left.connector.from.select) ||
|
||||
targetSlotY(right.target, right.connector.to.slot) -
|
||||
targetSlotY(left.target, left.connector.to.slot) ||
|
||||
connectorKey(left.connector).localeCompare(connectorKey(right.connector)),
|
||||
right.sourceY - left.sourceY ||
|
||||
right.targetY - left.targetY ||
|
||||
left.key.localeCompare(right.key),
|
||||
);
|
||||
routes.forEach(({ connector, target }, index) => {
|
||||
columnRoutes.forEach(({ key, targetX }, index) => {
|
||||
verticalXByConnector.set(
|
||||
connectorKey(connector),
|
||||
target.x -
|
||||
key,
|
||||
targetX -
|
||||
geometry.columnGap +
|
||||
(geometry.columnGap * (index + 1)) / (routes.length + 1),
|
||||
(geometry.columnGap * (index + 1)) / (columnRoutes.length + 1),
|
||||
);
|
||||
});
|
||||
}
|
||||
if (!alignWinnerBundleRails(routes, verticalXByConnector)) return null;
|
||||
|
||||
const result: BracketConnectorLayout[] = [];
|
||||
for (const connector of projection.connectors) {
|
||||
const source = nodeById.get(connector.from.seriesId);
|
||||
const target = nodeById.get(connector.to.seriesId);
|
||||
if (!source || !target || target.column <= source.column) return null;
|
||||
|
||||
const sourceX = source.x + source.width;
|
||||
const targetX = target.x;
|
||||
const sourceY = connectorAnchorY(source, connector.from.select);
|
||||
const targetY = targetSlotY(target, connector.to.slot);
|
||||
const verticalX = verticalXByConnector.get(connectorKey(connector));
|
||||
for (const route of routes) {
|
||||
const { connector, key, kind, sourceX, sourceY, targetX, targetY } = route;
|
||||
const verticalX = verticalXByConnector.get(key);
|
||||
if (verticalX === undefined) return null;
|
||||
const kind = connectorKind(connector.from.select);
|
||||
result.push({
|
||||
fromSeriesId: connector.from.seriesId,
|
||||
select: connector.from.select,
|
||||
@@ -622,6 +647,324 @@ function buildConnectors(
|
||||
);
|
||||
}
|
||||
|
||||
function alignWinnerBundleRails(
|
||||
routes: readonly ConnectorRoute[],
|
||||
verticalXByConnector: Map<string, number>,
|
||||
): boolean {
|
||||
const winnersByTarget = new Map<SeriesId, ConnectorRoute[]>();
|
||||
for (const route of routes) {
|
||||
if (route.kind !== "winner") continue;
|
||||
const winners = winnersByTarget.get(route.connector.to.seriesId) ?? [];
|
||||
winners.push(route);
|
||||
winnersByTarget.set(route.connector.to.seriesId, winners);
|
||||
}
|
||||
|
||||
const bundles = [...winnersByTarget.values()]
|
||||
.filter(
|
||||
(winners) =>
|
||||
winners.length === 2 &&
|
||||
winners[0].connector.to.slot !== winners[1].connector.to.slot,
|
||||
)
|
||||
.sort(
|
||||
(left, right) =>
|
||||
left[0].targetColumn - right[0].targetColumn ||
|
||||
left[0].targetNodeY - right[0].targetNodeY ||
|
||||
left[0].key.localeCompare(right[0].key),
|
||||
);
|
||||
|
||||
for (const bundle of bundles) {
|
||||
const preferredX =
|
||||
bundle[0].targetX - DOUBLE_ELIMINATION_BRACKET_GEOMETRY.columnGap / 2;
|
||||
if (
|
||||
intervalsOverlap(
|
||||
bundle[0].sourceY,
|
||||
bundle[0].targetY,
|
||||
bundle[1].sourceY,
|
||||
bundle[1].targetY,
|
||||
)
|
||||
) {
|
||||
const assignment = chooseSeparateWinnerRails(
|
||||
bundle,
|
||||
routes,
|
||||
verticalXByConnector,
|
||||
preferredX,
|
||||
);
|
||||
if (!assignment) return false;
|
||||
for (const [key, verticalX] of assignment) {
|
||||
verticalXByConnector.set(key, verticalX);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
const verticalX = chooseWinnerBundleRail(
|
||||
bundle,
|
||||
routes,
|
||||
verticalXByConnector,
|
||||
preferredX,
|
||||
);
|
||||
if (verticalX === null) return false;
|
||||
for (const route of bundle) verticalXByConnector.set(route.key, verticalX);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
function chooseWinnerBundleRail(
|
||||
bundle: readonly ConnectorRoute[],
|
||||
routes: readonly ConnectorRoute[],
|
||||
verticalXByConnector: Map<string, number>,
|
||||
preferredX: number,
|
||||
): number | null {
|
||||
const previousRails = bundle.map((route) =>
|
||||
verticalXByConnector.get(route.key),
|
||||
);
|
||||
if (previousRails.some((verticalX) => verticalX === undefined)) return null;
|
||||
const previousScore = connectorConflictScore(routes, verticalXByConnector);
|
||||
// Keep the existing crossing budget, then favor stroke-clear rails nearest center.
|
||||
let best:
|
||||
| {
|
||||
verticalX: number;
|
||||
crossings: number;
|
||||
clearanceConflicts: number;
|
||||
distanceFromCenter: number;
|
||||
}
|
||||
| null = null;
|
||||
|
||||
for (const candidateX of winnerRailCandidates(preferredX)) {
|
||||
for (const route of bundle) {
|
||||
verticalXByConnector.set(route.key, candidateX);
|
||||
}
|
||||
const score = connectorConflictScore(routes, verticalXByConnector);
|
||||
if (
|
||||
score.overlaps !== 0 ||
|
||||
score.crossings > previousScore.crossings ||
|
||||
score.clearanceConflicts > previousScore.clearanceConflicts
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
const distanceFromCenter = Math.abs(candidateX - preferredX);
|
||||
if (
|
||||
!best ||
|
||||
score.clearanceConflicts < best.clearanceConflicts ||
|
||||
(score.clearanceConflicts === best.clearanceConflicts &&
|
||||
(score.crossings < best.crossings ||
|
||||
(score.crossings === best.crossings &&
|
||||
distanceFromCenter < best.distanceFromCenter)))
|
||||
) {
|
||||
best = {
|
||||
verticalX: candidateX,
|
||||
crossings: score.crossings,
|
||||
clearanceConflicts: score.clearanceConflicts,
|
||||
distanceFromCenter,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
if (best) return best.verticalX;
|
||||
|
||||
bundle.forEach((route, index) => {
|
||||
const previousX = previousRails[index];
|
||||
if (previousX !== undefined) {
|
||||
verticalXByConnector.set(route.key, previousX);
|
||||
}
|
||||
});
|
||||
return null;
|
||||
}
|
||||
|
||||
function winnerRailCandidates(preferredX: number): number[] {
|
||||
const geometry = DOUBLE_ELIMINATION_BRACKET_GEOMETRY;
|
||||
const maximumOffset =
|
||||
geometry.columnGap / 2 - CONNECTOR_RAIL_EDGE_INSET;
|
||||
const candidates = [preferredX];
|
||||
for (let offset = 1; offset <= maximumOffset; offset += 1) {
|
||||
candidates.push(preferredX - offset, preferredX + offset);
|
||||
}
|
||||
return candidates;
|
||||
}
|
||||
|
||||
function chooseSeparateWinnerRails(
|
||||
bundle: readonly ConnectorRoute[],
|
||||
routes: readonly ConnectorRoute[],
|
||||
verticalXByConnector: Map<string, number>,
|
||||
preferredX: number,
|
||||
): Map<string, number> | null {
|
||||
const orderedBundle = [...bundle].sort(
|
||||
(left, right) =>
|
||||
left.sourceY - right.sourceY ||
|
||||
left.targetY - right.targetY ||
|
||||
left.key.localeCompare(right.key),
|
||||
);
|
||||
const previousRails: number[] = [];
|
||||
for (const route of orderedBundle) {
|
||||
const previousX = verticalXByConnector.get(route.key);
|
||||
if (previousX === undefined) return null;
|
||||
previousRails.push(previousX);
|
||||
}
|
||||
|
||||
const previousScore = connectorConflictScore(routes, verticalXByConnector);
|
||||
const bundleKeys = new Set(orderedBundle.map(({ key }) => key));
|
||||
const candidates = [
|
||||
...new Set([...previousRails, ...winnerRailCandidates(preferredX)]),
|
||||
];
|
||||
let best: SeparateWinnerRailChoice | null = null;
|
||||
|
||||
for (const firstX of candidates) {
|
||||
for (const secondX of candidates) {
|
||||
if (firstX === secondX) continue;
|
||||
verticalXByConnector.set(orderedBundle[0].key, firstX);
|
||||
verticalXByConnector.set(orderedBundle[1].key, secondX);
|
||||
|
||||
const bundleScore = connectorConflictScore(
|
||||
routes,
|
||||
verticalXByConnector,
|
||||
bundleKeys,
|
||||
);
|
||||
const score = connectorConflictScore(routes, verticalXByConnector);
|
||||
if (
|
||||
bundleScore.overlaps !== 0 ||
|
||||
bundleScore.clearanceConflicts !== 0 ||
|
||||
score.overlaps !== 0 ||
|
||||
score.crossings > previousScore.crossings
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const distanceFromBaseline =
|
||||
Math.abs(firstX - previousRails[0]) +
|
||||
Math.abs(secondX - previousRails[1]);
|
||||
const distanceFromCenter =
|
||||
Math.abs(firstX - preferredX) + Math.abs(secondX - preferredX);
|
||||
const candidate: SeparateWinnerRailChoice = {
|
||||
verticalXs: [firstX, secondX],
|
||||
crossings: score.crossings,
|
||||
distanceFromBaseline,
|
||||
distanceFromCenter,
|
||||
};
|
||||
if (!best || compareSeparateWinnerRailChoices(candidate, best) < 0) {
|
||||
best = candidate;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
orderedBundle.forEach((route, index) => {
|
||||
verticalXByConnector.set(route.key, previousRails[index]);
|
||||
});
|
||||
if (!best) return null;
|
||||
return new Map(
|
||||
orderedBundle.map((route, index) => [route.key, best.verticalXs[index]]),
|
||||
);
|
||||
}
|
||||
|
||||
function compareSeparateWinnerRailChoices(
|
||||
left: SeparateWinnerRailChoice,
|
||||
right: SeparateWinnerRailChoice,
|
||||
): number {
|
||||
return (
|
||||
left.crossings - right.crossings ||
|
||||
left.distanceFromBaseline - right.distanceFromBaseline ||
|
||||
left.distanceFromCenter - right.distanceFromCenter ||
|
||||
left.verticalXs[0] - right.verticalXs[0] ||
|
||||
left.verticalXs[1] - right.verticalXs[1]
|
||||
);
|
||||
}
|
||||
|
||||
function connectorConflictScore(
|
||||
routes: readonly ConnectorRoute[],
|
||||
verticalXByConnector: ReadonlyMap<string, number>,
|
||||
focusedRouteKeys?: ReadonlySet<string>,
|
||||
): { crossings: number; overlaps: number; clearanceConflicts: number } {
|
||||
let crossings = 0;
|
||||
let overlaps = 0;
|
||||
let clearanceConflicts = 0;
|
||||
for (let leftIndex = 0; leftIndex < routes.length; leftIndex += 1) {
|
||||
const leftX = verticalXByConnector.get(routes[leftIndex].key);
|
||||
if (leftX === undefined) continue;
|
||||
const leftSegments = connectorRouteSegments(routes[leftIndex], leftX);
|
||||
for (
|
||||
let rightIndex = leftIndex + 1;
|
||||
rightIndex < routes.length;
|
||||
rightIndex += 1
|
||||
) {
|
||||
if (
|
||||
focusedRouteKeys &&
|
||||
!focusedRouteKeys.has(routes[leftIndex].key) &&
|
||||
!focusedRouteKeys.has(routes[rightIndex].key)
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
const rightX = verticalXByConnector.get(routes[rightIndex].key);
|
||||
if (rightX === undefined) continue;
|
||||
const rightSegments = connectorRouteSegments(routes[rightIndex], rightX);
|
||||
for (const left of leftSegments) {
|
||||
for (const right of rightSegments) {
|
||||
if (left.orientation === right.orientation) {
|
||||
const overlapLength =
|
||||
Math.min(left.end, right.end) - Math.max(left.start, right.start);
|
||||
if (left.fixed === right.fixed && overlapLength > 0) {
|
||||
overlaps += 1;
|
||||
} else if (
|
||||
left.orientation === "vertical" &&
|
||||
overlapLength > 0 &&
|
||||
Math.abs(left.fixed - right.fixed) <
|
||||
DOUBLE_ELIMINATION_BRACKET_GEOMETRY.connectorRailClearance
|
||||
) {
|
||||
clearanceConflicts += 1;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
const horizontal =
|
||||
left.orientation === "horizontal" ? left : right;
|
||||
const vertical = left.orientation === "vertical" ? left : right;
|
||||
if (
|
||||
vertical.fixed > horizontal.start &&
|
||||
vertical.fixed < horizontal.end &&
|
||||
horizontal.fixed > vertical.start &&
|
||||
horizontal.fixed < vertical.end
|
||||
) {
|
||||
crossings += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return { crossings, overlaps, clearanceConflicts };
|
||||
}
|
||||
|
||||
function connectorRouteSegments(
|
||||
route: ConnectorRoute,
|
||||
verticalX: number,
|
||||
): OrthogonalSegment[] {
|
||||
return [
|
||||
orthogonalSegment("horizontal", route.sourceY, route.sourceX, verticalX),
|
||||
orthogonalSegment("vertical", verticalX, route.sourceY, route.targetY),
|
||||
orthogonalSegment("horizontal", route.targetY, verticalX, route.targetX),
|
||||
];
|
||||
}
|
||||
|
||||
function orthogonalSegment(
|
||||
orientation: OrthogonalSegment["orientation"],
|
||||
fixed: number,
|
||||
first: number,
|
||||
second: number,
|
||||
): OrthogonalSegment {
|
||||
return {
|
||||
orientation,
|
||||
fixed,
|
||||
start: Math.min(first, second),
|
||||
end: Math.max(first, second),
|
||||
};
|
||||
}
|
||||
|
||||
function intervalsOverlap(
|
||||
firstStart: number,
|
||||
firstEnd: number,
|
||||
secondStart: number,
|
||||
secondEnd: number,
|
||||
): boolean {
|
||||
return (
|
||||
Math.min(firstStart, firstEnd) < Math.max(secondStart, secondEnd) &&
|
||||
Math.min(secondStart, secondEnd) < Math.max(firstStart, firstEnd)
|
||||
);
|
||||
}
|
||||
|
||||
function connectorLabel(
|
||||
connector: SeriesConnectorView,
|
||||
graph: ValidatedGraph,
|
||||
|
||||
@@ -26,9 +26,9 @@ export const MATCH_DETAIL_TAB_QUERY_KEY = "tab";
|
||||
|
||||
const PUBLIC_MATCH_DETAIL_TABS: MatchDetailTab[] = [
|
||||
{ id: "bracket", label: "대진표·순위" },
|
||||
{ id: "games", label: "경기 기록" },
|
||||
{ id: "games", label: "경기 일정·결과" },
|
||||
{ id: "teams", label: "팀" },
|
||||
{ id: "info", label: "일정·안내" },
|
||||
{ id: "info", label: "안내" },
|
||||
];
|
||||
|
||||
const OPERATIONS_TAB: MatchDetailTab = { id: "ops", label: "운영" };
|
||||
|
||||
@@ -97,15 +97,15 @@ function resolveBackTarget(
|
||||
return {
|
||||
to: state.backTo,
|
||||
label:
|
||||
typeof state.backLabel === "string"
|
||||
? state.backLabel
|
||||
typeof state.backLabel === "string" && state.backLabel.trim().length > 0
|
||||
? state.backLabel.trim()
|
||||
: "돌아가기",
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
to: fallbackTo,
|
||||
label: "경기 결과로 돌아가기",
|
||||
label: "경기 기록으로 돌아가기",
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -12,12 +12,13 @@ import {
|
||||
competitionHistoryGameDetailPath,
|
||||
createCompetitionSeriesHistory,
|
||||
formatCompetitionHistoryDate,
|
||||
formatCompetitionHistoryDayHeading,
|
||||
formatCompetitionHistoryTime,
|
||||
formatSeriesGameDuration,
|
||||
getSeriesHistoryRecordLabel,
|
||||
getSeriesHistoryResultLabel,
|
||||
getSeriesHistoryStatusLabel,
|
||||
getSeriesHistoryTimePresentation,
|
||||
isCompetitionHistoryCalendarDate,
|
||||
shouldDisplaySeriesHistoryScore,
|
||||
} from "../src/components/competition/competition-series-history.ts";
|
||||
import { isSeriesEntryWinner } from "../src/components/competition/series-score-card-model.ts";
|
||||
@@ -140,7 +141,7 @@ test("groups and orders Series by the Asia/Seoul calendar day", () => {
|
||||
);
|
||||
});
|
||||
|
||||
test("includes recorded in-progress Series and game-less completed decisions only", () => {
|
||||
test("includes recorded in-progress Series and game-less completed decisions", () => {
|
||||
const teamA = teamId("team-a");
|
||||
const teamB = teamId("team-b");
|
||||
const running = inProgressSeries("running-recorded", teamA, teamB, 1, 0);
|
||||
@@ -173,9 +174,6 @@ test("includes recorded in-progress Series and game-less completed decisions onl
|
||||
|
||||
const history = createCompetitionSeriesHistory({
|
||||
series: [
|
||||
readySeries("ready", teamA, teamB),
|
||||
waitingSeries("waiting"),
|
||||
inactiveSeries("inactive"),
|
||||
unrecordedRunning,
|
||||
administrative,
|
||||
running,
|
||||
@@ -193,6 +191,231 @@ test("includes recorded in-progress Series and game-less completed decisions onl
|
||||
assert.equal(rows[1].occurredAt, administrative.outcome.completedAt);
|
||||
});
|
||||
|
||||
test("includes ready and waiting Series in dated and final unscheduled groups", () => {
|
||||
const teamA = teamId("future-team-a");
|
||||
const teamB = teamId("future-team-b");
|
||||
const scheduledReady = withSchedule(
|
||||
readySeries("scheduled-ready", teamA, teamB),
|
||||
{ date: "2026-07-15", time: "21:30", timeZone: "Asia/Seoul" },
|
||||
);
|
||||
const scheduledWaiting = withSchedule(waitingSeries("scheduled-waiting"), {
|
||||
date: "2026-07-15",
|
||||
time: null,
|
||||
timeZone: "Asia/Seoul",
|
||||
});
|
||||
const unscheduledReady = {
|
||||
...readySeries("unscheduled-ready", teamA, teamB),
|
||||
stage: { type: "upper" as const, roundNumber: 1, displayOrder: 3 },
|
||||
};
|
||||
const unscheduledWaiting = {
|
||||
...waitingSeries("unscheduled-waiting"),
|
||||
stage: { type: "upper" as const, roundNumber: 1, displayOrder: 4 },
|
||||
};
|
||||
|
||||
const history = createCompetitionSeriesHistory({
|
||||
series: [
|
||||
unscheduledWaiting,
|
||||
scheduledWaiting,
|
||||
unscheduledReady,
|
||||
scheduledReady,
|
||||
],
|
||||
games: [],
|
||||
});
|
||||
|
||||
assert.deepEqual(
|
||||
history.map(({ dateKey }) => dateKey),
|
||||
["2026-07-15", "unknown"],
|
||||
);
|
||||
assert.deepEqual(
|
||||
history[0].rows.map(({ series }) => series.seriesId),
|
||||
[scheduledReady.seriesId, scheduledWaiting.seriesId],
|
||||
);
|
||||
assert.deepEqual(
|
||||
history[1].rows.map(({ series }) => series.seriesId),
|
||||
[unscheduledReady.seriesId, unscheduledWaiting.seriesId],
|
||||
);
|
||||
});
|
||||
|
||||
test("keeps missing historical timestamps separate from unscheduled future Series", () => {
|
||||
const teamA = teamId("missing-record-time-a");
|
||||
const teamB = teamId("missing-record-time-b");
|
||||
const historical = completedSeries({
|
||||
id: "missing-record-time",
|
||||
teamA,
|
||||
teamB,
|
||||
scoreA: 0,
|
||||
scoreB: 0,
|
||||
completedAt: "not-an-iso-date",
|
||||
outcome: "administrative",
|
||||
});
|
||||
const future = readySeries("missing-schedule-date", teamA, teamB);
|
||||
|
||||
const history = createCompetitionSeriesHistory({
|
||||
series: [future, historical],
|
||||
games: [],
|
||||
});
|
||||
|
||||
assert.deepEqual(
|
||||
history.map(({ dateKey }) => dateKey),
|
||||
["record-unknown", "unknown"],
|
||||
);
|
||||
assert.equal(
|
||||
formatCompetitionHistoryDate(history[0].dateKey),
|
||||
"기록 일시 미상",
|
||||
);
|
||||
assert.equal(
|
||||
formatCompetitionHistoryDate(history[1].dateKey),
|
||||
"일정 미정",
|
||||
);
|
||||
});
|
||||
|
||||
test("prefers recorded start and decision times over an attached schedule", () => {
|
||||
const teamA = teamId("record-precedence-a");
|
||||
const teamB = teamId("record-precedence-b");
|
||||
const played = withSchedule(
|
||||
completedSeries({
|
||||
id: "recorded-start-precedence",
|
||||
teamA,
|
||||
teamB,
|
||||
scoreA: 1,
|
||||
scoreB: 0,
|
||||
completedAt: "2026-07-12T12:00:00.000Z",
|
||||
}),
|
||||
{ date: "2026-08-01", time: "20:00", timeZone: "Asia/Seoul" },
|
||||
);
|
||||
const recordedGame = game({
|
||||
id: "recorded-start-precedence-game",
|
||||
seriesId: played.seriesId,
|
||||
ordinal: 1,
|
||||
displayNumber: 20,
|
||||
blueTeamId: teamA,
|
||||
redTeamId: teamB,
|
||||
winnerTeamId: teamA,
|
||||
startedAt: "2026-07-12T11:00:00.000Z",
|
||||
});
|
||||
const decided = withSchedule(
|
||||
completedSeries({
|
||||
id: "decision-precedence",
|
||||
teamA,
|
||||
teamB,
|
||||
scoreA: 0,
|
||||
scoreB: 0,
|
||||
completedAt: "2026-07-13T11:00:00.000Z",
|
||||
outcome: "administrative",
|
||||
}),
|
||||
{ date: "2026-08-02", time: "21:00", timeZone: "Asia/Seoul" },
|
||||
);
|
||||
const running = withSchedule(
|
||||
inProgressSeries("running-start-precedence", teamA, teamB, 1, 0),
|
||||
{ date: "2026-08-03", time: "22:00", timeZone: "Asia/Seoul" },
|
||||
);
|
||||
const runningGame = game({
|
||||
id: "running-start-precedence-game",
|
||||
seriesId: running.seriesId,
|
||||
ordinal: 1,
|
||||
displayNumber: 21,
|
||||
blueTeamId: teamA,
|
||||
redTeamId: teamB,
|
||||
winnerTeamId: teamA,
|
||||
startedAt: "2026-07-14T11:00:00.000Z",
|
||||
});
|
||||
|
||||
const rows = createCompetitionSeriesHistory({
|
||||
series: [running, decided, played],
|
||||
games: [runningGame, recordedGame],
|
||||
}).flatMap(({ rows }) => rows);
|
||||
|
||||
assert.equal(rows[0].timestampSource, "game-start");
|
||||
assert.equal(rows[0].occurredAt, recordedGame.startedAt);
|
||||
assert.equal(rows[1].timestampSource, "decision");
|
||||
assert.equal(rows[1].occurredAt, decided.outcome.completedAt);
|
||||
assert.equal(rows[2].timestampSource, "game-start");
|
||||
assert.equal(rows[2].occurredAt, runningGame.startedAt);
|
||||
});
|
||||
|
||||
test("keeps Series with invalid recorded Game starts in the missing-record group", () => {
|
||||
const teamA = teamId("invalid-game-start-a");
|
||||
const teamB = teamId("invalid-game-start-b");
|
||||
const scheduledRunning = withSchedule(
|
||||
inProgressSeries("invalid-running-scheduled", teamA, teamB, 0, 0),
|
||||
{ date: "2026-08-03", time: "22:00", timeZone: "Asia/Seoul" },
|
||||
);
|
||||
const unscheduledRunning = {
|
||||
...inProgressSeries("invalid-running-unscheduled", teamA, teamB, 0, 0),
|
||||
stage: { type: "upper" as const, roundNumber: 1, displayOrder: 2 },
|
||||
};
|
||||
const completed = completedSeries({
|
||||
id: "invalid-completed-game-start",
|
||||
teamA,
|
||||
teamB,
|
||||
scoreA: 1,
|
||||
scoreB: 0,
|
||||
displayOrder: 3,
|
||||
completedAt: "2026-07-15T11:00:00.000Z",
|
||||
});
|
||||
const invalidGames = [scheduledRunning, unscheduledRunning, completed].map(
|
||||
(series, index) =>
|
||||
game({
|
||||
id: `invalid-start-game-${index}`,
|
||||
seriesId: series.seriesId,
|
||||
ordinal: 1,
|
||||
displayNumber: 30 + index,
|
||||
blueTeamId: teamA,
|
||||
redTeamId: teamB,
|
||||
winnerTeamId: teamA,
|
||||
startedAt: "not-an-iso-date",
|
||||
}),
|
||||
);
|
||||
invalidGames.push(
|
||||
game({
|
||||
id: "mixed-valid-start-game",
|
||||
seriesId: scheduledRunning.seriesId,
|
||||
ordinal: 2,
|
||||
displayNumber: 33,
|
||||
blueTeamId: teamA,
|
||||
redTeamId: teamB,
|
||||
winnerTeamId: teamA,
|
||||
startedAt: "2026-07-14T11:00:00.000Z",
|
||||
}),
|
||||
);
|
||||
|
||||
const rows = createCompetitionSeriesHistory({
|
||||
series: [completed, unscheduledRunning, scheduledRunning],
|
||||
games: invalidGames,
|
||||
}).flatMap(({ rows }) => rows);
|
||||
|
||||
assert.equal(rows.length, 3);
|
||||
for (const row of rows) {
|
||||
assert.equal(row.dateKey, "record-unknown");
|
||||
assert.equal(row.timestampSource, "game-start");
|
||||
assert.equal(row.occurredAt, null);
|
||||
assert.deepEqual(getSeriesHistoryTimePresentation(row), {
|
||||
text: "—",
|
||||
dateTime: null,
|
||||
screenReaderText: "시작 시각 기록 없음",
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
test("hides unscheduled inactive Series but includes a scheduled conditional Series", () => {
|
||||
const unscheduledInactive = inactiveSeries("inactive-unscheduled");
|
||||
const scheduledInactive = withSchedule(
|
||||
inactiveSeries("inactive-scheduled"),
|
||||
{ date: "2026-07-16", time: null, timeZone: "Asia/Seoul" },
|
||||
);
|
||||
|
||||
const rows = createCompetitionSeriesHistory({
|
||||
series: [unscheduledInactive, scheduledInactive],
|
||||
games: [],
|
||||
}).flatMap(({ rows }) => rows);
|
||||
|
||||
assert.deepEqual(
|
||||
rows.map(({ series }) => series.seriesId),
|
||||
[scheduledInactive.seriesId],
|
||||
);
|
||||
assert.equal(getSeriesHistoryStatusLabel(scheduledInactive), "필요 시");
|
||||
});
|
||||
|
||||
test("sorts tied timestamps deterministically and ignores orphan Games", () => {
|
||||
const teamA = teamId("team-a");
|
||||
const teamB = teamId("team-b");
|
||||
@@ -241,6 +464,13 @@ test("separates lifecycle status from played and adjudicated result labels", ()
|
||||
const teamA = teamId("team-a");
|
||||
const teamB = teamId("team-b");
|
||||
const running = inProgressSeries("running", teamA, teamB, 1, 0);
|
||||
const ready = readySeries("ready-status", teamA, teamB);
|
||||
const waiting = waitingSeries("waiting-status");
|
||||
const conditional = withSchedule(inactiveSeries("conditional-status"), {
|
||||
date: "2026-07-16",
|
||||
time: null,
|
||||
timeZone: "Asia/Seoul",
|
||||
});
|
||||
const played = completedSeries({
|
||||
id: "played",
|
||||
teamA,
|
||||
@@ -292,6 +522,9 @@ test("separates lifecycle status from played and adjudicated result labels", ()
|
||||
outcome: "administrative",
|
||||
});
|
||||
|
||||
assert.equal(getSeriesHistoryStatusLabel(ready), "예정");
|
||||
assert.equal(getSeriesHistoryStatusLabel(waiting), "예정");
|
||||
assert.equal(getSeriesHistoryStatusLabel(conditional), "필요 시");
|
||||
assert.equal(getSeriesHistoryStatusLabel(running), "진행 중");
|
||||
for (const completed of [
|
||||
played,
|
||||
@@ -304,6 +537,9 @@ test("separates lifecycle status from played and adjudicated result labels", ()
|
||||
assert.equal(getSeriesHistoryStatusLabel(completed), "최종");
|
||||
}
|
||||
|
||||
assert.equal(getSeriesHistoryResultLabel(ready), "VS");
|
||||
assert.equal(getSeriesHistoryResultLabel(waiting), "VS");
|
||||
assert.equal(getSeriesHistoryResultLabel(conditional), "VS");
|
||||
assert.equal(getSeriesHistoryResultLabel(running), null);
|
||||
assert.equal(getSeriesHistoryResultLabel(played), null);
|
||||
assert.equal(getSeriesHistoryResultLabel(playedDraw), "무승부");
|
||||
@@ -341,6 +577,43 @@ test("describes recorded Games, decisions, and legacy missing records", () => {
|
||||
assert.equal(getSeriesHistoryRecordLabel(played, 0, false), "게임 기록 미등록");
|
||||
});
|
||||
|
||||
test("presents known and unknown future times without an invalid time value", () => {
|
||||
const teamA = teamId("time-team-a");
|
||||
const teamB = teamId("time-team-b");
|
||||
const knownTime = withSchedule(
|
||||
readySeries("known-scheduled-time", teamA, teamB),
|
||||
{ date: "2026-07-15", time: "21:30", timeZone: "Asia/Seoul" },
|
||||
);
|
||||
const unknownTime = withSchedule(
|
||||
readySeries("unknown-scheduled-time", teamA, teamB),
|
||||
{ date: "2026-07-15", time: null, timeZone: "Asia/Seoul" },
|
||||
);
|
||||
const rows = createCompetitionSeriesHistory({
|
||||
series: [unknownTime, knownTime],
|
||||
games: [],
|
||||
}).flatMap(({ rows }) => rows);
|
||||
const knownRow = rows.find(
|
||||
({ series }) => series.seriesId === knownTime.seriesId,
|
||||
);
|
||||
const unknownRow = rows.find(
|
||||
({ series }) => series.seriesId === unknownTime.seriesId,
|
||||
);
|
||||
|
||||
assert.ok(knownRow);
|
||||
assert.ok(unknownRow);
|
||||
|
||||
assert.deepEqual(getSeriesHistoryTimePresentation(knownRow), {
|
||||
text: "21:30",
|
||||
dateTime: "2026-07-15T21:30:00+09:00",
|
||||
screenReaderText: null,
|
||||
});
|
||||
assert.deepEqual(getSeriesHistoryTimePresentation(unknownRow), {
|
||||
text: "--:--",
|
||||
dateTime: null,
|
||||
screenReaderText: "시작 시간 미정",
|
||||
});
|
||||
});
|
||||
|
||||
test("shows a numeric score only for played records", () => {
|
||||
const teamA = teamId("team-a");
|
||||
const teamB = teamId("team-b");
|
||||
@@ -423,25 +696,20 @@ test("formats recorded Game duration and omits unknown legacy zero values", () =
|
||||
});
|
||||
|
||||
test("formats history dates and times explicitly in Asia/Seoul", () => {
|
||||
assert.equal(formatCompetitionHistoryDate("2026-07-05"), "7월 5일 (일)");
|
||||
assert.equal(formatCompetitionHistoryDate("2026-07-05"), "7월 05일 (일)");
|
||||
assert.equal(formatCompetitionHistoryDate("2026-07-13"), "7월 13일 (월)");
|
||||
assert.equal(
|
||||
formatCompetitionHistoryDayHeading("2026-07-05", 1),
|
||||
"7월 5일 (일) · 1경기",
|
||||
);
|
||||
assert.equal(
|
||||
formatCompetitionHistoryDayHeading("2026-07-13", 2),
|
||||
"7월 13일 (월) · 2경기",
|
||||
);
|
||||
assert.equal(
|
||||
formatCompetitionHistoryTime("2026-07-12T15:05:00.000Z"),
|
||||
"00:05",
|
||||
);
|
||||
assert.equal(formatCompetitionHistoryDate("unknown"), "일시 정보 없음");
|
||||
assert.equal(formatCompetitionHistoryDate("unknown"), "일정 미정");
|
||||
assert.equal(
|
||||
formatCompetitionHistoryDayHeading("unknown", 1),
|
||||
"일시 정보 없음 · 1경기",
|
||||
formatCompetitionHistoryDate("record-unknown"),
|
||||
"기록 일시 미상",
|
||||
);
|
||||
assert.equal(isCompetitionHistoryCalendarDate("2026-07-05"), true);
|
||||
assert.equal(isCompetitionHistoryCalendarDate("record-unknown"), false);
|
||||
assert.equal(isCompetitionHistoryCalendarDate("unknown"), false);
|
||||
});
|
||||
|
||||
function playedSeriesWithGame({
|
||||
@@ -647,3 +915,14 @@ function seriesId(value: string): SeriesId {
|
||||
function teamId(value: string): TeamId {
|
||||
return value as TeamId;
|
||||
}
|
||||
|
||||
function withSchedule<T extends SeriesProjection>(
|
||||
series: T,
|
||||
schedule: {
|
||||
date: string;
|
||||
time: string | null;
|
||||
timeZone: "Asia/Seoul";
|
||||
},
|
||||
): T & { schedule: typeof schedule } {
|
||||
return { ...series, schedule };
|
||||
}
|
||||
@@ -367,6 +367,7 @@ test("orders mobile groups as winners, losers, grand final, then reset final", (
|
||||
shuffledLayout.mobileGroups.map((group) => group.seriesIds),
|
||||
orderedLayout.mobileGroups.map((group) => group.seriesIds),
|
||||
);
|
||||
assert.deepEqual(shuffledLayout.connectors, orderedLayout.connectors);
|
||||
assert.deepEqual(
|
||||
shuffledLayout.mobileGroups.flatMap((group) => group.seriesIds).sort(),
|
||||
shuffled.projection.series.map((series) => series.seriesId).sort(),
|
||||
@@ -474,11 +475,10 @@ test("returns null instead of throwing for an unknown connector discriminator",
|
||||
);
|
||||
});
|
||||
|
||||
test("keeps connector rails distinct and outside intervening card rectangles", () => {
|
||||
test("keeps connector rails finite and outside intervening card rectangles", () => {
|
||||
const { projection } = eightTeamProjection();
|
||||
const layout = requireLayout(projection, EIGHT_TEAM_LAYOUT);
|
||||
const nodes = new Map(layout.nodes.map((node) => [node.seriesId, node]));
|
||||
const routesByTargetColumn = new Map<number, number[]>();
|
||||
|
||||
for (const route of layout.connectors) {
|
||||
const source = nodes.get(route.fromSeriesId);
|
||||
@@ -511,23 +511,256 @@ test("keeps connector rails distinct and outside intervening card rectangles", (
|
||||
false,
|
||||
);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
const rails = routesByTargetColumn.get(target.column) ?? [];
|
||||
rails.push(route.verticalX);
|
||||
routesByTargetColumn.set(target.column, rails);
|
||||
test("aligns paired winner bends on one shared rail", () => {
|
||||
const fourTeam = fourTeamProjection();
|
||||
const fourTeamLayout = requireLayout(fourTeam.projection, FOUR_TEAM_LAYOUT);
|
||||
for (const targetSeriesId of [fourTeam.ids.WB_FINAL, fourTeam.ids.GF]) {
|
||||
const routes = winnerRoutesTo(fourTeamLayout, targetSeriesId);
|
||||
assert.equal(routes.length, 2);
|
||||
assert.equal(routes[0].verticalX, routes[1].verticalX);
|
||||
}
|
||||
|
||||
for (const rails of routesByTargetColumn.values()) {
|
||||
assert.equal(new Set(rails).size, rails.length);
|
||||
const { projection, ids } = eightTeamProjection();
|
||||
const layout = requireLayout(projection, EIGHT_TEAM_LAYOUT);
|
||||
|
||||
for (const targetSeriesId of [
|
||||
ids.WB_R2_M1,
|
||||
ids.WB_R2_M2,
|
||||
ids.WB_FINAL,
|
||||
ids.LB_R3_M1,
|
||||
ids.GF,
|
||||
]) {
|
||||
const routes = winnerRoutesTo(layout, targetSeriesId);
|
||||
assert.equal(routes.length, 2);
|
||||
assert.equal(
|
||||
routes[0].verticalX,
|
||||
routes[1].verticalX,
|
||||
`${targetSeriesId} winner routes must share one bend rail`,
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
test("keeps reversed winner slots on deterministic non-overlapping rails", () => {
|
||||
const { projection, ids } = fourTeamProjection();
|
||||
const reversed = cloneProjection(projection);
|
||||
const firstWinner = reversed.connectors.find(
|
||||
({ from, to }) =>
|
||||
from.seriesId === ids.WB_R1_M1 &&
|
||||
from.select === "winner" &&
|
||||
to.seriesId === ids.WB_FINAL,
|
||||
);
|
||||
const secondWinner = reversed.connectors.find(
|
||||
({ from, to }) =>
|
||||
from.seriesId === ids.WB_R1_M2 &&
|
||||
from.select === "winner" &&
|
||||
to.seriesId === ids.WB_FINAL,
|
||||
);
|
||||
assert.ok(firstWinner);
|
||||
assert.ok(secondWinner);
|
||||
firstWinner.to = { seriesId: ids.WB_FINAL, slot: "B" };
|
||||
secondWinner.to = { seriesId: ids.WB_FINAL, slot: "A" };
|
||||
|
||||
const orderedLayout = requireLayout(reversed, FOUR_TEAM_LAYOUT);
|
||||
const shuffled = cloneProjection(reversed);
|
||||
shuffled.connectors = shuffledCopy(shuffled.connectors);
|
||||
const shuffledLayout = requireLayout(shuffled, FOUR_TEAM_LAYOUT);
|
||||
const routes = winnerRoutesTo(orderedLayout, ids.WB_FINAL);
|
||||
|
||||
assert.equal(routes.length, 2);
|
||||
assert.equal(new Set(routes.map(({ verticalX }) => verticalX)).size, 2);
|
||||
assert.equal(countCollinearConnectorOverlaps(orderedLayout.connectors), 0);
|
||||
assert.deepEqual(shuffledLayout.connectors, orderedLayout.connectors);
|
||||
});
|
||||
|
||||
test("moves reversed winner rails clear of overlapping connector underlays", () => {
|
||||
const { projection, ids } = eightTeamProjection();
|
||||
const reversed = cloneProjection(projection);
|
||||
const firstWinner = reversed.connectors.find(
|
||||
({ from, to }) =>
|
||||
from.seriesId === ids.WB_R1_M1 &&
|
||||
from.select === "winner" &&
|
||||
to.seriesId === ids.WB_R2_M1,
|
||||
);
|
||||
const secondWinner = reversed.connectors.find(
|
||||
({ from, to }) =>
|
||||
from.seriesId === ids.WB_R1_M2 &&
|
||||
from.select === "winner" &&
|
||||
to.seriesId === ids.WB_R2_M1,
|
||||
);
|
||||
assert.ok(firstWinner);
|
||||
assert.ok(secondWinner);
|
||||
firstWinner.to = { seriesId: ids.WB_R2_M1, slot: "B" };
|
||||
secondWinner.to = { seriesId: ids.WB_R2_M1, slot: "A" };
|
||||
|
||||
const layout = requireLayout(reversed, EIGHT_TEAM_LAYOUT);
|
||||
const shuffled = cloneProjection(reversed);
|
||||
shuffled.connectors = shuffledCopy(shuffled.connectors);
|
||||
const shuffledLayout = requireLayout(shuffled, EIGHT_TEAM_LAYOUT);
|
||||
const winners = winnerRoutesTo(layout, ids.WB_R2_M1);
|
||||
|
||||
assert.equal(winners.length, 2);
|
||||
for (const winner of winners) {
|
||||
for (const route of layout.connectors) {
|
||||
if (
|
||||
route === winner ||
|
||||
!intervalsStrictlyOverlap(
|
||||
winner.sourceY,
|
||||
winner.targetY,
|
||||
route.sourceY,
|
||||
route.targetY,
|
||||
)
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
assert.ok(
|
||||
Math.abs(winner.verticalX - route.verticalX) >=
|
||||
DOUBLE_ELIMINATION_BRACKET_GEOMETRY.connectorRailClearance,
|
||||
`${winner.fromSeriesId} winner rail ${winner.verticalX} is too close to ${route.fromSeriesId} ${route.kind} rail ${route.verticalX}`,
|
||||
);
|
||||
}
|
||||
}
|
||||
assert.deepEqual(shuffledLayout.connectors, layout.connectors);
|
||||
});
|
||||
|
||||
test("centers conflict-free paired winner bends in the routing gap", () => {
|
||||
const fourTeam = fourTeamProjection();
|
||||
const fourTeamLayout = requireLayout(fourTeam.projection, FOUR_TEAM_LAYOUT);
|
||||
const fourTeamGrandFinal = nodeFor(fourTeamLayout, fourTeam.ids.GF);
|
||||
assert.deepEqual(
|
||||
winnerRoutesTo(fourTeamLayout, fourTeam.ids.GF).map(
|
||||
({ verticalX }) => verticalX,
|
||||
),
|
||||
[
|
||||
fourTeamGrandFinal.x -
|
||||
DOUBLE_ELIMINATION_BRACKET_GEOMETRY.columnGap / 2,
|
||||
fourTeamGrandFinal.x -
|
||||
DOUBLE_ELIMINATION_BRACKET_GEOMETRY.columnGap / 2,
|
||||
],
|
||||
);
|
||||
|
||||
const { projection, ids } = eightTeamProjection();
|
||||
const layout = requireLayout(projection, EIGHT_TEAM_LAYOUT);
|
||||
|
||||
for (const targetSeriesId of [ids.LB_R3_M1, ids.GF]) {
|
||||
const target = nodeFor(layout, targetSeriesId);
|
||||
const expectedVerticalX =
|
||||
target.x - DOUBLE_ELIMINATION_BRACKET_GEOMETRY.columnGap / 2;
|
||||
const routes = winnerRoutesTo(layout, targetSeriesId);
|
||||
|
||||
assert.equal(routes.length, 2);
|
||||
assert.deepEqual(
|
||||
routes.map(({ verticalX }) => verticalX),
|
||||
[expectedVerticalX, expectedVerticalX],
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
test("preserves baseline rails for loser and reset paths", () => {
|
||||
const { projection } = eightTeamProjection({ resetFinal: true });
|
||||
const layout = requireLayout(projection, EIGHT_TEAM_RESET_LAYOUT);
|
||||
const nodes = new Map(layout.nodes.map((node) => [node.seriesId, node]));
|
||||
const routesByTargetColumn = new Map<number, ConnectorLayout[]>();
|
||||
|
||||
for (const route of layout.connectors) {
|
||||
const target = nodes.get(route.toSeriesId);
|
||||
assert.ok(target);
|
||||
const routes = routesByTargetColumn.get(target.column) ?? [];
|
||||
routes.push(route);
|
||||
routesByTargetColumn.set(target.column, routes);
|
||||
}
|
||||
|
||||
for (const routes of routesByTargetColumn.values()) {
|
||||
routes.sort(
|
||||
(left, right) =>
|
||||
right.sourceY - left.sourceY ||
|
||||
right.targetY - left.targetY ||
|
||||
connectorLayoutKey(left).localeCompare(connectorLayoutKey(right)),
|
||||
);
|
||||
routes.forEach((route, index) => {
|
||||
if (route.kind === "winner") return;
|
||||
assert.equal(
|
||||
route.verticalX,
|
||||
route.targetX -
|
||||
DOUBLE_ELIMINATION_BRACKET_GEOMETRY.columnGap +
|
||||
(DOUBLE_ELIMINATION_BRACKET_GEOMETRY.columnGap * (index + 1)) /
|
||||
(routes.length + 1),
|
||||
);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
test("keeps paired winner rails clear of overlapping loser paths", () => {
|
||||
const fourTeam = fourTeamProjection();
|
||||
const eightTeam = eightTeamProjection();
|
||||
const fixtures = [
|
||||
{
|
||||
layout: requireLayout(fourTeam.projection, FOUR_TEAM_LAYOUT),
|
||||
pairedWinnerTargets: new Set<SeriesId>([
|
||||
fourTeam.ids.WB_FINAL,
|
||||
fourTeam.ids.GF,
|
||||
]),
|
||||
},
|
||||
{
|
||||
layout: requireLayout(eightTeam.projection, EIGHT_TEAM_LAYOUT),
|
||||
pairedWinnerTargets: new Set<SeriesId>([
|
||||
eightTeam.ids.WB_R2_M1,
|
||||
eightTeam.ids.WB_R2_M2,
|
||||
eightTeam.ids.WB_FINAL,
|
||||
eightTeam.ids.LB_R3_M1,
|
||||
eightTeam.ids.GF,
|
||||
]),
|
||||
},
|
||||
];
|
||||
|
||||
for (const { layout, pairedWinnerTargets } of fixtures) {
|
||||
for (const winner of layout.connectors) {
|
||||
if (
|
||||
winner.kind !== "winner" ||
|
||||
!pairedWinnerTargets.has(winner.toSeriesId)
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
for (const loser of layout.connectors) {
|
||||
if (
|
||||
loser.kind !== "loser" ||
|
||||
!intervalsStrictlyOverlap(
|
||||
winner.sourceY,
|
||||
winner.targetY,
|
||||
loser.sourceY,
|
||||
loser.targetY,
|
||||
)
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
assert.ok(
|
||||
Math.abs(winner.verticalX - loser.verticalX) >=
|
||||
DOUBLE_ELIMINATION_BRACKET_GEOMETRY.connectorRailClearance,
|
||||
`${winner.fromSeriesId} winner rail ${winner.verticalX} is too close to ${loser.fromSeriesId} loser rail ${loser.verticalX}`,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
test("minimizes connector crossings without introducing segment overlaps", () => {
|
||||
const { projection } = eightTeamProjection();
|
||||
const layout = requireLayout(projection, EIGHT_TEAM_LAYOUT);
|
||||
const fourTeam = fourTeamProjection();
|
||||
const fourTeamReset = fourTeamProjection({ resetFinal: true });
|
||||
const eightTeam = eightTeamProjection();
|
||||
const eightTeamReset = eightTeamProjection({ resetFinal: true });
|
||||
const layouts = [
|
||||
requireLayout(fourTeam.projection, FOUR_TEAM_LAYOUT),
|
||||
requireLayout(fourTeamReset.projection, FOUR_TEAM_RESET_LAYOUT),
|
||||
requireLayout(eightTeam.projection, EIGHT_TEAM_LAYOUT),
|
||||
requireLayout(eightTeamReset.projection, EIGHT_TEAM_RESET_LAYOUT),
|
||||
];
|
||||
|
||||
assert.equal(countStrictConnectorCrossings(layout.connectors), 12);
|
||||
assert.equal(countCollinearConnectorOverlaps(layout.connectors), 0);
|
||||
assert.ok(countStrictConnectorCrossings(layouts[2].connectors) <= 12);
|
||||
for (const layout of layouts) {
|
||||
assert.equal(countCollinearConnectorOverlaps(layout.connectors), 0);
|
||||
}
|
||||
});
|
||||
|
||||
test("aligns connector endpoints with the A and B entry row centers", () => {
|
||||
@@ -921,6 +1154,18 @@ function segment(
|
||||
};
|
||||
}
|
||||
|
||||
function intervalsStrictlyOverlap(
|
||||
firstStart: number,
|
||||
firstEnd: number,
|
||||
secondStart: number,
|
||||
secondEnd: number,
|
||||
): boolean {
|
||||
return (
|
||||
Math.min(firstStart, firstEnd) < Math.max(secondStart, secondEnd) &&
|
||||
Math.min(secondStart, secondEnd) < Math.max(firstStart, firstEnd)
|
||||
);
|
||||
}
|
||||
|
||||
function countStrictConnectorCrossings(routes: readonly ConnectorLayout[]): number {
|
||||
let crossings = 0;
|
||||
for (let leftIndex = 0; leftIndex < routes.length; leftIndex += 1) {
|
||||
@@ -1009,6 +1254,16 @@ function nodeFor(
|
||||
return node;
|
||||
}
|
||||
|
||||
function winnerRoutesTo(
|
||||
layout: NonNullable<ReturnType<typeof createDoubleEliminationBracketLayout>>,
|
||||
targetSeriesId: SeriesId,
|
||||
) {
|
||||
return layout.connectors.filter(
|
||||
(route) =>
|
||||
route.kind === "winner" && route.toSeriesId === targetSeriesId,
|
||||
);
|
||||
}
|
||||
|
||||
function routeFrom(
|
||||
layout: NonNullable<ReturnType<typeof createDoubleEliminationBracketLayout>>,
|
||||
id: SeriesId,
|
||||
@@ -1036,6 +1291,10 @@ function connectorIdentity(
|
||||
};
|
||||
}
|
||||
|
||||
function connectorLayoutKey(connector: ConnectorLayout): string {
|
||||
return `${connector.fromSeriesId}:${connector.select}:${connector.toSeriesId}:${connector.toSlot}`;
|
||||
}
|
||||
|
||||
function mobileGroupKeys(
|
||||
layout: NonNullable<ReturnType<typeof createDoubleEliminationBracketLayout>>,
|
||||
) {
|
||||
|
||||
@@ -27,7 +27,7 @@ test("uses tabs only in progress or when finished and exposes operations only to
|
||||
);
|
||||
assert.deepEqual(
|
||||
publicTabs.map((tab) => tab.label),
|
||||
["대진표·순위", "경기 기록", "팀", "일정·안내"],
|
||||
["대진표·순위", "경기 일정·결과", "팀", "안내"],
|
||||
);
|
||||
|
||||
const managerTabs = createMatchDetailTabs({
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
import assert from "node:assert/strict";
|
||||
import { readFile } from "node:fs/promises";
|
||||
import test from "node:test";
|
||||
import { SERIES_SCORE_CARD_GEOMETRY } from "../src/components/competition/series-score-card-geometry.ts";
|
||||
|
||||
const component = await readFile(
|
||||
new URL(
|
||||
"../src/components/competition/SeriesScoreCard.tsx",
|
||||
import.meta.url,
|
||||
),
|
||||
"utf8",
|
||||
);
|
||||
|
||||
test("keeps bracket entry rows equal by overlaying their divider", () => {
|
||||
assert.equal(
|
||||
SERIES_SCORE_CARD_GEOMETRY.height -
|
||||
SERIES_SCORE_CARD_GEOMETRY.borderWidth * 2 -
|
||||
SERIES_SCORE_CARD_GEOMETRY.headerHeight,
|
||||
SERIES_SCORE_CARD_GEOMETRY.entryHeight * 2,
|
||||
);
|
||||
assert.match(
|
||||
component,
|
||||
/className=\{\s*isBracket\s*\?\s*"relative"\s*:\s*"divide-y divide-base-content\/8"\s*\}/,
|
||||
);
|
||||
assert.match(
|
||||
component,
|
||||
/className="pointer-events-none absolute inset-x-0 border-t border-base-content\/8"/,
|
||||
);
|
||||
assert.match(
|
||||
component,
|
||||
/style=\{\{ top: SERIES_SCORE_CARD_GEOMETRY\.entryHeight \}\}/,
|
||||
);
|
||||
});
|
||||
@@ -0,0 +1,84 @@
|
||||
# Implementation Plan: Double-Elimination Connector Routing
|
||||
|
||||
## Overview
|
||||
|
||||
Replace per-edge winner rail staggering with deterministic, collision-aware winner
|
||||
bundles while retaining the existing target-corridor `H-V-H` path model and the
|
||||
current loser/reset routing behavior.
|
||||
|
||||
## Architecture Decisions
|
||||
|
||||
- Keep routing as a pure layout calculation; the React renderer consumes unchanged
|
||||
`BracketConnectorLayout` paths.
|
||||
- Allocate baseline rails first, then choose one rail for each same-target winner
|
||||
bundle while leaving loser/reset coordinates unchanged.
|
||||
- Score complete candidate paths by parallel-stroke clearance, strict crossings,
|
||||
and distance from the corridor midpoint.
|
||||
- Permit shared `verticalX` only when the participating vertical intervals do not
|
||||
overlap; otherwise search the same corridor for the nearest deterministic pair
|
||||
of separate rails with focused-stroke clearance.
|
||||
|
||||
## Task List
|
||||
|
||||
### Phase 1: Regression Contract
|
||||
|
||||
- [x] Add tests proving quiet winner bundles use the corridor midpoint and all
|
||||
shareable same-target winner paths remain aligned.
|
||||
- [x] Replace target-column rail uniqueness with interval-aware segment assertions.
|
||||
- [x] Cover reversed A/B input where overlapping vertical spans require the
|
||||
deterministic separate-rail fallback.
|
||||
- [x] Confirm the focused test fails with the current allocator.
|
||||
|
||||
### Checkpoint: RED
|
||||
|
||||
- [x] The new behavioral assertion fails for the expected unequal `verticalX`.
|
||||
- [x] Existing tests remain unchanged except where their invariant is obsolete.
|
||||
|
||||
### Phase 2: Bundle-Aware Allocator
|
||||
|
||||
- [x] Represent connector routing inputs with precomputed source/target anchors.
|
||||
- [x] Retain stable independent rails for loser/reset routes.
|
||||
- [x] Group the two winners entering each target and select the nearest safe shared
|
||||
rail without card penetration, forbidden overlap, or avoidable added crossings.
|
||||
- [x] Fall back to the nearest deterministic, stroke-clear separate rails only
|
||||
when the pair's own vertical intervals overlap and cannot safely share a rail.
|
||||
|
||||
### Checkpoint: GREEN
|
||||
|
||||
- [x] Focused layout tests pass for four-team, eight-team, reset-final, and shuffled
|
||||
input fixtures.
|
||||
- [x] Strict crossing, collinear-overlap, and 5px parallel-clearance safeguards pass.
|
||||
|
||||
### Phase 3: Verification and Review
|
||||
|
||||
- [x] Run the full web suite, lint, and production build; document the unrelated
|
||||
pre-existing full-lint failures while verifying changed files separately.
|
||||
- [x] Inspect the diff for correctness, simplicity, security, performance, and
|
||||
adherence to the approved spec.
|
||||
- [x] Perform an independent review and address all required findings.
|
||||
|
||||
### Checkpoint: Complete
|
||||
|
||||
- [x] All success criteria in the spec are verified.
|
||||
- [x] No unrelated files are modified.
|
||||
|
||||
## Risks and Mitigations
|
||||
|
||||
| Risk | Impact | Mitigation |
|
||||
|---|---|---|
|
||||
| Blind midpoint alignment adds crossings in busy upper rounds | High | Score complete candidate paths and move the winner bundle together to the nearest safe rail. |
|
||||
| Shared rails create overlapping vertical segments | High | Check interval overlap before allowing a shared `verticalX`; search deterministic fallback rails with 5px clearance otherwise. |
|
||||
| Visually parallel rails pass exact-coordinate tests but overlap at stroke width | High | Require 5px clearance across overlapping vertical runs and cover it for 4/8-team fixtures. |
|
||||
| Routing changes depend on input array order | Medium | Sort routes and bundles by graph display order and retain shuffled-fixture equality tests. |
|
||||
| A long connector bends through an intermediate card | High | Restrict every candidate to the target corridor and retain card-penetration assertions. |
|
||||
| Reset-final slot carry-over is accidentally treated as a winner pair | Medium | Bundle only connectors whose computed kind is `winner`; keep reset paths independent. |
|
||||
|
||||
## Dependencies
|
||||
|
||||
```text
|
||||
Regression contract -> bundle-aware rail allocator -> full verification -> review
|
||||
```
|
||||
|
||||
## Open Questions
|
||||
|
||||
None.
|
||||
@@ -0,0 +1,134 @@
|
||||
# Spec: Double-Elimination Connector Routing
|
||||
|
||||
## Objective
|
||||
|
||||
Make winner advancement lines in the desktop double-elimination bracket bend at a
|
||||
consistent horizontal position. Two winner lines entering the same match should
|
||||
read as one visual pair when their vertical spans can share a rail: use the center
|
||||
of the 40px inter-column corridor when it is safe, and move the pair together only
|
||||
when another connector would interfere. If an accepted A/B mapping reverses the
|
||||
source order and makes those spans overlap, preserve separate deterministic,
|
||||
stroke-clear rails instead of creating a collinear overlap.
|
||||
|
||||
The primary user is a participant or organizer tracing advancement through a busy
|
||||
eight-team bracket. Success means the solid coral winner paths are visually
|
||||
aligned without degrading the existing dashed loser paths, card placement, or
|
||||
keyboard-driven connector highlighting.
|
||||
|
||||
## Approved Product Decisions
|
||||
|
||||
- Treat the two `winner` connectors entering one Series as a semantic bundle.
|
||||
- Prefer `target.x - columnGap / 2` for a winner bundle.
|
||||
- If the preferred rail causes crossings, collinear overlap, or less than 5px of
|
||||
clearance from an overlapping parallel route, move a shareable bundle to the
|
||||
nearest safe rail. Retain separate rails only when the pair's own vertical spans
|
||||
overlap and therefore cannot safely share any rail; move those rails to the
|
||||
nearest deterministic positions needed to preserve the same 5px clearance.
|
||||
- Preserve the current loser/reset rail ordering unless moving one is required to
|
||||
maintain valid geometry.
|
||||
- Keep every connector as a separate `H-V-H` SVG path so focus highlighting and
|
||||
accessible labels remain independent.
|
||||
- Keep long-distance bends inside the corridor immediately before the target
|
||||
column; do not use the midpoint between source and target cards.
|
||||
|
||||
## Tech Stack
|
||||
|
||||
- React 19, TypeScript 6, Vite 8, Tailwind CSS 4, and daisyUI under `apps/web`
|
||||
- Node's built-in test runner for the pure bracket layout calculation
|
||||
|
||||
## Commands
|
||||
|
||||
- Focused layout tests: `pnpm --filter web exec node --test --experimental-strip-types test/double-elimination-bracket-layout.test.ts`
|
||||
- Full web tests: `pnpm --filter web test`
|
||||
- Web lint: `pnpm --filter web lint`
|
||||
- Web production build: `pnpm --filter web build:prod`
|
||||
- Development server: `pnpm --filter web start:dev`
|
||||
|
||||
## Project Structure
|
||||
|
||||
- `apps/web/src/components/competition/double-elimination-bracket-layout.ts`
|
||||
validates the bracket graph, positions cards, assigns connector rails, and emits
|
||||
SVG path geometry.
|
||||
- `apps/web/src/components/competition/DoubleEliminationBracket.tsx` renders the
|
||||
computed paths and must not need routing-specific changes.
|
||||
- `apps/web/test/double-elimination-bracket-layout.test.ts` contains canonical
|
||||
four-team, eight-team, and reset-final fixtures plus geometry assertions.
|
||||
|
||||
## Code Style
|
||||
|
||||
Keep routing deterministic and express geometry through small named helpers:
|
||||
|
||||
```ts
|
||||
const preferredX = target.x - geometry.columnGap / 2;
|
||||
const verticalX = nearestSafeRail(preferredX, bundle, occupiedRoutes);
|
||||
```
|
||||
|
||||
Use existing layout types and semantic connector kinds. Do not add a dependency,
|
||||
DOM measurement, mutable global state, or renderer-specific routing behavior.
|
||||
|
||||
## Testing Strategy
|
||||
|
||||
- Add regression tests before implementation and confirm they fail against the
|
||||
current per-edge rail allocator.
|
||||
- Assert observable geometry: safe winner pairs share a rail, quiet corridors use
|
||||
their exact midpoint, busy corridors keep a pair aligned, and mixed
|
||||
winner/loser entries remain distinguishable.
|
||||
- Cover reversed A/B winner input explicitly: it remains deterministic and uses
|
||||
separate rails without collinear overlap or focused-stroke clearance conflicts
|
||||
because no shared H-V-H rail is safe.
|
||||
- Replace the obsolete "all rails in a target column are unique" assertion with
|
||||
interval-aware overlap and 5px focused-stroke clearance protection.
|
||||
- Preserve deterministic output for shuffled input, finite path coordinates,
|
||||
target-corridor bounds, card avoidance, endpoint alignment, and canonical graph
|
||||
validation.
|
||||
- Verify four-team, eight-team, and reset-final layouts; run the complete web test,
|
||||
lint, and production build commands.
|
||||
|
||||
## Boundaries
|
||||
|
||||
### Always
|
||||
|
||||
- Keep winner, loser, and reset connectors visually distinguishable by the existing
|
||||
solid/dashed patterns and brand tokens.
|
||||
- Keep connector rails strictly inside the target corridor.
|
||||
- Avoid strict segment crossings and collinear overlaps whenever a safe candidate
|
||||
exists.
|
||||
- Keep overlapping parallel winner and loser rails at least 5px apart, matching
|
||||
the widest focused connector underlay.
|
||||
- Produce the same layout regardless of projection input ordering.
|
||||
|
||||
### Ask First
|
||||
|
||||
- Add dependencies or change the public projection contract.
|
||||
- Change bracket card dimensions, round columns, or the 40px column gap.
|
||||
- Redesign mobile bracket presentation or connector interaction behavior.
|
||||
|
||||
### Never
|
||||
|
||||
- Route a connector through a match card.
|
||||
- Infer routing from Series codes; use canonical graph identity and topology.
|
||||
- Merge two logical connectors into one SVG path.
|
||||
- Modify unrelated competition or score-card behavior.
|
||||
|
||||
## Success Criteria
|
||||
|
||||
- The two winner paths into `LB_R3_M1` bend at the corridor midpoint and share the
|
||||
same `verticalX`.
|
||||
- The winner paths into the grand final share the corridor midpoint when safe.
|
||||
- Every same-target winner pair whose vertical spans do not overlap shares one
|
||||
`verticalX`, using the nearest collision-safe rail when the midpoint is busy.
|
||||
- A reversed A/B pair with overlapping vertical spans retains deterministic
|
||||
separate rails, produces no collinear segment overlap, and remains at least 5px
|
||||
from every overlapping vertical route.
|
||||
- Loser/reset paths retain their baseline rails, and winner bundles remain at least
|
||||
5px away where their vertical runs overlap.
|
||||
- All rails remain inside their target corridors without card penetration or
|
||||
collinear overlap.
|
||||
- Canonical four-team, eight-team, reset-final, and shuffled-input tests pass.
|
||||
- Full web tests and production build pass; changed-file lint passes, and any
|
||||
unrelated full-lint baseline failures are documented.
|
||||
|
||||
## Open Questions
|
||||
|
||||
None. The user reviewed the proposed bundle-aware routing behavior and requested
|
||||
implementation.
|
||||
@@ -68,12 +68,19 @@ export interface GrandFinalResetActivationRule {
|
||||
|
||||
export type SeriesActivationRule = GrandFinalResetActivationRule;
|
||||
|
||||
export interface SeriesSchedule {
|
||||
date: string;
|
||||
time: string | null;
|
||||
timeZone: "Asia/Seoul";
|
||||
}
|
||||
|
||||
export interface SeriesDefinition {
|
||||
id: SeriesId;
|
||||
code?: string;
|
||||
stage: SeriesStage;
|
||||
slots: [SeriesSlotDefinition, SeriesSlotDefinition];
|
||||
rule: SeriesRule;
|
||||
schedule?: SeriesSchedule;
|
||||
activation?: SeriesActivationRule;
|
||||
gameSlots: GameSlotDefinition[];
|
||||
}
|
||||
@@ -106,6 +113,7 @@ interface SeriesProjectionBase {
|
||||
code?: string;
|
||||
stage: SeriesStage;
|
||||
rule: SeriesRule;
|
||||
schedule?: SeriesSchedule;
|
||||
}
|
||||
|
||||
export interface PlayedSeriesOutcome {
|
||||
|
||||
Reference in new issue
Block a user