-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchess.js
31 lines (27 loc) · 896 Bytes
/
chess.js
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
let gameInstance;
let uiInstance;
function togglePause() {
if (gameInstance) {
const isPaused = gameInstance.togglePause();
uiInstance.updatePauseButton(isPaused);
}
}
function changeTimeControl() {
if (gameInstance) {
const timeControl = document.getElementById('timeControl');
const [minutes, increment] = timeControl.value.split('+').map(Number);
gameInstance.changeTimeControl(minutes, increment);
}
}
document.addEventListener('DOMContentLoaded', () => {
try {
console.log('Initializing chess game...');
gameInstance = new ChessGame();
uiInstance = new ChessUI(gameInstance);
// Initialize game
uiInstance.updateDisplay();
console.log('Chess game initialized successfully');
} catch (error) {
console.error('Error initializing chess game:', error);
}
});