Spaces:
Running
Running
Add 2 files
Browse files- README.md +7 -5
- index.html +661 -19
README.md
CHANGED
|
@@ -1,10 +1,12 @@
|
|
| 1 |
---
|
| 2 |
-
title:
|
| 3 |
-
emoji:
|
| 4 |
-
colorFrom:
|
| 5 |
-
colorTo:
|
| 6 |
sdk: static
|
| 7 |
pinned: false
|
|
|
|
|
|
|
| 8 |
---
|
| 9 |
|
| 10 |
-
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
|
| 1 |
---
|
| 2 |
+
title: connectfour
|
| 3 |
+
emoji: 🐳
|
| 4 |
+
colorFrom: blue
|
| 5 |
+
colorTo: blue
|
| 6 |
sdk: static
|
| 7 |
pinned: false
|
| 8 |
+
tags:
|
| 9 |
+
- deepsite
|
| 10 |
---
|
| 11 |
|
| 12 |
+
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
index.html
CHANGED
|
@@ -1,19 +1,661 @@
|
|
| 1 |
-
<!
|
| 2 |
-
<html>
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
| 2 |
+
<html lang="en">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="UTF-8">
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
+
<title>Connect Four Game</title>
|
| 7 |
+
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
|
| 8 |
+
<style>
|
| 9 |
+
:root {
|
| 10 |
+
--primary-color: #3498db;
|
| 11 |
+
--player1-color: #e74c3c;
|
| 12 |
+
--player2-color: #f1c40f;
|
| 13 |
+
--empty-cell: #ecf0f1;
|
| 14 |
+
--board-color: #2980b9;
|
| 15 |
+
--text-color: #2c3e50;
|
| 16 |
+
--highlight-color: #2ecc71;
|
| 17 |
+
}
|
| 18 |
+
|
| 19 |
+
* {
|
| 20 |
+
margin: 0;
|
| 21 |
+
padding: 0;
|
| 22 |
+
box-sizing: border-box;
|
| 23 |
+
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
| 24 |
+
}
|
| 25 |
+
|
| 26 |
+
body {
|
| 27 |
+
display: flex;
|
| 28 |
+
flex-direction: column;
|
| 29 |
+
justify-content: center;
|
| 30 |
+
align-items: center;
|
| 31 |
+
min-height: 100vh;
|
| 32 |
+
background: linear-gradient(135deg, #f5f7fa, #c3cfe2);
|
| 33 |
+
color: var(--text-color);
|
| 34 |
+
padding: 20px;
|
| 35 |
+
}
|
| 36 |
+
|
| 37 |
+
.game-container {
|
| 38 |
+
width: 100%;
|
| 39 |
+
max-width: 600px;
|
| 40 |
+
display: flex;
|
| 41 |
+
flex-direction: column;
|
| 42 |
+
align-items: center;
|
| 43 |
+
gap: 25px;
|
| 44 |
+
}
|
| 45 |
+
|
| 46 |
+
.header {
|
| 47 |
+
text-align: center;
|
| 48 |
+
width: 100%;
|
| 49 |
+
}
|
| 50 |
+
|
| 51 |
+
.title {
|
| 52 |
+
font-size: 2.5rem;
|
| 53 |
+
margin-bottom: 10px;
|
| 54 |
+
color: var(--primary-color);
|
| 55 |
+
text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
|
| 56 |
+
}
|
| 57 |
+
|
| 58 |
+
.status {
|
| 59 |
+
font-size: 1.5rem;
|
| 60 |
+
font-weight: 500;
|
| 61 |
+
margin-bottom: 15px;
|
| 62 |
+
min-height: 30px;
|
| 63 |
+
transition: all 0.3s ease;
|
| 64 |
+
}
|
| 65 |
+
|
| 66 |
+
.game-board {
|
| 67 |
+
position: relative;
|
| 68 |
+
background-color: var(--board-color);
|
| 69 |
+
border-radius: 10px;
|
| 70 |
+
padding: 20px;
|
| 71 |
+
box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
|
| 72 |
+
}
|
| 73 |
+
|
| 74 |
+
.board {
|
| 75 |
+
display: grid;
|
| 76 |
+
grid-template-columns: repeat(7, 1fr);
|
| 77 |
+
grid-template-rows: repeat(6, 1fr);
|
| 78 |
+
gap: 10px;
|
| 79 |
+
perspective: 1000px;
|
| 80 |
+
}
|
| 81 |
+
|
| 82 |
+
.cell {
|
| 83 |
+
position: relative;
|
| 84 |
+
width: 60px;
|
| 85 |
+
height: 60px;
|
| 86 |
+
background-color: var(--empty-cell);
|
| 87 |
+
border-radius: 50%;
|
| 88 |
+
cursor: pointer;
|
| 89 |
+
transition: transform 0.3s ease, background-color 0.3s ease;
|
| 90 |
+
box-shadow: inset 0 5px 0 rgba(0, 0, 0, 0.1);
|
| 91 |
+
}
|
| 92 |
+
|
| 93 |
+
.cell::before {
|
| 94 |
+
content: '';
|
| 95 |
+
position: absolute;
|
| 96 |
+
top: 0;
|
| 97 |
+
left: 0;
|
| 98 |
+
right: 0;
|
| 99 |
+
bottom: 0;
|
| 100 |
+
border-radius: 50%;
|
| 101 |
+
box-shadow: inset 0 -5px 0 rgba(0, 0, 0, 0.2);
|
| 102 |
+
z-index: 1;
|
| 103 |
+
}
|
| 104 |
+
|
| 105 |
+
.cell:hover:empty {
|
| 106 |
+
transform: translateY(-5px);
|
| 107 |
+
}
|
| 108 |
+
|
| 109 |
+
.cell.player1 {
|
| 110 |
+
background-color: var(--player1-color);
|
| 111 |
+
}
|
| 112 |
+
|
| 113 |
+
.cell.player2 {
|
| 114 |
+
background-color: var(--player2-color);
|
| 115 |
+
}
|
| 116 |
+
|
| 117 |
+
.cell.winning {
|
| 118 |
+
animation: pulse 1s infinite;
|
| 119 |
+
box-shadow: 0 0 0 5px rgba(46, 204, 113, 0.5);
|
| 120 |
+
}
|
| 121 |
+
|
| 122 |
+
@keyframes pulse {
|
| 123 |
+
0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(46, 204, 113, 0.7); }
|
| 124 |
+
70% { transform: scale(1.05); box-shadow: 0 0 0 10px rgba(46, 204, 113, 0); }
|
| 125 |
+
100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(46, 204, 113, 0); }
|
| 126 |
+
}
|
| 127 |
+
|
| 128 |
+
.column-selector {
|
| 129 |
+
display: flex;
|
| 130 |
+
justify-content: space-between;
|
| 131 |
+
margin-bottom: 10px;
|
| 132 |
+
}
|
| 133 |
+
|
| 134 |
+
.column-btn {
|
| 135 |
+
width: 60px;
|
| 136 |
+
height: 30px;
|
| 137 |
+
background-color: rgba(255, 255, 255, 0.3);
|
| 138 |
+
border: none;
|
| 139 |
+
border-radius: 5px 5px 0 0;
|
| 140 |
+
cursor: pointer;
|
| 141 |
+
transition: all 0.2s ease;
|
| 142 |
+
display: flex;
|
| 143 |
+
justify-content: center;
|
| 144 |
+
align-items: center;
|
| 145 |
+
color: white;
|
| 146 |
+
font-weight: bold;
|
| 147 |
+
}
|
| 148 |
+
|
| 149 |
+
.column-btn:hover {
|
| 150 |
+
background-color: rgba(255, 255, 255, 0.5);
|
| 151 |
+
}
|
| 152 |
+
|
| 153 |
+
.column-btn.active {
|
| 154 |
+
background-color: rgba(255, 255, 255, 0.7);
|
| 155 |
+
}
|
| 156 |
+
|
| 157 |
+
.players {
|
| 158 |
+
display: flex;
|
| 159 |
+
justify-content: space-around;
|
| 160 |
+
width: 100%;
|
| 161 |
+
margin-bottom: 20px;
|
| 162 |
+
}
|
| 163 |
+
|
| 164 |
+
.player {
|
| 165 |
+
display: flex;
|
| 166 |
+
align-items: center;
|
| 167 |
+
gap: 10px;
|
| 168 |
+
padding: 10px 20px;
|
| 169 |
+
border-radius: 10px;
|
| 170 |
+
transition: all 0.3s ease;
|
| 171 |
+
}
|
| 172 |
+
|
| 173 |
+
.player.active {
|
| 174 |
+
background-color: rgba(52, 152, 219, 0.2);
|
| 175 |
+
transform: scale(1.05);
|
| 176 |
+
}
|
| 177 |
+
|
| 178 |
+
.player-icon {
|
| 179 |
+
width: 30px;
|
| 180 |
+
height: 30px;
|
| 181 |
+
border-radius: 50%;
|
| 182 |
+
display: flex;
|
| 183 |
+
justify-content: center;
|
| 184 |
+
align-items: center;
|
| 185 |
+
color: white;
|
| 186 |
+
font-weight: bold;
|
| 187 |
+
}
|
| 188 |
+
|
| 189 |
+
.controls {
|
| 190 |
+
display: flex;
|
| 191 |
+
gap: 15px;
|
| 192 |
+
margin-top: 20px;
|
| 193 |
+
}
|
| 194 |
+
|
| 195 |
+
.btn {
|
| 196 |
+
padding: 12px 24px;
|
| 197 |
+
border: none;
|
| 198 |
+
border-radius: 8px;
|
| 199 |
+
font-size: 1rem;
|
| 200 |
+
font-weight: 600;
|
| 201 |
+
cursor: pointer;
|
| 202 |
+
transition: all 0.3s ease;
|
| 203 |
+
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
|
| 204 |
+
display: flex;
|
| 205 |
+
align-items: center;
|
| 206 |
+
gap: 8px;
|
| 207 |
+
}
|
| 208 |
+
|
| 209 |
+
.btn-primary {
|
| 210 |
+
background-color: var(--primary-color);
|
| 211 |
+
color: white;
|
| 212 |
+
}
|
| 213 |
+
|
| 214 |
+
.btn:hover {
|
| 215 |
+
transform: translateY(-2px);
|
| 216 |
+
box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);
|
| 217 |
+
}
|
| 218 |
+
|
| 219 |
+
.btn:active {
|
| 220 |
+
transform: translateY(1px);
|
| 221 |
+
}
|
| 222 |
+
|
| 223 |
+
.modal {
|
| 224 |
+
position: fixed;
|
| 225 |
+
top: 0;
|
| 226 |
+
left: 0;
|
| 227 |
+
width: 100%;
|
| 228 |
+
height: 100%;
|
| 229 |
+
background-color: rgba(0, 0, 0, 0.8);
|
| 230 |
+
display: flex;
|
| 231 |
+
justify-content: center;
|
| 232 |
+
align-items: center;
|
| 233 |
+
z-index: 100;
|
| 234 |
+
opacity: 0;
|
| 235 |
+
pointer-events: none;
|
| 236 |
+
transition: opacity 0.3s ease;
|
| 237 |
+
}
|
| 238 |
+
|
| 239 |
+
.modal.show {
|
| 240 |
+
opacity: 1;
|
| 241 |
+
pointer-events: all;
|
| 242 |
+
}
|
| 243 |
+
|
| 244 |
+
.modal-content {
|
| 245 |
+
background-color: white;
|
| 246 |
+
border-radius: 10px;
|
| 247 |
+
padding: 30px;
|
| 248 |
+
max-width: 400px;
|
| 249 |
+
width: 90%;
|
| 250 |
+
text-align: center;
|
| 251 |
+
transform: scale(0.8);
|
| 252 |
+
transition: transform 0.3s ease;
|
| 253 |
+
box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
|
| 254 |
+
}
|
| 255 |
+
|
| 256 |
+
.modal.show .modal-content {
|
| 257 |
+
transform: scale(1);
|
| 258 |
+
}
|
| 259 |
+
|
| 260 |
+
.modal h2 {
|
| 261 |
+
margin-bottom: 20px;
|
| 262 |
+
color: var(--primary-color);
|
| 263 |
+
}
|
| 264 |
+
|
| 265 |
+
.modal p {
|
| 266 |
+
margin-bottom: 30px;
|
| 267 |
+
font-size: 1.2rem;
|
| 268 |
+
}
|
| 269 |
+
|
| 270 |
+
.winner-icon {
|
| 271 |
+
font-size: 3rem;
|
| 272 |
+
margin-bottom: 20px;
|
| 273 |
+
}
|
| 274 |
+
|
| 275 |
+
.player1-icon {
|
| 276 |
+
color: var(--player1-color);
|
| 277 |
+
}
|
| 278 |
+
|
| 279 |
+
.player2-icon {
|
| 280 |
+
color: var(--player2-color);
|
| 281 |
+
}
|
| 282 |
+
|
| 283 |
+
.tie-icon {
|
| 284 |
+
color: var(--text-color);
|
| 285 |
+
}
|
| 286 |
+
|
| 287 |
+
@media (max-width: 600px) {
|
| 288 |
+
.cell {
|
| 289 |
+
width: 40px;
|
| 290 |
+
height: 40px;
|
| 291 |
+
}
|
| 292 |
+
|
| 293 |
+
.column-btn {
|
| 294 |
+
width: 40px;
|
| 295 |
+
}
|
| 296 |
+
|
| 297 |
+
.title {
|
| 298 |
+
font-size: 2rem;
|
| 299 |
+
}
|
| 300 |
+
|
| 301 |
+
.status {
|
| 302 |
+
font-size: 1.2rem;
|
| 303 |
+
}
|
| 304 |
+
}
|
| 305 |
+
</style>
|
| 306 |
+
</head>
|
| 307 |
+
<body>
|
| 308 |
+
<div class="game-container">
|
| 309 |
+
<div class="header">
|
| 310 |
+
<h1 class="title">Connect Four</h1>
|
| 311 |
+
<div class="status" id="status">Player 1's Turn</div>
|
| 312 |
+
</div>
|
| 313 |
+
|
| 314 |
+
<div class="players">
|
| 315 |
+
<div class="player active" id="player1">
|
| 316 |
+
<div class="player-icon" style="background-color: var(--player1-color);">
|
| 317 |
+
<i class="fas fa-user"></i>
|
| 318 |
+
</div>
|
| 319 |
+
<span>Player 1</span>
|
| 320 |
+
</div>
|
| 321 |
+
<div class="player" id="player2">
|
| 322 |
+
<div class="player-icon" style="background-color: var(--player2-color);">
|
| 323 |
+
<i class="fas fa-user"></i>
|
| 324 |
+
</div>
|
| 325 |
+
<span>Player 2</span>
|
| 326 |
+
</div>
|
| 327 |
+
</div>
|
| 328 |
+
|
| 329 |
+
<div class="game-board">
|
| 330 |
+
<div class="column-selector" id="column-selector">
|
| 331 |
+
<!-- Column selectors will be added by JavaScript -->
|
| 332 |
+
</div>
|
| 333 |
+
<div class="board" id="board">
|
| 334 |
+
<!-- Cells will be added by JavaScript -->
|
| 335 |
+
</div>
|
| 336 |
+
</div>
|
| 337 |
+
|
| 338 |
+
<div class="controls">
|
| 339 |
+
<button class="btn btn-primary" id="restart-btn">
|
| 340 |
+
<i class="fas fa-redo"></i> Restart Game
|
| 341 |
+
</button>
|
| 342 |
+
</div>
|
| 343 |
+
</div>
|
| 344 |
+
|
| 345 |
+
<div class="modal" id="modal">
|
| 346 |
+
<div class="modal-content">
|
| 347 |
+
<div class="winner-icon" id="winner-icon">
|
| 348 |
+
<i class="fas fa-trophy"></i>
|
| 349 |
+
</div>
|
| 350 |
+
<h2 id="modal-title">Game Over</h2>
|
| 351 |
+
<p id="modal-text">Player 1 wins!</p>
|
| 352 |
+
<button class="btn btn-primary" id="play-again-btn">
|
| 353 |
+
<i class="fas fa-play"></i> Play Again
|
| 354 |
+
</button>
|
| 355 |
+
</div>
|
| 356 |
+
</div>
|
| 357 |
+
|
| 358 |
+
<script>
|
| 359 |
+
document.addEventListener('DOMContentLoaded', () => {
|
| 360 |
+
// Game elements
|
| 361 |
+
const board = document.getElementById('board');
|
| 362 |
+
const columnSelector = document.getElementById('column-selector');
|
| 363 |
+
const statusDisplay = document.getElementById('status');
|
| 364 |
+
const player1Display = document.getElementById('player1');
|
| 365 |
+
const player2Display = document.getElementById('player2');
|
| 366 |
+
const modal = document.getElementById('modal');
|
| 367 |
+
const modalTitle = document.getElementById('modal-title');
|
| 368 |
+
const modalText = document.getElementById('modal-text');
|
| 369 |
+
const winnerIcon = document.getElementById('winner-icon');
|
| 370 |
+
|
| 371 |
+
// Buttons
|
| 372 |
+
const restartBtn = document.getElementById('restart-btn');
|
| 373 |
+
const playAgainBtn = document.getElementById('play-again-btn');
|
| 374 |
+
|
| 375 |
+
// Game variables
|
| 376 |
+
const ROWS = 6;
|
| 377 |
+
const COLS = 7;
|
| 378 |
+
let currentPlayer = 1;
|
| 379 |
+
let gameBoard = Array(ROWS).fill().map(() => Array(COLS).fill(0));
|
| 380 |
+
let gameActive = true;
|
| 381 |
+
let lastMoveRow = -1;
|
| 382 |
+
let lastMoveCol = -1;
|
| 383 |
+
|
| 384 |
+
// Create the game board
|
| 385 |
+
function createBoard() {
|
| 386 |
+
board.innerHTML = '';
|
| 387 |
+
columnSelector.innerHTML = '';
|
| 388 |
+
|
| 389 |
+
// Create column selection buttons
|
| 390 |
+
for (let col = 0; col < COLS; col++) {
|
| 391 |
+
const colBtn = document.createElement('button');
|
| 392 |
+
colBtn.classList.add('column-btn');
|
| 393 |
+
colBtn.dataset.col = col;
|
| 394 |
+
colBtn.innerHTML = `<i class="fas fa-arrow-down"></i>`;
|
| 395 |
+
colBtn.addEventListener('click', () => makeMove(col));
|
| 396 |
+
columnSelector.appendChild(colBtn);
|
| 397 |
+
}
|
| 398 |
+
|
| 399 |
+
// Create game cells
|
| 400 |
+
for (let row = 0; row < ROWS; row++) {
|
| 401 |
+
for (let col = 0; col < COLS; col++) {
|
| 402 |
+
const cell = document.createElement('div');
|
| 403 |
+
cell.classList.add('cell');
|
| 404 |
+
cell.dataset.row = row;
|
| 405 |
+
cell.dataset.col = col;
|
| 406 |
+
board.appendChild(cell);
|
| 407 |
+
}
|
| 408 |
+
}
|
| 409 |
+
}
|
| 410 |
+
|
| 411 |
+
// Make a move in the specified column
|
| 412 |
+
function makeMove(col) {
|
| 413 |
+
if (!gameActive) return;
|
| 414 |
+
|
| 415 |
+
// Find the first empty row in the column
|
| 416 |
+
for (let row = ROWS - 1; row >= 0; row--) {
|
| 417 |
+
if (gameBoard[row][col] === 0) {
|
| 418 |
+
// Update game state
|
| 419 |
+
gameBoard[row][col] = currentPlayer;
|
| 420 |
+
lastMoveRow = row;
|
| 421 |
+
lastMoveCol = col;
|
| 422 |
+
|
| 423 |
+
// Update UI
|
| 424 |
+
const cell = document.querySelector(`.cell[data-row="${row}"][data-col="${col}"]`);
|
| 425 |
+
cell.classList.add(`player${currentPlayer}`);
|
| 426 |
+
|
| 427 |
+
// Check for win or draw
|
| 428 |
+
if (checkWin()) {
|
| 429 |
+
endGame(`Player ${currentPlayer} wins!`);
|
| 430 |
+
highlightWinningCells();
|
| 431 |
+
} else if (isBoardFull()) {
|
| 432 |
+
endGame("It's a draw!");
|
| 433 |
+
} else {
|
| 434 |
+
// Switch players
|
| 435 |
+
currentPlayer = currentPlayer === 1 ? 2 : 1;
|
| 436 |
+
updateStatus();
|
| 437 |
+
}
|
| 438 |
+
return;
|
| 439 |
+
}
|
| 440 |
+
}
|
| 441 |
+
}
|
| 442 |
+
|
| 443 |
+
// Check if the last move resulted in a win
|
| 444 |
+
function checkWin() {
|
| 445 |
+
if (lastMoveRow === -1 || lastMoveCol === -1) return false;
|
| 446 |
+
|
| 447 |
+
const directions = [
|
| 448 |
+
[0, 1], // Horizontal
|
| 449 |
+
[1, 0], // Vertical
|
| 450 |
+
[1, 1], // Diagonal down-right
|
| 451 |
+
[1, -1] // Diagonal down-left
|
| 452 |
+
];
|
| 453 |
+
|
| 454 |
+
for (const [dx, dy] of directions) {
|
| 455 |
+
let count = 1;
|
| 456 |
+
|
| 457 |
+
// Check in positive direction
|
| 458 |
+
for (let i = 1; i < 4; i++) {
|
| 459 |
+
const newRow = lastMoveRow + i * dx;
|
| 460 |
+
const newCol = lastMoveCol + i * dy;
|
| 461 |
+
|
| 462 |
+
if (newRow < 0 || newRow >= ROWS || newCol < 0 || newCol >= COLS) break;
|
| 463 |
+
if (gameBoard[newRow][newCol] !== currentPlayer) break;
|
| 464 |
+
|
| 465 |
+
count++;
|
| 466 |
+
}
|
| 467 |
+
|
| 468 |
+
// Check in negative direction
|
| 469 |
+
for (let i = 1; i < 4; i++) {
|
| 470 |
+
const newRow = lastMoveRow - i * dx;
|
| 471 |
+
const newCol = lastMoveCol - i * dy;
|
| 472 |
+
|
| 473 |
+
if (newRow < 0 || newRow >= ROWS || newCol < 0 || newCol >= COLS) break;
|
| 474 |
+
if (gameBoard[newRow][newCol] !== currentPlayer) break;
|
| 475 |
+
|
| 476 |
+
count++;
|
| 477 |
+
}
|
| 478 |
+
|
| 479 |
+
if (count >= 4) return true;
|
| 480 |
+
}
|
| 481 |
+
|
| 482 |
+
return false;
|
| 483 |
+
}
|
| 484 |
+
|
| 485 |
+
// Highlight the winning cells
|
| 486 |
+
function highlightWinningCells() {
|
| 487 |
+
const winningCells = findWinningCells();
|
| 488 |
+
if (!winningCells) return;
|
| 489 |
+
|
| 490 |
+
winningCells.forEach(([row, col]) => {
|
| 491 |
+
const cell = document.querySelector(`.cell[data-row="${row}"][data-col="${col}"]`);
|
| 492 |
+
cell.classList.add('winning');
|
| 493 |
+
});
|
| 494 |
+
}
|
| 495 |
+
|
| 496 |
+
// Find the winning cells (returns undefined if no win)
|
| 497 |
+
function findWinningCells() {
|
| 498 |
+
if (lastMoveRow === -1 || lastMoveCol === -1) return;
|
| 499 |
+
|
| 500 |
+
const directions = [
|
| 501 |
+
[0, 1], // Horizontal
|
| 502 |
+
[1, 0], // Vertical
|
| 503 |
+
[1, 1], // Diagonal down-right
|
| 504 |
+
[1, -1] // Diagonal down-left
|
| 505 |
+
];
|
| 506 |
+
|
| 507 |
+
for (const [dx, dy] of directions) {
|
| 508 |
+
let cells = [[lastMoveRow, lastMoveCol]];
|
| 509 |
+
|
| 510 |
+
// Check in positive direction
|
| 511 |
+
for (let i = 1; i < 4; i++) {
|
| 512 |
+
const newRow = lastMoveRow + i * dx;
|
| 513 |
+
const newCol = lastMoveCol + i * dy;
|
| 514 |
+
|
| 515 |
+
if (newRow < 0 || newRow >= ROWS || newCol < 0 || newCol >= COLS) break;
|
| 516 |
+
if (gameBoard[newRow][newCol] !== currentPlayer) break;
|
| 517 |
+
|
| 518 |
+
cells.push([newRow, newCol]);
|
| 519 |
+
}
|
| 520 |
+
|
| 521 |
+
// Check in negative direction
|
| 522 |
+
for (let i = 1; i < 4; i++) {
|
| 523 |
+
const newRow = lastMoveRow - i * dx;
|
| 524 |
+
const newCol = lastMoveCol - i * dy;
|
| 525 |
+
|
| 526 |
+
if (newRow < 0 || newRow >= ROWS || newCol < 0 || newCol >= COLS) break;
|
| 527 |
+
if (gameBoard[newRow][newCol] !== currentPlayer) break;
|
| 528 |
+
|
| 529 |
+
cells.push([newRow, newCol]);
|
| 530 |
+
}
|
| 531 |
+
|
| 532 |
+
if (cells.length >= 4) {
|
| 533 |
+
return cells.slice(0, 4); // Return first 4 cells in a row
|
| 534 |
+
}
|
| 535 |
+
}
|
| 536 |
+
|
| 537 |
+
return;
|
| 538 |
+
}
|
| 539 |
+
|
| 540 |
+
// Check if the board is full (draw)
|
| 541 |
+
function isBoardFull() {
|
| 542 |
+
return gameBoard.every(row => row.every(cell => cell !== 0));
|
| 543 |
+
}
|
| 544 |
+
|
| 545 |
+
// End the game with the given message
|
| 546 |
+
function endGame(message) {
|
| 547 |
+
gameActive = false;
|
| 548 |
+
|
| 549 |
+
// Show modal
|
| 550 |
+
modalTitle.textContent = message.includes('wins') ? 'Winner!' : 'Game Over';
|
| 551 |
+
modalText.textContent = message;
|
| 552 |
+
|
| 553 |
+
// Set winner icon
|
| 554 |
+
if (message.includes('Player 1')) {
|
| 555 |
+
winnerIcon.className = 'winner-icon player1-icon';
|
| 556 |
+
winnerIcon.innerHTML = '<i class="fas fa-trophy"></i>';
|
| 557 |
+
} else if (message.includes('Player 2')) {
|
| 558 |
+
winnerIcon.className = 'winner-icon player2-icon';
|
| 559 |
+
winnerIcon.innerHTML = '<i class="fas fa-trophy"></i>';
|
| 560 |
+
} else {
|
| 561 |
+
winnerIcon.className = 'winner-icon tie-icon';
|
| 562 |
+
winnerIcon.innerHTML = '<i class="fas fa-handshake"></i>';
|
| 563 |
+
}
|
| 564 |
+
|
| 565 |
+
modal.classList.add('show');
|
| 566 |
+
}
|
| 567 |
+
|
| 568 |
+
// Update the game status display
|
| 569 |
+
function updateStatus() {
|
| 570 |
+
statusDisplay.textContent = `Player ${currentPlayer}'s Turn`;
|
| 571 |
+
|
| 572 |
+
// Update active player highlight
|
| 573 |
+
if (currentPlayer === 1) {
|
| 574 |
+
player1Display.classList.add('active');
|
| 575 |
+
player2Display.classList.remove('active');
|
| 576 |
+
} else {
|
| 577 |
+
player1Display.classList.remove('active');
|
| 578 |
+
player2Display.classList.add('active');
|
| 579 |
+
}
|
| 580 |
+
}
|
| 581 |
+
|
| 582 |
+
// Reset the game
|
| 583 |
+
function resetGame() {
|
| 584 |
+
gameBoard = Array(ROWS).fill().map(() => Array(COLS).fill(0));
|
| 585 |
+
currentPlayer = 1;
|
| 586 |
+
gameActive = true;
|
| 587 |
+
lastMoveRow = -1;
|
| 588 |
+
lastMoveCol = -1;
|
| 589 |
+
|
| 590 |
+
// Reset UI
|
| 591 |
+
document.querySelectorAll('.cell').forEach(cell => {
|
| 592 |
+
cell.className = 'cell';
|
| 593 |
+
});
|
| 594 |
+
|
| 595 |
+
updateStatus();
|
| 596 |
+
modal.classList.remove('show');
|
| 597 |
+
}
|
| 598 |
+
|
| 599 |
+
// Event listeners
|
| 600 |
+
restartBtn.addEventListener('click', resetGame);
|
| 601 |
+
playAgainBtn.addEventListener('click', resetGame);
|
| 602 |
+
|
| 603 |
+
// Initialize the game
|
| 604 |
+
createBoard();
|
| 605 |
+
updateStatus();
|
| 606 |
+
|
| 607 |
+
// Keyboard controls
|
| 608 |
+
document.addEventListener('keydown', (e) => {
|
| 609 |
+
if (!gameActive) return;
|
| 610 |
+
|
| 611 |
+
// 1-7 keys for columns
|
| 612 |
+
if (e.key >= '1' && e.key <= '7') {
|
| 613 |
+
const col = parseInt(e.key) - 1;
|
| 614 |
+
if (col >= 0 && col < COLS) {
|
| 615 |
+
makeMove(col);
|
| 616 |
+
}
|
| 617 |
+
}
|
| 618 |
+
// Left/Right arrow keys for column selection
|
| 619 |
+
else if (e.key === 'ArrowLeft' || e.key === 'ArrowRight') {
|
| 620 |
+
const colBtns = document.querySelectorAll('.column-btn');
|
| 621 |
+
let currentCol = 0;
|
| 622 |
+
|
| 623 |
+
// Find the currently selected column (if any)
|
| 624 |
+
const activeBtn = document.querySelector('.column-btn.active');
|
| 625 |
+
if (activeBtn) {
|
| 626 |
+
currentCol = parseInt(activeBtn.dataset.col);
|
| 627 |
+
}
|
| 628 |
+
|
| 629 |
+
// Determine new selection
|
| 630 |
+
let newCol = currentCol;
|
| 631 |
+
if (e.key === 'ArrowLeft') {
|
| 632 |
+
newCol = Math.max(0, currentCol - 1);
|
| 633 |
+
} else if (e.key === 'ArrowRight') {
|
| 634 |
+
newCol = Math.min(COLS - 1, currentCol + 1);
|
| 635 |
+
}
|
| 636 |
+
|
| 637 |
+
// Update selection
|
| 638 |
+
colBtns.forEach(btn => btn.classList.remove('active'));
|
| 639 |
+
colBtns[newCol].classList.add('active');
|
| 640 |
+
}
|
| 641 |
+
// Space or Enter to make move in selected column
|
| 642 |
+
else if (e.key === ' ' || e.key === 'Enter') {
|
| 643 |
+
const activeBtn = document.querySelector('.column-btn.active');
|
| 644 |
+
if (activeBtn) {
|
| 645 |
+
makeMove(parseInt(activeBtn.dataset.col));
|
| 646 |
+
}
|
| 647 |
+
}
|
| 648 |
+
});
|
| 649 |
+
|
| 650 |
+
// Hide selection highlight when clicking outside
|
| 651 |
+
document.addEventListener('click', (e) => {
|
| 652 |
+
if (!e.target.classList.contains('column-btn')) {
|
| 653 |
+
document.querySelectorAll('.column-btn').forEach(btn => {
|
| 654 |
+
btn.classList.remove('active');
|
| 655 |
+
});
|
| 656 |
+
}
|
| 657 |
+
});
|
| 658 |
+
});
|
| 659 |
+
</script>
|
| 660 |
+
<p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: absolute; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">This website has been generated by <a href="https://enzostvs-deepsite.hf.space" style="color: #fff;" target="_blank" >DeepSite</a> <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;"></p></body>
|
| 661 |
+
</html>
|