From 853cd3756b007abcc92c246d8e8f672c685ad27b Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 23 Feb 2026 02:01:09 +0000 Subject: [PATCH] Fix force-manual-pick resetting next team's timer to initial time When a commissioner forced a manual pick, the next team's timer was being reset to the initial time (2 minutes) instead of carrying forward their existing time bank balance. This aligns force-manual-pick with the behavior of regular user picks and force-autopick: the picking team gets their increment added, and the next team's timer is left untouched so their bank carries forward. https://claude.ai/code/session_01X7gwWmafUSEvVHcV7Raz5p --- app/routes/api/draft.force-manual-pick.ts | 61 ++--------------------- 1 file changed, 3 insertions(+), 58 deletions(-) diff --git a/app/routes/api/draft.force-manual-pick.ts b/app/routes/api/draft.force-manual-pick.ts index 03176be..5fa8276 100644 --- a/app/routes/api/draft.force-manual-pick.ts +++ b/app/routes/api/draft.force-manual-pick.ts @@ -178,65 +178,10 @@ export async function action(args: any) { console.error("Socket.IO timer-update error:", error); } - // Initialize timer for the next team BEFORE updating pick number (prevents race condition) - if (!isDraftComplete) { - // Calculate which team is next using snake draft logic - const nextRound = Math.ceil(nextPickNumber / totalTeams); - const isNextRoundEven = nextRound % 2 === 0; - let nextPickInRound = ((nextPickNumber - 1) % totalTeams) + 1; + // Next team's timer is unchanged — their bank carries forward as-is. + // The timer server loop will start counting down from their existing balance. - // Apply snake draft reversal for even rounds - if (isNextRoundEven) { - nextPickInRound = totalTeams - nextPickInRound + 1; - } - - const nextDraftSlot = draftSlots.find((slot) => slot.draftOrder === nextPickInRound); - - if (nextDraftSlot) { - const nextTeamId = nextDraftSlot.teamId; - const initialTime = season.draftInitialTime || 120; - - // Check if timer already exists for next team - const nextTimer = await db.query.draftTimers.findFirst({ - where: and( - eq(schema.draftTimers.seasonId, seasonId), - eq(schema.draftTimers.teamId, nextTeamId) - ), - }); - - if (nextTimer) { - // Update existing timer - await db - .update(schema.draftTimers) - .set({ - timeRemaining: initialTime, - updatedAt: new Date(), - }) - .where(eq(schema.draftTimers.id, nextTimer.id)); - } else { - // Create new timer if it doesn't exist - await db.insert(schema.draftTimers).values({ - seasonId, - teamId: nextTeamId, - timeRemaining: initialTime, - }); - } - - // Emit timer update for next team - try { - getSocketIO().to(`draft-${seasonId}`).emit("timer-update", { - seasonId, - teamId: nextTeamId, - timeRemaining: initialTime, - currentPickNumber: nextPickNumber, - }); - } catch (error) { - console.error("Socket.IO next timer-update error:", error); - } - } - } - - // Update season's current pick number (AFTER initializing next timer to prevent race condition) + // Update season's current pick number await db .update(schema.seasons) .set({