Skip to content

Commit

Permalink
Update tournament.js
Browse files Browse the repository at this point in the history
  • Loading branch information
EhabElasam authored Apr 24, 2024
1 parent b6cc1ba commit 5244c18
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions srcs/frontend/js/tournament.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}`);
Expand All @@ -53,8 +57,6 @@ function startTournament(playerCount) {
showTournament(players, playerCount);
}



function showTournament(players, playerCount) {
const canvas = document.getElementById('canvastour');
if (!canvas) return;
Expand Down

0 comments on commit 5244c18

Please sign in to comment.