Skip to content

Commit

Permalink
Merge branch 'main' of github.com:hu8813/pong42
Browse files Browse the repository at this point in the history
  • Loading branch information
hu8813 committed Apr 24, 2024
2 parents 4fac0b0 + 5244c18 commit b39e94b
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 b39e94b

Please sign in to comment.