🌆 Checkpoint

./script.js:18108132/17543:18108380/780
./style.css:18108127/255
This commit is contained in:
Glitch (hello-webpage) 2020-07-30 09:06:03 +00:00
parent b5fc6f9e39
commit 7f8c980ab3
2 changed files with 38 additions and 17 deletions

View file

@ -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);

View file

@ -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;
}
}