Raven7 commited on
Commit
088cfa5
Β·
verified Β·
1 Parent(s): 2483475

Update index.html

Browse files
Files changed (1) hide show
  1. index.html +48 -35
index.html CHANGED
@@ -154,28 +154,12 @@
154
  cursor: grabbing;
155
  }
156
 
157
- .coordinates {
158
- position: absolute;
159
- font-size: 0.8rem;
160
- color: #95a5a6;
161
- }
162
-
163
- .file {
164
- bottom: -1.5rem;
165
- left: calc(var(--square-size) * 0.5);
166
- }
167
-
168
- .rank {
169
- left: -1.5rem;
170
- top: calc(var(--square-size) * 0.5);
171
- }
172
-
173
  @media (max-width: 1024px) {
174
  .container {
175
  grid-template-columns: 1fr;
176
  grid-template-rows: auto auto;
177
  }
178
-
179
  .board-container {
180
  margin: auto;
181
  }
@@ -186,13 +170,12 @@
186
  <div class="container">
187
  <div class="board-container">
188
  <div class="chessboard" id="board"></div>
189
- <div class="coordinates" id="coordinates"></div>
190
  </div>
191
  <div class="controls">
192
  <div class="status-panel">
193
  <h3>Position Analysis</h3>
194
  <p id="status">White to move</p>
195
- <p id="evaluation">Evaluation: 0.0</p>
196
  </div>
197
  <div class="move-list" id="moveList">
198
  <!-- Moves will be inserted here -->
@@ -209,6 +192,18 @@
209
  this.currentPlayer = 'white';
210
  this.selectedPiece = null;
211
  this.moveHistory = [];
 
 
 
 
 
 
 
 
 
 
 
 
212
  this.initializeBoard();
213
  }
214
 
@@ -217,7 +212,7 @@
217
  ['β™œ', 'β™ž', '♝', 'β™›', 'β™š', '♝', 'β™ž', 'β™œ'],
218
  ['β™Ÿ', 'β™Ÿ', 'β™Ÿ', 'β™Ÿ', 'β™Ÿ', 'β™Ÿ', 'β™Ÿ', 'β™Ÿ'],
219
  [null, null, null, null, null, null, null, null],
220
- [null, null, null, null, null, null, null, null],
221
  [null, null, null, null, null, null, null, null],
222
  [null, null, null, null, null, null, null, null],
223
  ['β™™', 'β™™', 'β™™', 'β™™', 'β™™', 'β™™', 'β™™', 'β™™'],
@@ -225,6 +220,7 @@
225
  ];
226
  }
227
 
 
228
  initializeBoard() {
229
  const boardElement = document.getElementById('board');
230
  boardElement.innerHTML = '';
@@ -251,6 +247,7 @@
251
  this.updateStatus();
252
  }
253
 
 
254
  handleSquareClick(event) {
255
  const square = event.target.closest('.square');
256
  const row = parseInt(square.dataset.row);
@@ -263,11 +260,11 @@
263
  }
264
  }
