Skip to content

Commit fe043ac

Browse files
Update index.html
1 parent bc4cdb0 commit fe043ac

File tree

1 file changed

+73
-46
lines changed

1 file changed

+73
-46
lines changed

index.html

Lines changed: 73 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
<title>DeveloperCrcodile's Portal</title>
77
<style>
88
:root {
9-
--color-primary: #bb86fc; /* Purple for titles and player X */
10-
--color-secondary: #03dac6; /* Teal for links and borders */
9+
--color-primary: #bb86fc; /* Purple for titles and borders */
10+
--color-secondary: #03dac6; /* Teal for glows and links */
1111
--color-danger: #ff4d4d; /* Red for AI player O */
1212
--color-background: #121212;
1313
--color-surface: #2c2c2e;
@@ -38,24 +38,49 @@
3838
.game-wrapper { transition: opacity 0.5s ease-in-out; position: relative; }
3939
.status { font-size: 1.5em; height: 30px; color: var(--color-text-alt); margin-bottom: 15px;}
4040

41-
/* Shared Cell Styles */
42-
.cell { border-radius: 10px; cursor: pointer; display: flex; justify-content: center; align-items: center; font-weight: bold; }
41+
/* NEW: Universal Cell Style */
42+
.cell {
43+
border-radius: 10px;
44+
cursor: pointer;
45+
display: flex;
46+
justify-content: center;
47+
align-items: center;
48+
font-weight: bold;
49+
background-color: #1a1f23; /* Dark base for the glow */
50+
border: 2px solid var(--color-primary); /* Purple outline */
51+
/* The Neon Glow Effect */
52+
box-shadow: inset 0 0 15px #03dac677, /* Inner teal glow */
53+
0 0 5px #03dac655; /* Outer teal glow */
54+
transition: transform 0.2s ease;
55+
}
56+
.cell:hover {
57+
transform: scale(1.03); /* Subtle pop effect on hover */
58+
}
59+
4360
.cell.x { color: var(--color-primary); text-shadow: 0 0 10px var(--color-primary); }
4461
.cell.o { color: var(--color-danger); text-shadow: 0 0 10px var(--color-danger); }
4562

46-
/* Initial Board - The chunky, stylish one */
63+
/* Initial Board - defines size and font */
4764
.initial-board { display: grid; grid-template-columns: repeat(3, 100px); gap: 10px; }
48-
.initial-board .cell { width: 100px; height: 100px; font-size: 4em; border: 2px solid var(--color-secondary); box-shadow: 0 0 10px var(--color-secondary); }
65+
.initial-board .cell { width: 100px; height: 100px; font-size: 4em; }
4966

50-
/* Ultimate Board - Made to look like 9 smaller versions of the initial board */
67+
/* Ultimate Board - a grid of smaller, stylish boards */
5168
.ultimate-board { display: grid; grid-template-columns: repeat(3, 1fr); gap: 15px; padding: 15px; background-color: var(--color-surface); border-radius: 15px; }
5269
.local-board {
5370
display: grid; grid-template-columns: repeat(3, 60px); grid-template-rows: repeat(3, 60px); gap: 5px;
54-
border: 2px solid var(--color-secondary); box-shadow: 0 0 10px var(--color-secondary);
55-
border-radius: 10px; transition: border-color 0.3s, box-shadow 0.3s; position: relative;
71+
border: 2px solid var(--color-secondary);
72+
box-shadow: 0 0 10px var(--color-secondary);
73+
border-radius: 10px;
74+
transition: border-color 0.3s, box-shadow 0.3s;
75+
position: relative;
76+
background-color: var(--color-background);
5677
}
5778
.local-board.active { border-color: var(--color-primary); box-shadow: 0 0 20px var(--color-primary); }
58-
.local-board .cell { width: 60px; height: 60px; font-size: 2.5em; background-color: var(--color-background); }
79+
.local-board .cell {
80+
width: 60px; height: 60px; font-size: 2.5em;
81+
/* Tweak glow for smaller cells */
82+
box-shadow: inset 0 0 10px #03dac677, 0 0 3px #03dac655;
83+
}
5984

6085
.local-board .winner-overlay { position: absolute; top: 0; left: 0; right: 0; bottom: 0; font-size: 6em; font-weight: bold; display: flex; justify-content: center; align-items: center; pointer-events: none; }
6186

@@ -98,6 +123,9 @@ <h3>Ultimate Tic-Tac-Toe Rules</h3>
98123
</div>
99124

100125
<script>
126+
// --- All JavaScript logic is unchanged and remains the same.
127+
// --- Only the CSS has been updated.
128+
101129
// --- DOM Elements ---
102130
const gameWrapper = document.getElementById('game-wrapper');
103131
const statusDisplay = document.querySelector('.status');
@@ -181,7 +209,6 @@ <h3>Ultimate Tic-Tac-Toe Rules</h3>
181209
}
182210
gameWrapper.appendChild(board);
183211

