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>