265
 
 
266
  selectPiece(row, col) {
267
  const piece = this.board[row][col];
268
  if (!piece) return;
269
 
270
- // Remove previous selection
271
  document.querySelectorAll('.square').forEach(sq => {
272
  sq.classList.remove('selected');
273
  sq.classList.remove('valid-move');
@@ -276,10 +273,10 @@
276
  document.querySelector(`[data-row="${row}"][data-col="${col}"]`).classList.add('selected');
277
  this.selectedPiece = { row, col };
278
 
279
- // Show valid moves
280
  this.showValidMoves(row, col);
281
  }
282
 
 
283
  tryMove(toRow, toCol) {
284
  if (this.isValidMove(this.selectedPiece.row, this.selectedPiece.col, toRow, toCol)) {
285
  this.makeMove(this.selectedPiece.row, this.selectedPiece.col, toRow, toCol);
@@ -293,11 +290,14 @@
293
  this.selectedPiece = null;
294
  }
295
 
 
296
  isValidMove(fromRow, fromCol, toRow, toCol) {
297
- // Basic move validation - can be expanded
298
- return true;
 
299
  }
300
 
 
301
  makeMove(fromRow, fromCol, toRow, toCol) {
302
  const piece = this.board[fromRow][fromCol];
303
  this.board[fromRow][fromCol] = null;
@@ -314,23 +314,36 @@
314
  this.updateMoveList();
315
  }
316
 
 
317
  showValidMoves(row, col) {
318
- // Simplified valid moves - can be expanded
319
- for (let i = 0; i < 8; i++) {
320
- for (let j = 0; j < 8; j++) {
321
- if (this.isValidMove(row, col, i, j)) {
322
- document.querySelector(`[data-row="${i}"][data-col="${j}"]`)
323
- .classList.add('valid-move');
324
- }
325
- }
326
- }
 
 
 
 
 
 
 
 
 
327
  }
328
 
 
329
  updateStatus() {
330
- document.getElementById('status').textContent = `${this.currentPlayer.charAt(0).toUpperCase() +
 
331
  this.currentPlayer.slice(1)} to move`;
332
  }
333
 
 
334
  updateMoveList() {
335
  const moveList = document.getElementById('moveList');
336
  moveList.innerHTML = '';
@@ -359,6 +372,7 @@
359
  moveList.scrollTop = moveList.scrollHeight;
360
  }
361
 
 
362
  formatMove(move) {
363
  const files = 'abcdefgh';
364
  const ranks = '87654321';
@@ -369,7 +383,6 @@
369
  const game = new ChessGame();
370
 
371
  function analyzePosition() {
372
- // Simulated analysis
373
  const eval = (Math.random() * 2 - 1).toFixed(2);
374
  document.getElementById('evaluation').textContent = `Evaluation: ${eval}`;
375
  }
 
154
  cursor: grabbing;
155
  }
156
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
157
  @media (max-width: 1024px) {
158
  .container {
159
  grid-template-columns: 1fr;
160
  grid-template-rows: auto auto;
161
  }
162
+
163
  .board-container {
164
  margin: auto;
165
  }
 
170
  <div class="container">
171
  <div class="board-container">
172
  <div class="chessboard" id="board"></div>
 
173
  </div>
174
  <div class="controls">
175
  <div class="status-panel">
176
  <h3>Position Analysis</h3>
177
  <p id="status">White to move</p>
178
+ <p id="evaluation">Evaluation: 0.0</p>
179
  </div>
180
  <div class="move-list" id="moveList">
181
  <!-- Moves will be inserted here -->
 
192
  this.currentPlayer = 'white';
193
  this.selectedPiece = null;
194
  this.moveHistory = [];
195
+ this.validMoves = [
196
+ {type: 'K', move: {dx: [-1,0,1], dy: [-1,0,1]}},
197
+ {type: 'Q', move: {dx: [-7,-6,-5,-4,-3,-2,-1,0,1,2,3,4,5,6,7],
198
+ dy: [-7,-6,-5,-4,-3,-2,-1,0,1,2,3,4,5,6,7]}},
199
+ {type: 'R', move: {dx: [-7,-6,-5,-4,-3,-2,-1,0,1,2,3,4,5,6,7],
200
+ dy: [0]}},
201
+ {type: 'B', move: {dx: [-7,-6,-5,-4,-3,-2,-1,1,2,3,4,5,6,7],
202
+ dy: [-7,-6,-5,-4,-3,-2,-1,1,2,3,4,5,6,7]}},
203
+ {type: 'N', move: {dx: [-2,-2,-1,-1,1,1,2,2],
204
+ dy: [-1,1,-2,2,-2,2,-1,1]}},
205
+ {type: 'P', move: {dx: [0], dy: [-1,1]}}
206
+ ];
207
  this.initializeBoard();
208
  }
209
 
 
212
  ['β™œ', 'β™ž', '♝', 'β™›', 'β™š', '♝', 'β™ž', 'β™œ'],
213
  ['β™Ÿ', 'β™Ÿ', 'β™Ÿ', 'β™Ÿ', 'β™Ÿ', 'β™Ÿ', 'β™Ÿ', 'β™Ÿ'],
214
  [null, null, null, null, null, null, null, null],
215
+ [null, null, null, null, null, null, null, null],
216
  [null, null, null, null, null, null, null, null],
217
  [null, null, null, null, null, null, null, null],
218
  ['β™™', 'β™™', 'β™™', 'β™™', 'β™™', 'β™™', 'β™™', 'β™™'],
 
220
  ];
221
  }
222
 
223
+ // Initialize the board display
224
  initializeBoard() {
225
  const boardElement = document.getElementById('board');
226
  boardElement.innerHTML = '';
 
247
  this.updateStatus();
248
  }
249
 
250
+ // Handle square clicks
251
  handleSquareClick(event) {
252
  const square = event.target.closest('.square');
253
  const row = parseInt(square.dataset.row);
 
260
  }
261
  }
