diff --git a/srcs/frontend/js/tournament.js b/srcs/frontend/js/tournament.js index 6f0755f..dc4af49 100644 --- a/srcs/frontend/js/tournament.js +++ b/srcs/frontend/js/tournament.js @@ -39,12 +39,16 @@ function askPlayerCount() { }); } - function startTournament(playerCount) { console.log(`Tournament with ${playerCount} players is starting.`); const players = []; for (let i = 1; i <= playerCount; i++) { let playerName = prompt(`Enter name for Player ${i}:`); + if (playerName === null) { + window.location.reload(); + return; + } + if (playerName) playerName = playerName.replace(/[^a-z0-9]/gi, '').substring(0, 7); players.push(playerName || `X ${i}`); @@ -53,8 +57,6 @@ function startTournament(playerCount) { showTournament(players, playerCount); } - - function showTournament(players, playerCount) { const canvas = document.getElementById('canvastour'); if (!canvas) return;