Compare commits
No commits in common. "e4af7d3e53ea4dc0ced0afe9043f814c48b2bae6" and "bf6d8615ab09773906517941223dc2981560ba60" have entirely different histories.
e4af7d3e53
...
bf6d8615ab
@ -105,8 +105,7 @@ export class GameController {
|
|||||||
captured = SpecialMoves.executeEnPassant(this.board, piece, toRow, toCol);
|
captured = SpecialMoves.executeEnPassant(this.board, piece, toRow, toCol);
|
||||||
} else {
|
} else {
|
||||||
// Normal move
|
// Normal move
|
||||||
const moveResult = this.board.movePiece(fromRow, fromCol, toRow, toCol);
|
captured = this.board.movePiece(fromRow, fromCol, toRow, toCol);
|
||||||
captured = moveResult.captured;
|
|
||||||
|
|
||||||
// Check for promotion
|
// Check for promotion
|
||||||
if (specialMoveType === 'promotion' || (piece.type === 'pawn' && piece.canPromote())) {
|
if (specialMoveType === 'promotion' || (piece.type === 'pawn' && piece.canPromote())) {
|
||||||
|
|||||||
48
js/main.js
48
js/main.js
@ -84,13 +84,10 @@ class ChessApp {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Offer Draw
|
// Offer Draw
|
||||||
const offerDrawBtn = document.getElementById('btn-offer-draw');
|
document.getElementById('btn-offer-draw').addEventListener('click', () => {
|
||||||
if (offerDrawBtn) {
|
this.game.offerDraw();
|
||||||
offerDrawBtn.addEventListener('click', () => {
|
this.showMessage('Draw offered to opponent');
|
||||||
this.game.offerDraw();
|
});
|
||||||
this.showMessage('Draw offered to opponent');
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// Resign
|
// Resign
|
||||||
document.getElementById('btn-resign').addEventListener('click', () => {
|
document.getElementById('btn-resign').addEventListener('click', () => {
|
||||||
@ -175,13 +172,9 @@ class ChessApp {
|
|||||||
* Update turn indicator
|
* Update turn indicator
|
||||||
*/
|
*/
|
||||||
updateTurnIndicator() {
|
updateTurnIndicator() {
|
||||||
const indicator = document.getElementById('current-turn');
|
const indicator = document.getElementById('turn-indicator');
|
||||||
if (!indicator) {
|
|
||||||
console.error('Turn indicator element not found');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const turn = this.game.currentTurn;
|
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';
|
indicator.style.color = turn === 'white' ? '#ffffff' : '#333333';
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -189,7 +182,7 @@ class ChessApp {
|
|||||||
* Update move history display
|
* Update move history display
|
||||||
*/
|
*/
|
||||||
updateMoveHistory() {
|
updateMoveHistory() {
|
||||||
const moveList = document.getElementById('move-history');
|
const moveList = document.getElementById('move-list');
|
||||||
const history = this.game.gameState.moveHistory;
|
const history = this.game.gameState.moveHistory;
|
||||||
|
|
||||||
if (history.length === 0) {
|
if (history.length === 0) {
|
||||||
@ -218,19 +211,17 @@ class ChessApp {
|
|||||||
* Update captured pieces display
|
* Update captured pieces display
|
||||||
*/
|
*/
|
||||||
updateCapturedPieces() {
|
updateCapturedPieces() {
|
||||||
const whiteCaptured = document.getElementById('captured-white-pieces');
|
const whiteCaptured = document.getElementById('white-captured');
|
||||||
const blackCaptured = document.getElementById('captured-black-pieces');
|
const blackCaptured = document.getElementById('black-captured');
|
||||||
|
|
||||||
const captured = this.game.gameState.capturedPieces;
|
const captured = this.game.gameState.capturedPieces;
|
||||||
|
|
||||||
// "Captured by Black" shows white pieces that black captured
|
whiteCaptured.innerHTML = captured.black.map(piece =>
|
||||||
whiteCaptured.innerHTML = captured.white.map(piece =>
|
`<span class="captured-piece black">${piece.getSymbol()}</span>`
|
||||||
`<span class="captured-piece white">${piece.getSymbol()}</span>`
|
|
||||||
).join('') || '-';
|
).join('') || '-';
|
||||||
|
|
||||||
// "Captured by White" shows black pieces that white captured
|
blackCaptured.innerHTML = captured.white.map(piece =>
|
||||||
blackCaptured.innerHTML = captured.black.map(piece =>
|
`<span class="captured-piece white">${piece.getSymbol()}</span>`
|
||||||
`<span class="captured-piece black">${piece.getSymbol()}</span>`
|
|
||||||
).join('') || '-';
|
).join('') || '-';
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -241,10 +232,6 @@ class ChessApp {
|
|||||||
*/
|
*/
|
||||||
showMessage(message, type = 'info') {
|
showMessage(message, type = 'info') {
|
||||||
const statusMessage = document.getElementById('status-message');
|
const statusMessage = document.getElementById('status-message');
|
||||||
if (!statusMessage) {
|
|
||||||
console.warn('Status message element not found, using console:', message);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
statusMessage.textContent = message;
|
statusMessage.textContent = message;
|
||||||
statusMessage.style.display = 'block';
|
statusMessage.style.display = 'block';
|
||||||
|
|
||||||
@ -263,14 +250,7 @@ class ChessApp {
|
|||||||
const overlay = document.getElementById('promotion-overlay');
|
const overlay = document.getElementById('promotion-overlay');
|
||||||
const dialog = document.getElementById('promotion-dialog');
|
const dialog = document.getElementById('promotion-dialog');
|
||||||
|
|
||||||
if (!dialog) {
|
overlay.style.display = 'block';
|
||||||
console.error('Promotion dialog not found');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (overlay) {
|
|
||||||
overlay.style.display = 'block';
|
|
||||||
}
|
|
||||||
dialog.style.display = 'block';
|
dialog.style.display = 'block';
|
||||||
|
|
||||||
// Update symbols for current color
|
// Update symbols for current color
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user