tournament working but still some problems

This commit is contained in:
CHIBOUB Chakib
2024-09-02 23:24:42 +02:00
parent fecc91447b
commit 878cf92bbb
9 changed files with 123 additions and 262 deletions

View File

@@ -388,32 +388,31 @@ document.addEventListener('DOMContentLoaded', () => {
} else if (data.type === 'game_state_update') {
updateGameState(data.game_state);
} else if (data.type === 'player_disconnected') {
console.log("Player disconnected:", data.player);
console.log('Player disconnected:', data.player);
} else if (data.type === 'game_ended') {
console.log("Game ended:", data.game_id);
console.log('Game ended:', data.game_id);
} else if (data.type === 'error') {
console.error(data.message);
// Assuming you're inside some WebSocket message handling function
} else if (data.type === 'update_tournament_waiting_room') {
// Update the HTML content of the tournament bracket
document.getElementById('tournament-bracket').innerHTML = data.html;
// Reattach the event listener to the "Start Tournament" button
const startButton = document.getElementById('start-tournament-btn');
if (startButton) {
startButton.addEventListener('click', function() {
if (typeof socket !== 'undefined' && socket.readyState === WebSocket.OPEN) {
console.log("Start TOURNAMENT sent..");
console.log('Start TOURNAMENT sent..');
socket.send(JSON.stringify({type: 'start_tournament'}));
} else {
console.error("WebSocket is not open or undefined");
console.error('WebSocket is not open or undefined');
}
});
} else {
console.error('Start button not found');
}
} else if (data.type === 'update_brackets') {
// Update the HTML content of the tournament bracket
document.getElementById('tournament-bracket').innerHTML = data.html;
} else if (data.type === 'tournament_end') {
console.log('Tournament ended, the winner is:', data.winner);
} else {
console.log('Message from server:', data.type, data.message);
}
@@ -443,7 +442,7 @@ document.addEventListener('DOMContentLoaded', () => {
function updateGameState(newState) {
gameState = newState;
renderGame();
checkForWinner();
//checkForWinner();
}
function renderGame() {

View File

@@ -279,7 +279,6 @@ button:hover {
color: #ffffff;
}
.dropdown-content {
display: none;
position: absolute;
@@ -298,7 +297,6 @@ button:hover {
display: block;
}
.dropdown-content a {
color: #ffffff;
padding: 12px 16px;
@@ -308,7 +306,6 @@ button:hover {
transition: background-color 0.3s ease;
}
.dropdown-content a:hover {
background-color: #333;
color: #00ffff;
@@ -404,7 +401,7 @@ pre {
white-space: pre-wrap;
word-wrap: break-word;
}
/*
.tournament-waiting-room {
background-color: rgba(0, 0, 0, 0.6);
padding: 20px;
@@ -435,7 +432,7 @@ pre {
list-style-type: none;
padding: 0;
}
*/
body {
color: rgb(0, 255, 255); /* Valeur par défaut */
font-family: Arial, sans-serif;