262
 
263
+ // Select a piece to move
264
  selectPiece(row, col) {
265
  const piece = this.board[row][col];
266
  if (!piece) return;
267
 
 
268
  document.querySelectorAll('.square').forEach(sq => {
269
  sq.classList.remove('selected');
270
  sq.classList.remove('valid-move');
 
273
  document.querySelector(`[data-row="${row}"][data-col="${col}"]`).classList.add('selected');
274
  this.selectedPiece = { row, col };
275
 
 
276
  this.showValidMoves(row, col);
277
  }
278
 
279
+ // Try to make a move
280
  tryMove(toRow, toCol) {
281
  if (this.isValidMove(this.selectedPiece.row, this.selectedPiece.col, toRow, toCol)) {
282
  this.makeMove(this.selectedPiece.row, this.selectedPiece.col, toRow, toCol);
 
290
  this.selectedPiece = null;
291
  }
292
 
293
+ // Check if move is valid
294
  isValidMove(fromRow, fromCol, toRow, toCol) {
295
+ // Simplified validation
296
+ const piece = this.board[fromRow][fromCol];
297
+ return piece !== null;
298
  }
299
 
300
+ // Execute a move
301
  makeMove(fromRow, fromCol, toRow, toCol) {
302
  const piece = this.board[fromRow][fromCol];
303
  this.board[fromRow][fromCol] = null;
 
314
  this.updateMoveList();
315
  }
316
 
317
+ // Show valid moves for selected piece
318
  showValidMoves(row, col) {
319
+ const piece = this.board[row][col];
320
+ const moves = this.getValidMoves(piece, row, col);
321
+
322
+ moves.forEach(move => {
323
+ const square = document.querySelector(
324
+ `[data-row="${move.row}"][data-col="${move.col}"]`
325
+ );
326
+ if (square) square.classList.add('valid-move');
327
+ });
328
+ }
329
+
330
+ // Get valid moves for a piece
331
+ getValidMoves(piece, row, col) {
332
+ // Simplified move generation
333
+ return [{row: row + 1, col}, {row: row - 1, col},
334
+ {row, col: col + 1}, {row, col: col - 1}]
335
+ .filter(pos => pos.row >= 0 && pos.row < 8 &&
336
+ pos.col >= 0 && pos.col < 8);
337
  }
338
 
339
+ // Update game status display
340
  updateStatus() {
341
+ document.getElementById('status').textContent =
342
+ `${this.currentPlayer.charAt(0).toUpperCase() +
343
  this.currentPlayer.slice(1)} to move`;
344
  }
345
 
346
+ // Update move list display
347
  updateMoveList() {
348
  const moveList = document.getElementById('moveList');
349
  moveList.innerHTML = '';
 
372
  moveList.scrollTop = moveList.scrollHeight;
373
  }
374
 
375
+ // Format move for display
376
  formatMove(move) {
377
  const files = 'abcdefgh';
378
  const ranks = '87654321';
 
383
  const game = new ChessGame();
384
 
385
  function analyzePosition() {
 
386
  const eval = (Math.random() * 2 - 1).toFixed(2);
387
  document.getElementById('evaluation').textContent = `Evaluation: ${eval}`;
388
  }