From d79c3d0cb602f48c4701e46722d7c1855230b556 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 10 Dec 2025 21:50:34 +0000 Subject: [PATCH 1/3] Initial plan From 17e3c34f1834e853351b94fc81850078b287c4d8 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 10 Dec 2025 21:57:14 +0000 Subject: [PATCH 2/3] Add game mode selection and update timer system to 2-minute cumulative Co-authored-by: CodeKunalTomar <111980003+CodeKunalTomar@users.noreply.github.com> --- Connect-4.css | 108 +++++++++++++++++---- Connect-4.js | 18 ++++ index.html | 29 +++++- index.js | 262 ++++++++++++++++++++++++++++++++++++++------------ 4 files changed, 328 insertions(+), 89 deletions(-) diff --git a/Connect-4.css b/Connect-4.css index 8a160f2..03d20de 100644 --- a/Connect-4.css +++ b/Connect-4.css @@ -55,51 +55,117 @@ h2 { border-radius: 8px; } +/* Setup Panel - Mode Selection */ +.setup-panel h2 { + margin-bottom: 12px; + text-align: center; +} + +.mode-select { + display: flex; + gap: 10px; + margin-bottom: 0; +} + +.mode-btn { + flex: 1; + padding: 15px 10px; + background-color: rgba(255, 255, 255, 0.1); + border: 2px solid #666; + border-radius: 8px; + color: #ccc; + cursor: pointer; + transition: all 0.3s ease; + text-align: center; + font-family: "Doppio One", sans-serif; + font-size: 14px; +} + +.mode-btn:hover { + background-color: rgba(255, 255, 255, 0.2); + border-color: #999; +} + +.mode-btn.selected { + background-color: #593f6b; + border-color: #fff; + color: #fff; +} + +.mode-btn .icon { + font-size: 24px; + display: block; + margin-bottom: 5px; +} + +.mode-btn:focus { + outline: none; +} + /* Timer Panel */ .timer-panel { display: flex; flex-direction: column; - gap: 10px; - padding: 15px; + gap: 8px; + padding: 12px; } .timer { - padding: 15px; + padding: 12px; background-color: rgba(255, 255, 255, 0.1); border-radius: 8px; - font-family: "Doppio One", monospace; - text-align: center; border: 2px solid transparent; transition: all 0.3s ease; + display: flex; + justify-content: space-between; + align-items: center; +} + +.timer-label { + font-size: 14px; + color: #aaa; + font-family: "Doppio One", sans-serif; +} + +.timer-value { + font-size: 24px; + font-family: "Courier New", monospace; + color: #fff; + font-weight: bold; } .timer.active { border-color: #4CAF50; - box-shadow: 0 0 15px rgba(76, 175, 80, 0.5); - background-color: rgba(76, 175, 80, 0.2); + box-shadow: 0 0 10px rgba(76, 175, 80, 0.4); + background-color: rgba(76, 175, 80, 0.15); +} + +.timer.active .timer-label { + color: #4CAF50; } .timer.warning { - border-color: #f44336; - background-color: rgba(244, 67, 54, 0.2); - animation: pulse 1s infinite; + border-color: #ff9800; + background-color: rgba(255, 152, 0, 0.15); } -@keyframes pulse { - 0%, 100% { opacity: 1; } - 50% { opacity: 0.6; } +.timer.warning .timer-value { + color: #ff9800; } -.timer-label { - font-size: 14px; - color: #aaa; - margin-bottom: 5px; +.timer.critical { + border-color: #f44336; + background-color: rgba(244, 67, 54, 0.15); + animation: pulse-critical 0.5s infinite; } -.timer-value { - font-size: 32px; - color: #fff; - font-weight: bold; +.timer.critical .timer-value { + color: #f44336; +} + +@keyframes pulse-critical { + 0%, 100% { opacity: 1; } + 50% { opacity: 0.7; } } /* Start Panel */ diff --git a/Connect-4.js b/Connect-4.js index 78ab459..d03b83d 100644 --- a/Connect-4.js +++ b/Connect-4.js @@ -308,6 +308,9 @@ self.addEventListener('message', function(e) { case 'human-move': makeHumanMove(e.data.col); break; + case 'player2-move': + makePlayer2Move(e.data.col); + break; case 'computer-move': makeComputerMove(e.data.maxDepth); break; @@ -340,6 +343,21 @@ function makeHumanMove(col) { }); } +function makePlayer2Move(col) { + // coords is undefined if the move is invalid (column is full) + const coords = currentGameState.makeMove(2, col); + const isWin = currentGameState.isWin(); + const winningChips = currentGameState.winningChips; + const isBoardFull = currentGameState.isBoardFull(); + self.postMessage({ + messageType: 'player2-move-done', + coords: coords, + isWin: isWin, + winningChips: winningChips, + isBoardFull: isBoardFull + }); +} + function makeComputerMove(maxDepth) { let col; let isWinImminent = false; diff --git a/index.html b/index.html index f33cf02..9a5ca68 100644 --- a/index.html +++ b/index.html @@ -11,19 +11,38 @@