Skip to content

Commit

Permalink
Chime's Commit #11
Browse files Browse the repository at this point in the history
- Hopefully fixed ready queue where name doesn't show up when pressing "Join Queue" button
  • Loading branch information
Chime-txt committed Apr 30, 2024
1 parent 55f88af commit f0ee2a7
Showing 1 changed file with 16 additions and 14 deletions.
30 changes: 16 additions & 14 deletions html/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -351,28 +351,30 @@ <h2> Player 2 Name</h2>
}
*/
function readyqueue() {
var playerDoesExist = 0;
var playerExistInQueue = 0;
const playerName = document.getElementById("playerName").value.trim(); // Get the player's name from the input field
for(i = 0; i <= playerNames.length; i++) {
if ((playerName!=playerNames[i]) && (i == playerNames.length)) {
const playerQueue = document.getElementById('playerQueue');
const li = document.createElement('li');
li.textContent = playerName; // Use the player's name obtained from the input field
li.style.fontSize = "20px";
playerQueue.appendChild(li);
playerDoesExist = 1;
break;
} else if (playerName==playerNames[i]) {
console.error('Player name already in the ready queue.');
playerDoesExist = 1;
if (playerName!=playerNames[i]) {
playerExistInQueue = 1;
break;
}
}

if (!playerDoesExist){
if (playerExistInQueue){
/* Player exists and is in queue. */
console.error('Player name already in the ready queue.');
} else {
console.error('Player name not found.');
/* Player doesn't exists, check if name is found. */
if (playerName) {
const playerQueue = document.getElementById('playerQueue');
const li = document.createElement('li');
li.textContent = playerName; // Use the player's name obtained from the input field
li.style.fontSize = "20px";
playerQueue.appendChild(li);
} else {
/* Player doesn't exists, and name is not found. */
console.error('Player name not found.');
}
}


Expand Down

0 comments on commit f0ee2a7

Please sign in to comment.