Skip to content

Commit

Permalink
Bug fixes
Browse files Browse the repository at this point in the history
- Bug 1: After computer's turn, if the roll button is clicked too quicly
  when the turn score is still visible then the turn score stays at 0
- Bug 2: When user wins, the computer plays automatically after the
  alert box is closed
  • Loading branch information
an4s911 committed Jul 26, 2023
1 parent ee012e9 commit d1387c9
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions script.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,10 @@ const currentTurn = {
this.player = computer;
emulateComputerTurn();
} else {
rollBtn.removeAttribute("disabled");
turnOverBtn.removeAttribute("disabled");
setTimeout(() => {
rollBtn.removeAttribute("disabled");
turnOverBtn.removeAttribute("disabled");
}, 400);
this.player = user;
}
turnPronounElement.textContent = this.currentPlayer.pronoun;
Expand All @@ -77,13 +79,13 @@ function turnOver() {
currentTurn.player.score += currentTurn.score;
setTimeout(() => {
currentTurn.score = 0;
}, 800);
}, 400);

if (currentTurn.player.score >= winningScore) {
playerWins(currentTurn.player);
} else {
currentTurn.switchPlayer();
}

currentTurn.switchPlayer();
}

function rollAndValidate() {
Expand Down

0 comments on commit d1387c9

Please sign in to comment.