diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index f6962a5..069328e 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -13,6 +13,16 @@
+ + + KK +
+ + Kunal Katiyar + +
+
+ diff --git a/index.html b/index.html index 5fc16a2..34e3bec 100644 --- a/index.html +++ b/index.html @@ -27,7 +27,7 @@

time:0

rengoku card cover -
+
mask card cover diff --git a/index.js b/index.js index a517b78..f7f6052 100644 --- a/index.js +++ b/index.js @@ -3,16 +3,44 @@ const cards = document.querySelectorAll('.memory-card') const restartBtn = document.querySelector('#restart-btn') const timer = document.querySelector('#timer') let counter = 0; +let memoryCounter = 5; -//increasing the counter +// For modifying cards +const makeCardsClickable = setTimeout(function(){ + cards.forEach(card=>{ + card.addEventListener('click',flipCard); // Makes cards clickable after the timer expires + card.children[1].style.display="block"; // Hides them after the timer expires + }) +},memoryCounter*1000); + +// For timing the counters const interval = setInterval(function(){ - counter++; - console.log() - timer.innerHTML = "" + counter + ""; + if(memoryCounter>0){ // Makes a check on memoryCounter and stops after 5 secs + memoryCounter--; + viewAllCards(); + timer.innerHTML = "" + memoryCounter + ""; // Changes inner HTML + } + else{ // Counter for timing the game + counter++; // This counter is set to motion only when the game starts i.e when memoryCounter expires + timer.innerHTML = "" + counter + ""; // Changes inner HTML + } }, 1000); + +// To view all cards +function viewAllCards(){ + // Cards are made viewable when memoryCounter is greater than 0 + if(memoryCounter>0){ + cards.forEach(card=>{ + card.children[1].style.display="none"; + }) + } +} + + +// When the game restarts all cards are made visible for 5secs function restartGame(){ - window.location.reload() + window.location.reload(); } const flippedCards = [] @@ -59,9 +87,3 @@ function flipCard(e){ setTimeout(checkForMatch,0); } } - -cards.forEach(card=>{ - card.addEventListener('click',flipCard); -}) - -