feat(web): align team match names with bracket
This commit is contained in:
1 parent
bb32c26694
commit
dc77b37494
5 files changed
+54
-60
No files matched your search
@@ -170,11 +170,12 @@ export function bracketRoundLabel(
|
||||
stage: SeriesStageType,
|
||||
roundNumber?: number,
|
||||
): string {
|
||||
const round = roundNumber ?? 1;
|
||||
switch (stage) {
|
||||
case "upper":
|
||||
return `승자조 ${roundNumber ?? 1}라운드`;
|
||||
return round === 1 ? `브래킷 1R` : `브래킷 상위 ${round}R`;
|
||||
case "lower":
|
||||
return `패자조 ${roundNumber ?? 1}라운드`;
|
||||
return `브래킷 하위 ${round}R`;
|
||||
case "grand-final":
|
||||
return "그랜드 파이널";
|
||||
case "reset-final":
|
||||
@@ -182,7 +183,7 @@ export function bracketRoundLabel(
|
||||
case "pair":
|
||||
return "대진";
|
||||
case "round-robin":
|
||||
return `${roundNumber ?? 1}라운드`;
|
||||
return `${round}라운드`;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ import type {
|
||||
SeriesProjection,
|
||||
TeamTournamentCodeView,
|
||||
} from "@lolympus/contracts";
|
||||
import { bracketRoundLabel } from "../components/competition/double-elimination-bracket-layout.ts";
|
||||
|
||||
export interface TeamSeriesGroup {
|
||||
series: SeriesProjection;
|
||||
@@ -78,11 +79,7 @@ export function getTeamSeriesDisplayLabel(
|
||||
);
|
||||
const stage = round?.stage ?? series.stage.type;
|
||||
const roundNumber = round?.roundNumber ?? series.stage.roundNumber ?? 1;
|
||||
const baseLabel = isFinalRound(round, rounds)
|
||||
? stage === "upper"
|
||||
? "승자조 결승"
|
||||
: "패자조 결승"
|
||||
: stageLabel(stage, roundNumber);
|
||||
const baseLabel = bracketRoundLabel(stage, roundNumber);
|
||||
|
||||
if (!round || round.seriesIds.length <= 1) return baseLabel;
|
||||
const matchIndex = round.seriesIds.findIndex(
|
||||
@@ -265,42 +262,6 @@ function compareTournamentCodes(
|
||||
);
|
||||
}
|
||||
|
||||
function isFinalRound(
|
||||
round: BracketRoundView | undefined,
|
||||
rounds: readonly BracketRoundView[],
|
||||
): boolean {
|
||||
if (!round || (round.stage !== "upper" && round.stage !== "lower")) {
|
||||
return false;
|
||||
}
|
||||
const stageRoundNumbers = rounds
|
||||
.filter(({ stage }) => stage === round.stage)
|
||||
.map(({ roundNumber }) => roundNumber ?? 0);
|
||||
return (
|
||||
stageRoundNumbers.length > 0 &&
|
||||
(round.roundNumber ?? 0) === Math.max(...stageRoundNumbers)
|
||||
);
|
||||
}
|
||||
|
||||
function stageLabel(
|
||||
stage: SeriesProjection["stage"]["type"],
|
||||
roundNumber: number,
|
||||
): string {
|
||||
switch (stage) {
|
||||
case "upper":
|
||||
return `승자조 ${roundNumber}라운드`;
|
||||
case "lower":
|
||||
return `패자조 ${roundNumber}라운드`;
|
||||
case "grand-final":
|
||||
return "그랜드 파이널";
|
||||
case "reset-final":
|
||||
return "리셋 파이널";
|
||||
case "round-robin":
|
||||
return `${roundNumber}라운드`;
|
||||
case "pair":
|
||||
return "공식 대진";
|
||||
}
|
||||
}
|
||||
|
||||
function isExpired(expiresAt: string | null, now: number): boolean {
|
||||
if (!expiresAt) return false;
|
||||
const timestamp = Date.parse(expiresAt);
|
||||
|
||||
@@ -51,24 +51,38 @@ test("groups only matching tournament codes under each active Series", () => {
|
||||
);
|
||||
});
|
||||
|
||||
test("uses Korean round names while keeping global game numbers secondary", () => {
|
||||
test("uses bracket match names while keeping global game numbers secondary", () => {
|
||||
const opening = readySeries("upper-opening-2", 1, "WB_R1_M2");
|
||||
const final = readySeries("upper-final", 3, "WB_FINAL");
|
||||
const upperLater = readySeries("upper-final", 3, "WB_FINAL");
|
||||
const lower: SeriesProjection = {
|
||||
...readySeries("lower-opening", 4, "LB_R1_M1"),
|
||||
stage: { type: "lower", roundNumber: 1, displayOrder: 4 },
|
||||
};
|
||||
const rounds: BracketRoundView[] = [
|
||||
round("upper", 1, 1, ["upper-opening-1", opening.seriesId]),
|
||||
round("upper", 3, 3, [final.seriesId]),
|
||||
round("upper", 3, 3, [upperLater.seriesId]),
|
||||
round("lower", 1, 4, [lower.seriesId]),
|
||||
];
|
||||
|
||||
assert.equal(
|
||||
getTeamSeriesDisplayLabel(opening, rounds),
|
||||
"승자조 1라운드 · 2경기",
|
||||
"브래킷 1R · 2경기",
|
||||
);
|
||||
assert.equal(getTeamSeriesDisplayLabel(final, rounds), "승자조 결승");
|
||||
|
||||
const assignment = tournamentCode("final-1", final.seriesId, 1, 19);
|
||||
assert.equal(
|
||||
getTournamentCodeCopyLabel(assignment, "승자조 결승"),
|
||||
"승자조 결승 1세트 토너먼트 코드 복사 (전체 19번 게임)",
|
||||
getTeamSeriesDisplayLabel(upperLater, rounds),
|
||||
"브래킷 상위 3R",
|
||||
);
|
||||
assert.equal(getTeamSeriesDisplayLabel(lower, rounds), "브래킷 하위 1R");
|
||||
|
||||
const assignment = tournamentCode(
|
||||
"final-1",
|
||||
upperLater.seriesId,
|
||||
1,
|
||||
19,
|
||||
);
|
||||
assert.equal(
|
||||
getTournamentCodeCopyLabel(assignment, "브래킷 상위 3R"),
|
||||
"브래킷 상위 3R 1세트 토너먼트 코드 복사 (전체 19번 게임)",
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
Reference in new issue
Block a user