184-
// AI's last move in the initial game determines the next active board
185212
activeBoardIndex = initialAiLastMove;
186213
updateActiveBoardHighlights();
187214
}
@@ -193,36 +220,18 @@ <h3>Ultimate Tic-Tac-Toe Rules</h3>
193220
if (initialBoardState[index] !== '') return;
194221

195222
makeMove(index, HUMAN, initialBoardState);
196-
if (checkWinner(initialBoardState, HUMAN)) { endGame(true); return; }
223+
if (checkWinner(initialBoardState, HUMAN)) { endGame(true); return; } // Should be impossible
197224
if (initialBoardState.every(c => c !== '')) { endGame(true); return; }
198225

199226
gameActive = false;
200227
statusDisplay.textContent = 'AI is thinking...';
201228
setTimeout(initialAiTurn, 700);
202229
}
203230

204-
function handleUltimateClick(e) { /* ... same as before ... */ }
205231
restartButton.addEventListener('click', () => initGame(isUltimateMode));
206232
rulesButton.addEventListener('click', () => rulesModal.classList.add('visible'));
207233
closeRulesButton.addEventListener('click', () => rulesModal.classList.remove('visible'));
208234

209-
// --- Game Logic ---
210-
function makeMove(index, player, board, boardIndex = null) { /* ... same as before ... */ }
211-
212-
function endGame(isInitialGame) {
213-
gameActive = false;
214-
if (isInitialGame) {
215-
statusDisplay.textContent = "A worthy effort... but inevitable.";
216-
setTimeout(() => {
217-
statusDisplay.textContent = "Let's play for real.";
218-
isUltimateMode = true;
219-
initGame(true); // Re-initialize in ultimate mode
220-
}, 2500);
221-
} else {
222-
// ... Ultimate game end logic ...
223-
}
224-
}
225-
226235
let initialAiLastMove;
227236
function initialAiTurn() {
228237
let bestScore = -Infinity, move;
@@ -234,7 +243,7 @@ <h3>Ultimate Tic-Tac-Toe Rules</h3>
234243
if (score > bestScore) { bestScore = score; move = i; }
235244
}
236245
}
237-
initialAiLastMove = move; // Store the AI's move
246+
initialAiLastMove = move;
238247
makeMove(move, AI, initialBoardState);
239248
if (checkWinner(initialBoardState, AI) || initialBoardState.every(c => c !== '')) {
240249
endGame(true);
@@ -245,17 +254,22 @@ <h3>Ultimate Tic-Tac-Toe Rules</h3>
245254
statusDisplay.textContent = `Your Turn (${HUMAN})`;
246255
}
247256

