My memory game is almost complete, it has one last error to fix. Timer stops and returns to zero after the game is complete and a modal box appears to congratulate the player with total time and stars scored. However, while in this state, clicking somewhere in the deck (colored with linear-gradient property) causes it to start back again. Normally, it shouldn't start until the player has restarted the game and clicked on one of the closed cards.
How can I prevent it in a way so that after the modal box kicks in, clicking anywhere on the screen will NOT cause the timer to start?
Here is my project. If you finish and click someplace on the deck you'll see the timer starting even though the game is finished. I want to prevent that from happening.
https://codepen.io/Caysle/pen/aYYKRp
Here is the bit that collects all the progress you've made in the game:
//Collect cards to check if all are open and match:
let matchingCards = document.getElementsByClassName('card match open show');
if (matchingCards.length == 16) {
setTimeout (function() {document.querySelector(".winPage").className =
"winPage"}, 1000);
stopTimer = true;
}
}