mirror of
https://codeberg.org/JasterV/MEMORY-CARD-GAME.git
synced 2026-04-26 18:20:03 +00:00
⚽️🌆 Checkpoint
./script.js:18108132/17543:18108380/780 ./style.css:18108127/255
This commit is contained in:
parent
b5fc6f9e39
commit
7f8c980ab3
2 changed files with 38 additions and 17 deletions
37
script.js
37
script.js
|
|
@ -72,7 +72,7 @@ imgDivArray.forEach(targetCard => {
|
|||
tries++;
|
||||
if (areEqualCards(targetCard, lastCard)) {
|
||||
discoveredCards.push(targetCard);
|
||||
|
||||
|
||||
if (isGameEnd(discoveredCards, imgDivArray)) {
|
||||
setTimeout(() => {
|
||||
winGame(currentUser);
|
||||
|
|
@ -98,25 +98,17 @@ playBtn.addEventListener("click", goToModePage);
|
|||
document.addEventListener("keydown", event => {
|
||||
if (!chooseUserDiv.classList.contains("hide") && event.which === 13) {
|
||||
goToModePage();
|
||||
} else if((!looseDiv.classList.contains("hide") || !congratsDiv.classList.contains("hide")) && event.which === 13){
|
||||
|
||||
} else if (
|
||||
(!looseDiv.classList.contains("hide") ||
|
||||
!congratsDiv.classList.contains("hide")) &&
|
||||
event.which === 13
|
||||
) {
|
||||
playAgain();
|
||||
}
|
||||
});
|
||||
|
||||
for (let btn of playAgainBtns) {
|
||||
btn.addEventListener("click", e => {
|
||||
currentUser = "";
|
||||
discoveredCards = [];
|
||||
tries = 0;
|
||||
unFlipCards(imgDivArray);
|
||||
if(e.which === 13){
|
||||
|
||||
} else {
|
||||
e.target.parentElement.classList.add("hide");
|
||||
}
|
||||
chooseUserDiv.classList.remove("hide");
|
||||
document.getElementById("username").value = "";
|
||||
});
|
||||
btn.addEventListener("click", playAgain);
|
||||
}
|
||||
|
||||
easyBtn.addEventListener("click", () => {
|
||||
|
|
@ -204,6 +196,19 @@ function goToModePage() {
|
|||
}
|
||||
}
|
||||
|
||||
function playAgain() {
|
||||
currentUser = "";
|
||||
discoveredCards = [];
|
||||
tries = 0;
|
||||
unFlipCards(imgDivArray);
|
||||
|
||||
looseDiv.classList.add("hide");
|
||||
congratsDiv.classList.add("hide");
|
||||
|
||||
chooseUserDiv.classList.remove("hide");
|
||||
document.getElementById("username").value = "";
|
||||
}
|
||||
|
||||
function startGame(username) {
|
||||
startTime = Date.now();
|
||||
scoresController.createPlayingUser(username);
|
||||
|
|
|
|||
18
style.css
18
style.css
|
|
@ -356,6 +356,22 @@ strong {
|
|||
|
||||
@media (max-width: 500px) {
|
||||
body {
|
||||
padding: 0;
|
||||
padding: 90px 0;
|
||||
}
|
||||
|
||||
.cards-row {
|
||||
height: 100%;
|
||||
margin-top: 0;
|
||||
}
|
||||
|
||||
.score-container {
|
||||
max-height: 96px;
|
||||
min-height: auto;
|
||||
}
|
||||
|
||||
.fa-trophy {
|
||||
font-size: 18vh;
|
||||
left: 53px;
|
||||
top: -22px;
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue