diff --git a/src/components/TeamTable.vue b/src/components/TeamTable.vue index 4f61749..d31d004 100644 --- a/src/components/TeamTable.vue +++ b/src/components/TeamTable.vue @@ -122,6 +122,20 @@ const groupName = (id: string | null) => { background-color: rgb(31, 202, 131); } } + + &.play-in { + position: relative; + + ::before { + content: ""; + position: absolute; + top: 2px; + left: 0; + width: 2px; + height: calc(100% - 4px); + background-color: var(--color-brand-blue); + } + } } @media screen and (max-width: 600px) { diff --git a/src/components/TeamTableEntry.vue b/src/components/TeamTableEntry.vue index 6bdf8d0..56f334c 100644 --- a/src/components/TeamTableEntry.vue +++ b/src/components/TeamTableEntry.vue @@ -18,6 +18,7 @@ const teamName = computed(() => { const progress = computed(() => { let proceedingTeams = 0; + let byeTeams = 0; const phaseI = props.tournament.phases.findIndex((p) => p.id === props.phaseId); if (phaseI < props.tournament.phases.length - 1) { @@ -25,7 +26,13 @@ const progress = computed(() => { if (nextPhase.teamCount) { const currentPhase = props.tournament.phases[phaseI] as GroupTournamentPhase; - proceedingTeams = nextPhase.teamCount / (currentPhase.groups?.length ?? 1); + const groupCount = currentPhase.groups?.length ?? 1; + proceedingTeams = nextPhase.teamCount / groupCount; + + if (nextPhase.type === "knockout") { + const powerOfTwo = nextPowerOfTwo(nextPhase.teamCount); + byeTeams = (powerOfTwo - nextPhase.teamCount) / groupCount; + } } else { proceedingTeams = props.rank; } @@ -33,15 +40,23 @@ const progress = computed(() => { const def = Math.floor(proceedingTeams); const maybe = Math.ceil(proceedingTeams); + const byeDef = Math.floor(byeTeams); - if (props.rank <= def) { + if (byeDef > 0 && props.rank <= byeDef) { return "progress"; + } else if (props.rank <= def) { + return "play-in"; } else if (props.rank === maybe) { return "maybe"; } return null; }); + +const nextPowerOfTwo = (value: number): number => { + if (value <= 1) return 1; + return 2 ** Math.ceil(Math.log2(value)); +};