Compare commits

..

No commits in common. "e4af7d3e53ea4dc0ced0afe9043f814c48b2bae6" and "bf6d8615ab09773906517941223dc2981560ba60" have entirely different histories.

2 changed files with 15 additions and 36 deletions

View File

@ -105,8 +105,7 @@ export class GameController {
captured = SpecialMoves.executeEnPassant(this.board, piece, toRow, toCol);
} else {
// Normal move
const moveResult = this.board.movePiece(fromRow, fromCol, toRow, toCol);
captured = moveResult.captured;
captured = this.board.movePiece(fromRow, fromCol, toRow, toCol);
// Check for promotion
if (specialMoveType === 'promotion' || (piece.type === 'pawn' && piece.canPromote())) {

View File

@ -84,13 +84,10 @@ class ChessApp {
});
// Offer Draw
const offerDrawBtn = document.getElementById('btn-offer-draw');
if (offerDrawBtn) {
offerDrawBtn.addEventListener('click', () => {
this.game.offerDraw();
this.showMessage('Draw offered to opponent');
});
}
document.getElementById('btn-offer-draw').addEventListener('click', () => {
this.game.offerDraw();
this.showMessage('Draw offered to opponent');
});
// Resign
document.getElementById('btn-resign').addEventListener('click', () => {
@ -175,13 +172,9 @@ class ChessApp {
* Update turn indicator
*/
updateTurnIndicator() {
const indicator = document.getElementById('current-turn');
if (!indicator) {
console.error('Turn indicator element not found');
return;
}
const indicator = document.getElementById('turn-indicator');
const turn = this.game.currentTurn;
indicator.textContent = `${turn.charAt(0).toUpperCase() + turn.slice(1)}'s Turn`;
indicator.textContent = `${turn.charAt(0).toUpperCase() + turn.slice(1)} to move`;
indicator.style.color = turn === 'white' ? '#ffffff' : '#333333';
}
@ -189,7 +182,7 @@ class ChessApp {
* Update move history display
*/
updateMoveHistory() {
const moveList = document.getElementById('move-history');
const moveList = document.getElementById('move-list');
const history = this.game.gameState.moveHistory;
if (history.length === 0) {
@ -218,19 +211,17 @@ class ChessApp {
* Update captured pieces display
*/
updateCapturedPieces() {
const whiteCaptured = document.getElementById('captured-white-pieces');
const blackCaptured = document.getElementById('captured-black-pieces');
const whiteCaptured = document.getElementById('white-captured');
const blackCaptured = document.getElementById('black-captured');
const captured = this.game.gameState.capturedPieces;
// "Captured by Black" shows white pieces that black captured
whiteCaptured.innerHTML = captured.white.map(piece =>
`<span class="captured-piece white">${piece.getSymbol()}</span>`
whiteCaptured.innerHTML = captured.black.map(piece =>
`<span class="captured-piece black">${piece.getSymbol()}</span>`
).join('') || '-';
// "Captured by White" shows black pieces that white captured
blackCaptured.innerHTML = captured.black.map(piece =>
`<span class="captured-piece black">${piece.getSymbol()}</span>`
blackCaptured.innerHTML = captured.white.map(piece =>
`<span class="captured-piece white">${piece.getSymbol()}</span>`
).join('') || '-';
}
@ -241,10 +232,6 @@ class ChessApp {
*/
showMessage(message, type = 'info') {
const statusMessage = document.getElementById('status-message');
if (!statusMessage) {
console.warn('Status message element not found, using console:', message);
return;
}
statusMessage.textContent = message;
statusMessage.style.display = 'block';
@ -263,14 +250,7 @@ class ChessApp {
const overlay = document.getElementById('promotion-overlay');
const dialog = document.getElementById('promotion-dialog');
if (!dialog) {
console.error('Promotion dialog not found');
return;
}
if (overlay) {
overlay.style.display = 'block';
}
overlay.style.display = 'block';
dialog.style.display = 'block';
// Update symbols for current color