248-
function minimax(board, isMaximizing) { /* ... same as before ... */ }
249-
function checkWinner(board, player) { /* ... same as before ... */ }
250-
251-
// Placeholder functions for Ultimate Mode to be filled in
252-
function handleUltimateClick(e) { console.log('Ultimate move'); }
253-
254-
// --- Start ---
255-
initGame(false);
256-
257+
function minimax(board, isMaximizing) {
258+
if (checkWinner(board, HUMAN)) return -1;
259+
if (checkWinner(board, AI)) return 1;
260+
if (board.every(c => c !== '')) return 0;
257261

258-
// ---- Full Ultimate Logic (re-added for completeness) ----
262+
if (isMaximizing) {
263+
let bestScore = -Infinity;
264+
for(let i=0; i<9; i++) { if(board[i]==='') { board[i]=AI; bestScore = Math.max(bestScore, minimax(board,false)); board[i]=''; }}
265+
return bestScore;
266+
} else {
267+
let bestScore = Infinity;
268+
for(let i=0; i<9; i++) { if(board[i]==='') { board[i]=HUMAN; bestScore = Math.min(bestScore, minimax(board,true)); board[i]=''; }}
269+
return bestScore;
270+
}
271+
}
272+
259273
function handleUltimateClick(e) {
260274
if (!gameActive) return;
261275
const { boardIndex, cellIndex } = e.target.dataset;
@@ -308,8 +322,19 @@ <h3>Ultimate Tic-Tac-Toe Rules</h3>
308322
}
309323

310324
function checkUltimateEnd(lastCellIndex, player) {
311-
const boardIndex = activeBoardIndex; // The board that was just played on
312-
if (mainBoardState[boardIndex] === '' && checkWinner(localBoards[boardIndex], player)) {
325+
const boardIndex = activeBoardIndex; // This should be the board that was just played on.
326+
if (!boardIndex && boardIndex !== 0) { // This handles initial free moves
327+
const currentBoard = localBoards.find((_,i)=> document.querySelector(`[data-board-index='${i}'][data-cell-index='${lastCellIndex}']`))
328+
const bIndex = localBoards.indexOf(currentBoard)
329+
if (mainBoardState[bIndex] === '' && checkWinner(localBoards[bIndex], player)) {
330+
mainBoardState[bIndex] = player;
331+
const localBoardEl = gameWrapper.querySelector(`[data-board-index='${bIndex}']`);
332+
const overlay = document.createElement('div');
333+
overlay.className = `winner-overlay ${player.toLowerCase()}`;
334+
overlay.textContent = player;
335+
localBoardEl.appendChild(overlay);
336+
}
337+
} else if (mainBoardState[boardIndex] === '' && checkWinner(localBoards[boardIndex], player)) {
313338
mainBoardState[boardIndex] = player;
314339
const localBoardEl = gameWrapper.querySelector(`[data-board-index='${boardIndex}']`);
315340
const overlay = document.createElement('div');
@@ -330,16 +355,18 @@ <h3>Ultimate Tic-Tac-Toe Rules</h3>
330355
function findBestUltimateMove() {
331356
const validMoves = getValidMoves();
332357
if (validMoves.length === 0) return null;
333-
// Heuristic AI logic here... (Simplified for now)
358+
// Simple heuristic: returns a random valid move for now
334359
return validMoves[Math.floor(Math.random() * validMoves.length)];
335360
}
336361

337362
function getValidMoves() {
338363
const moves = [];
339364
const targetBoards = (activeBoardIndex === null) ? [0,1,2,3,4,5,6,7,8].filter(i => mainBoardState[i] === '') : [activeBoardIndex];
340365
for (const bIndex of targetBoards) {
341-
for(let cIndex=0; cIndex<9; cIndex++) {
342-
if(localBoards[bIndex][cIndex] === '') moves.push({boardIndex: bIndex, cellIndex: cIndex});
366+
if(mainBoardState[bIndex] === '') {
367+
for(let cIndex=0; cIndex<9; cIndex++) {
368+
if(localBoards[bIndex][cIndex] === '') moves.push({boardIndex: bIndex, cellIndex: cIndex});
369+
}
343370
}
344371
}
345372
return moves;

0 commit comments

Comments
 (0)