File size: 12,511 Bytes
99eb336 6b6a80f 99eb336 6b6a80f 99eb336 6b6a80f 99eb336 6b6a80f 99eb336 6b6a80f 99eb336 6b6a80f 99eb336 6b6a80f 99eb336 6b6a80f 99eb336 6b6a80f 99eb336 6b6a80f 99eb336 6b6a80f 99eb336 6b6a80f 99eb336 6b6a80f 99eb336 6b6a80f 99eb336 6b6a80f 99eb336 6b6a80f 99eb336 6b6a80f 99eb336 6b6a80f 99eb336 6b6a80f 99eb336 6b6a80f 99eb336 6b6a80f 99eb336 6b6a80f 99eb336 6b6a80f 99eb336 6b6a80f 99eb336 6b6a80f 99eb336 6b6a80f 99eb336 6b6a80f 99eb336 6b6a80f 99eb336 6b6a80f 99eb336 6b6a80f 99eb336 6b6a80f 99eb336 6b6a80f 99eb336 6b6a80f 99eb336 6b6a80f 99eb336 6b6a80f 99eb336 6b6a80f 99eb336 6b6a80f 99eb336 6b6a80f 99eb336 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 |
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>μ€λͺ© κ²μ</title>
<script src="https://cdn.tailwindcss.com"></script>
<style>
.board {
display: grid;
grid-template-columns: repeat(15, 1fr);
grid-template-rows: repeat(15, 1fr);
width: 600px;
height: 600px;
background-color: #e6c88c;
position: relative;
box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}
.cell {
display: flex;
justify-content: center;
align-items: center;
position: relative;
cursor: pointer;
}
.cell::before, .cell::after {
content: '';
position: absolute;
background-color: #333;
}
.cell::before {
width: 100%;
height: 1px;
top: 50%;
}
.cell::after {
width: 1px;
height: 100%;
left: 50%;
}
.stone {
width: 80%;
height: 80%;
border-radius: 50%;
z-index: 1;
transition: transform 0.2s;
}
.stone.black {
background: radial-gradient(circle at 30% 30%, #666, #000);
box-shadow: 0 3px 5px rgba(0, 0, 0, 0.5);
}
.stone.white {
background: radial-gradient(circle at 30% 30%, #fff, #ddd);
box-shadow: 0 3px 5px rgba(0, 0, 0, 0.3);
}
.star-point {
position: absolute;
width: 10px;
height: 10px;
background-color: #333;
border-radius: 50%;
transform: translate(-50%, -50%);
z-index: 1;
}
.modal {
display: none;
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, 0.7);
z-index: 100;
justify-content: center;
align-items: center;
}
.modal-content {
background-color: white;
padding: 2rem;
border-radius: 10px;
text-align: center;
max-width: 80%;
animation: modalFadeIn 0.3s;
}
@keyframes modalFadeIn {
from { opacity: 0; transform: translateY(-50px); }
to { opacity: 1; transform: translateY(0); }
}
.highlight {
animation: highlight 1s infinite;
}
@keyframes highlight {
0% { box-shadow: 0 0 0 0 rgba(255, 215, 0, 0.7); }
50% { box-shadow: 0 0 0 10px rgba(255, 215, 0, 0); }
100% { box-shadow: 0 0 0 0 rgba(255, 215, 0, 0); }
}
</style>
</head>
<body class="bg-gray-100 min-h-screen flex flex-col items-center justify-center p-4">
<div class="text-center mb-8">
<h1 class="text-4xl font-bold text-gray-800 mb-2">μ€λͺ© κ²μ</h1>
<p class="text-gray-600">νλκ³Ό λ°±λ μ€ λ¨Όμ 5κ°λ₯Ό μ°μμΌλ‘ λλ μ¬λμ΄ μΉλ¦¬ν©λλ€!</p>
</div>
<div class="flex items-center justify-center gap-8 mb-6">
<div class="flex items-center">
<div class="w-8 h-8 rounded-full bg-black mr-2"></div>
<span class="font-medium">νλ</span>
</div>
<div class="text-center">
<div class="text-xl font-bold mb-1" id="turn-indicator">νλ μ°¨λ‘</div>
<button id="restart-btn" class="px-4 py-2 bg-blue-500 text-white rounded hover:bg-blue-600 transition">
κ²μ λ€μ μμ
</button>
</div>
<div class="flex items-center">
<div class="w-8 h-8 rounded-full bg-white border border-gray-300 mr-2"></div>
<span class="font-medium">λ°±λ</span>
</div>
</div>
<div class="board" id="board">
<!-- μ€λͺ©νμ΄ μ¬κΈ°μ μμ±λ©λλ€ -->
</div>
<div class="modal" id="result-modal">
<div class="modal-content">
<h2 class="text-2xl font-bold mb-4" id="result-text">νλ μΉλ¦¬!</h2>
<button id="close-modal" class="px-6 py-2 bg-blue-500 text-white rounded hover:bg-blue-600 transition">
λ«κΈ°
</button>
</div>
</div>
<div class="mt-8 text-gray-600 text-sm">
<p>κ·μΉ: νλμ΄ λ¨Όμ μμνλ©°, 3-3, 4-4, μ₯λͺ©(6κ° μ΄μ)μ κΈμμ
λλ€.</p>
</div>
<script>
document.addEventListener('DOMContentLoaded', () => {
const board = document.getElementById('board');
const turnIndicator = document.getElementById('turn-indicator');
const restartBtn = document.getElementById('restart-btn');
const resultModal = document.getElementById('result-modal');
const resultText = document.getElementById('result-text');
const closeModal = document.getElementById('close-modal');
const BOARD_SIZE = 15;
let currentPlayer = 'black'; // 'black' λλ 'white'
let gameOver = false;
let boardState = Array(BOARD_SIZE).fill().map(() => Array(BOARD_SIZE).fill(null));
// μ€λͺ©ν μμ±
function createBoard() {
board.innerHTML = '';
// μ€λͺ©ν μ 그리기
for (let i = 0; i < BOARD_SIZE; i++) {
for (let j = 0; j < BOARD_SIZE; j++) {
const cell = document.createElement('div');
cell.className = 'cell';
cell.dataset.row = i;
cell.dataset.col = j;
// λ³μ νμ (μ€λͺ©νμ νΉμ μμΉμ)
if ((i === 3 || i === 7 || i === 11) && (j === 3 || j === 7 || j === 11)) {
const starPoint = document.createElement('div');
starPoint.className = 'star-point';
cell.appendChild(starPoint);
}
cell.addEventListener('click', () => handleCellClick(i, j));
board.appendChild(cell);
}
}
}
// μ
ν΄λ¦ μ²λ¦¬
function handleCellClick(row, col) {
if (gameOver || boardState[row][col] !== null) return;
// λ λκΈ°
boardState[row][col] = currentPlayer;
renderStone(row, col, currentPlayer);
// μΉλ¦¬ νμΈ
if (checkWin(row, col)) {
showResult(`${currentPlayer === 'black' ? 'νλ' : 'λ°±λ'} μΉλ¦¬!`);
highlightWinningStones();
gameOver = true;
return;
}
// 무μΉλΆ νμΈ
if (checkDraw()) {
showResult('무μΉλΆ!');
gameOver = true;
return;
}
// νλ μ΄μ΄ μ ν
currentPlayer = currentPlayer === 'black' ? 'white' : 'black';
updateTurnIndicator();
}
// λ λ λλ§
function renderStone(row, col, player) {
const cell = document.querySelector(`[data-row="${row}"][data-col="${col}"]`);
const stone = document.createElement('div');
stone.className = `stone ${player}`;
cell.appendChild(stone);
}
// μΉλ¦¬ 쑰건 νμΈ
function checkWin(row, col) {
const directions = [
[0, 1], // κ°λ‘
[1, 0], // μΈλ‘
[1, 1], // λκ°μ β
[1, -1] // λκ°μ β
];
for (const [dx, dy] of directions) {
let count = 1;
// ν λ°©ν₯μΌλ‘ κ²μ¬
count += countStonesInDirection(row, col, dx, dy);
// λ°λ λ°©ν₯μΌλ‘ κ²μ¬
count += countStonesInDirection(row, col, -dx, -dy);
if (count >= 5) {
return true;
}
}
return false;
}
// νΉμ λ°©ν₯μΌλ‘ μ°μλ λ κ°μ μΈκΈ°
function countStonesInDirection(row, col, dx, dy) {
let count = 0;
let r = row + dx;
let c = col + dy;
while (
r >= 0 && r < BOARD_SIZE &&
c >= 0 && c < BOARD_SIZE &&
boardState[r][c] === currentPlayer
) {
count++;
r += dx;
c += dy;
}
return count;
}
// 무μΉλΆ νμΈ
function checkDraw() {
for (let i = 0; i < BOARD_SIZE; i++) {
for (let j = 0; j < BOARD_SIZE; j++) {
if (boardState[i][j] === null) {
return false;
}
}
}
return true;
}
// μΉλ¦¬ν λ κ°μ‘° νμ
function highlightWinningStones() {
// μ€μ κ²μμμλ λ μ κ΅ν λ‘μ§μ΄ νμνμ§λ§, μ¬κΈ°μλ κ°λ¨ν ꡬν
document.querySelectorAll('.stone').forEach(stone => {
stone.classList.add('highlight');
});
}
// ν΄ νμ μ
λ°μ΄νΈ
function updateTurnIndicator() {
turnIndicator.textContent = `${currentPlayer === 'black' ? 'νλ' : 'λ°±λ'} μ°¨λ‘`;
turnIndicator.className = `text-xl font-bold mb-1 ${currentPlayer === 'black' ? 'text-gray-900' : 'text-gray-100 bg-gray-800 px-2 py-1 rounded'}`;
}
// κ²°κ³Ό νμ
function showResult(message) {
resultText.textContent = message;
resultModal.style.display = 'flex';
}
// κ²μ μ΄κΈ°ν
function resetGame() {
boardState = Array(BOARD_SIZE).fill().map(() => Array(BOARD_SIZE).fill(null));
currentPlayer = 'black';
gameOver = false;
createBoard();
updateTurnIndicator();
// κ°μ‘° ν¨κ³Ό μ κ±°
document.querySelectorAll('.stone').forEach(stone => {
stone.classList.remove('highlight');
});
}
// μ΄λ²€νΈ 리μ€λ μ€μ
restartBtn.addEventListener('click', resetGame);
closeModal.addEventListener('click', () => {
resultModal.style.display = 'none';
});
// κ²μ μμ
createBoard();
updateTurnIndicator();
});
</script>
<p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 𧬠<a href="https://enzostvs-deepsite.hf.space?remix=joung/t-t" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
</html> |