/** * Returns the draft slot for a given pick number in a snake draft. */ export function getTeamForPick( pickNumber: number, draftSlots: T[] ): T | undefined { const totalTeams = draftSlots.length; if (totalTeams === 0) return undefined; const round = Math.ceil(pickNumber / totalTeams); const isEvenRound = round % 2 === 0; let pickInRound = ((pickNumber - 1) % totalTeams) + 1; if (isEvenRound) { pickInRound = totalTeams - pickInRound + 1; } return draftSlots.find((slot) => slot.draftOrder === pickInRound); }