diff --git a/fonts/Bangers/Bangers-Regular.ttf b/fonts/Bangers/Bangers-Regular.ttf new file mode 100644 index 0000000..027af19 Binary files /dev/null and b/fonts/Bangers/Bangers-Regular.ttf differ diff --git a/fonts/Bangers/OFL.txt b/fonts/Bangers/OFL.txt new file mode 100644 index 0000000..64071e3 --- /dev/null +++ b/fonts/Bangers/OFL.txt @@ -0,0 +1,94 @@ +Copyright 2010 The Bangers Project Authors (contact@sansoxygen.com), +with Reserved Font Name Bangers. + +This Font Software is licensed under the SIL Open Font License, Version 1.1. +This license is copied below, and is also available with a FAQ at: +http://scripts.sil.org/OFL + + +----------------------------------------------------------- +SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007 +----------------------------------------------------------- + +PREAMBLE +The goals of the Open Font License (OFL) are to stimulate worldwide +development of collaborative font projects, to support the font creation +efforts of academic and linguistic communities, and to provide a free and +open framework in which fonts may be shared and improved in partnership +with others. + +The OFL allows the licensed fonts to be used, studied, modified and +redistributed freely as long as they are not sold by themselves. The +fonts, including any derivative works, can be bundled, embedded, +redistributed and/or sold with any software provided that any reserved +names are not used by derivative works. The fonts and derivatives, +however, cannot be released under any other type of license. The +requirement for fonts to remain under this license does not apply +to any document created using the fonts or their derivatives. + +DEFINITIONS +"Font Software" refers to the set of files released by the Copyright +Holder(s) under this license and clearly marked as such. This may +include source files, build scripts and documentation. + +"Reserved Font Name" refers to any names specified as such after the +copyright statement(s). + +"Original Version" refers to the collection of Font Software components as +distributed by the Copyright Holder(s). + +"Modified Version" refers to any derivative made by adding to, deleting, +or substituting -- in part or in whole -- any of the components of the +Original Version, by changing formats or by porting the Font Software to a +new environment. + +"Author" refers to any designer, engineer, programmer, technical +writer or other person who contributed to the Font Software. + +PERMISSION & CONDITIONS +Permission is hereby granted, free of charge, to any person obtaining +a copy of the Font Software, to use, study, copy, merge, embed, modify, +redistribute, and sell modified and unmodified copies of the Font +Software, subject to the following conditions: + +1) Neither the Font Software nor any of its individual components, +in Original or Modified Versions, may be sold by itself. + +2) Original or Modified Versions of the Font Software may be bundled, +redistributed and/or sold with any software, provided that each copy +contains the above copyright notice and this license. These can be +included either as stand-alone text files, human-readable headers or +in the appropriate machine-readable metadata fields within text or +binary files as long as those fields can be easily viewed by the user. + +3) No Modified Version of the Font Software may use the Reserved Font +Name(s) unless explicit written permission is granted by the corresponding +Copyright Holder. This restriction only applies to the primary font name as +presented to the users. + +4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font +Software shall not be used to promote, endorse or advertise any +Modified Version, except to acknowledge the contribution(s) of the +Copyright Holder(s) and the Author(s) or with their explicit written +permission. + +5) The Font Software, modified or unmodified, in part or in whole, +must be distributed entirely under this license, and must not be +distributed under any other license. The requirement for fonts to +remain under this license does not apply to any document created +using the Font Software. + +TERMINATION +This license becomes null and void if any of the above conditions are +not met. + +DISCLAIMER +THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT +OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE +COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL +DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM +OTHER DEALINGS IN THE FONT SOFTWARE. diff --git a/images/cards/10_of_clubs.png b/images/cards/10_of_clubs.png new file mode 100644 index 0000000..18af741 Binary files /dev/null and b/images/cards/10_of_clubs.png differ diff --git a/images/cards/10_of_diamonds.png b/images/cards/10_of_diamonds.png new file mode 100644 index 0000000..3bbc4e0 Binary files /dev/null and b/images/cards/10_of_diamonds.png differ diff --git a/images/cards/10_of_hearts.png b/images/cards/10_of_hearts.png new file mode 100644 index 0000000..3eb83d7 Binary files /dev/null and b/images/cards/10_of_hearts.png differ diff --git a/images/cards/10_of_spades.png b/images/cards/10_of_spades.png new file mode 100644 index 0000000..0b3d294 Binary files /dev/null and b/images/cards/10_of_spades.png differ diff --git a/images/cards/2_of_clubs.png b/images/cards/2_of_clubs.png new file mode 100644 index 0000000..291ed97 Binary files /dev/null and b/images/cards/2_of_clubs.png differ diff --git a/images/cards/2_of_diamonds.png b/images/cards/2_of_diamonds.png new file mode 100644 index 0000000..4deee7c Binary files /dev/null and b/images/cards/2_of_diamonds.png differ diff --git a/images/cards/2_of_hearts.png b/images/cards/2_of_hearts.png new file mode 100644 index 0000000..75a014f Binary files /dev/null and b/images/cards/2_of_hearts.png differ diff --git a/images/cards/2_of_spades.png b/images/cards/2_of_spades.png new file mode 100644 index 0000000..1ce0ffe Binary files /dev/null and b/images/cards/2_of_spades.png differ diff --git a/images/cards/3_of_clubs.png b/images/cards/3_of_clubs.png new file mode 100644 index 0000000..076ab31 Binary files /dev/null and b/images/cards/3_of_clubs.png differ diff --git a/images/cards/3_of_diamonds.png b/images/cards/3_of_diamonds.png new file mode 100644 index 0000000..8ee0b4b Binary files /dev/null and b/images/cards/3_of_diamonds.png differ diff --git a/images/cards/3_of_hearts.png b/images/cards/3_of_hearts.png new file mode 100644 index 0000000..8e74673 Binary files /dev/null and b/images/cards/3_of_hearts.png differ diff --git a/images/cards/3_of_spades.png b/images/cards/3_of_spades.png new file mode 100644 index 0000000..f9e06b4 Binary files /dev/null and b/images/cards/3_of_spades.png differ diff --git a/images/cards/4_of_clubs.png b/images/cards/4_of_clubs.png new file mode 100644 index 0000000..8be9e08 Binary files /dev/null and b/images/cards/4_of_clubs.png differ diff --git a/images/cards/4_of_diamonds.png b/images/cards/4_of_diamonds.png new file mode 100644 index 0000000..70e82e8 Binary files /dev/null and b/images/cards/4_of_diamonds.png differ diff --git a/images/cards/4_of_hearts.png b/images/cards/4_of_hearts.png new file mode 100644 index 0000000..ceecbfe Binary files /dev/null and b/images/cards/4_of_hearts.png differ diff --git a/images/cards/4_of_spades.png b/images/cards/4_of_spades.png new file mode 100644 index 0000000..95abe3e Binary files /dev/null and b/images/cards/4_of_spades.png differ diff --git a/images/cards/5_of_clubs.png b/images/cards/5_of_clubs.png new file mode 100644 index 0000000..bde9777 Binary files /dev/null and b/images/cards/5_of_clubs.png differ diff --git a/images/cards/5_of_diamonds.png b/images/cards/5_of_diamonds.png new file mode 100644 index 0000000..bb92525 Binary files /dev/null and b/images/cards/5_of_diamonds.png differ diff --git a/images/cards/5_of_hearts.png b/images/cards/5_of_hearts.png new file mode 100644 index 0000000..d923456 Binary files /dev/null and b/images/cards/5_of_hearts.png differ diff --git a/images/cards/5_of_spades.png b/images/cards/5_of_spades.png new file mode 100644 index 0000000..53a1aad Binary files /dev/null and b/images/cards/5_of_spades.png differ diff --git a/images/cards/6_of_clubs.png b/images/cards/6_of_clubs.png new file mode 100644 index 0000000..a9660a0 Binary files /dev/null and b/images/cards/6_of_clubs.png differ diff --git a/images/cards/6_of_diamonds.png b/images/cards/6_of_diamonds.png new file mode 100644 index 0000000..78a80ad Binary files /dev/null and b/images/cards/6_of_diamonds.png differ diff --git a/images/cards/6_of_hearts.png b/images/cards/6_of_hearts.png new file mode 100644 index 0000000..361643e Binary files /dev/null and b/images/cards/6_of_hearts.png differ diff --git a/images/cards/6_of_spades.png b/images/cards/6_of_spades.png new file mode 100644 index 0000000..40242a7 Binary files /dev/null and b/images/cards/6_of_spades.png differ diff --git a/images/cards/7_of_clubs.png b/images/cards/7_of_clubs.png new file mode 100644 index 0000000..9d6b545 Binary files /dev/null and b/images/cards/7_of_clubs.png differ diff --git a/images/cards/7_of_diamonds.png b/images/cards/7_of_diamonds.png new file mode 100644 index 0000000..6ad5f15 Binary files /dev/null and b/images/cards/7_of_diamonds.png differ diff --git a/images/cards/7_of_hearts.png b/images/cards/7_of_hearts.png new file mode 100644 index 0000000..19b89a2 Binary files /dev/null and b/images/cards/7_of_hearts.png differ diff --git a/images/cards/7_of_spades.png b/images/cards/7_of_spades.png new file mode 100644 index 0000000..b9f1b93 Binary files /dev/null and b/images/cards/7_of_spades.png differ diff --git a/images/cards/8_of_clubs.png b/images/cards/8_of_clubs.png new file mode 100644 index 0000000..cec743c Binary files /dev/null and b/images/cards/8_of_clubs.png differ diff --git a/images/cards/8_of_diamonds.png b/images/cards/8_of_diamonds.png new file mode 100644 index 0000000..ed12951 Binary files /dev/null and b/images/cards/8_of_diamonds.png differ diff --git a/images/cards/8_of_hearts.png b/images/cards/8_of_hearts.png new file mode 100644 index 0000000..fb39723 Binary files /dev/null and b/images/cards/8_of_hearts.png differ diff --git a/images/cards/8_of_spades.png b/images/cards/8_of_spades.png new file mode 100644 index 0000000..b6b3b38 Binary files /dev/null and b/images/cards/8_of_spades.png differ diff --git a/images/cards/9_of_clubs.png b/images/cards/9_of_clubs.png new file mode 100644 index 0000000..2174db5 Binary files /dev/null and b/images/cards/9_of_clubs.png differ diff --git a/images/cards/9_of_diamonds.png b/images/cards/9_of_diamonds.png new file mode 100644 index 0000000..0b933fb Binary files /dev/null and b/images/cards/9_of_diamonds.png differ diff --git a/images/cards/9_of_hearts.png b/images/cards/9_of_hearts.png new file mode 100644 index 0000000..7b196d6 Binary files /dev/null and b/images/cards/9_of_hearts.png differ diff --git a/images/cards/9_of_spades.png b/images/cards/9_of_spades.png new file mode 100644 index 0000000..3c3b5ff Binary files /dev/null and b/images/cards/9_of_spades.png differ diff --git a/images/cards/ace_of_clubs.png b/images/cards/ace_of_clubs.png new file mode 100644 index 0000000..42bf5ec Binary files /dev/null and b/images/cards/ace_of_clubs.png differ diff --git a/images/cards/ace_of_diamonds.png b/images/cards/ace_of_diamonds.png new file mode 100644 index 0000000..79cd3b8 Binary files /dev/null and b/images/cards/ace_of_diamonds.png differ diff --git a/images/cards/ace_of_hearts.png b/images/cards/ace_of_hearts.png new file mode 100644 index 0000000..b422124 Binary files /dev/null and b/images/cards/ace_of_hearts.png differ diff --git a/images/cards/ace_of_spades.png b/images/cards/ace_of_spades.png new file mode 100644 index 0000000..103f56d Binary files /dev/null and b/images/cards/ace_of_spades.png differ diff --git a/images/cards/back.png b/images/cards/back.png new file mode 100644 index 0000000..84575a2 Binary files /dev/null and b/images/cards/back.png differ diff --git a/images/cards/jack_of_clubs.png b/images/cards/jack_of_clubs.png new file mode 100644 index 0000000..5e003be Binary files /dev/null and b/images/cards/jack_of_clubs.png differ diff --git a/images/cards/jack_of_diamonds.png b/images/cards/jack_of_diamonds.png new file mode 100644 index 0000000..131a977 Binary files /dev/null and b/images/cards/jack_of_diamonds.png differ diff --git a/images/cards/jack_of_hearts.png b/images/cards/jack_of_hearts.png new file mode 100644 index 0000000..bf342bc Binary files /dev/null and b/images/cards/jack_of_hearts.png differ diff --git a/images/cards/jack_of_spades.png b/images/cards/jack_of_spades.png new file mode 100644 index 0000000..f539c19 Binary files /dev/null and b/images/cards/jack_of_spades.png differ diff --git a/images/cards/king_of_clubs.png b/images/cards/king_of_clubs.png new file mode 100644 index 0000000..68e5774 Binary files /dev/null and b/images/cards/king_of_clubs.png differ diff --git a/images/cards/king_of_diamonds.png b/images/cards/king_of_diamonds.png new file mode 100644 index 0000000..e21d6a0 Binary files /dev/null and b/images/cards/king_of_diamonds.png differ diff --git a/images/cards/king_of_hearts.png b/images/cards/king_of_hearts.png new file mode 100644 index 0000000..1d3c468 Binary files /dev/null and b/images/cards/king_of_hearts.png differ diff --git a/images/cards/king_of_spades.png b/images/cards/king_of_spades.png new file mode 100644 index 0000000..2edbbc1 Binary files /dev/null and b/images/cards/king_of_spades.png differ diff --git a/images/cards/queen_of_clubs.png b/images/cards/queen_of_clubs.png new file mode 100644 index 0000000..7be5f9a Binary files /dev/null and b/images/cards/queen_of_clubs.png differ diff --git a/images/cards/queen_of_diamonds.png b/images/cards/queen_of_diamonds.png new file mode 100644 index 0000000..928f650 Binary files /dev/null and b/images/cards/queen_of_diamonds.png differ diff --git a/images/cards/queen_of_hearts.png b/images/cards/queen_of_hearts.png new file mode 100644 index 0000000..21839e6 Binary files /dev/null and b/images/cards/queen_of_hearts.png differ diff --git a/images/cards/queen_of_spades.png b/images/cards/queen_of_spades.png new file mode 100644 index 0000000..7983d03 Binary files /dev/null and b/images/cards/queen_of_spades.png differ diff --git a/images/logo.png b/images/logo.png new file mode 100644 index 0000000..7b25b86 Binary files /dev/null and b/images/logo.png differ diff --git a/images/play.png b/images/play.png new file mode 100644 index 0000000..db09872 Binary files /dev/null and b/images/play.png differ diff --git a/images/undo.png b/images/undo.png new file mode 100644 index 0000000..1074ee9 Binary files /dev/null and b/images/undo.png differ diff --git a/index.html b/index.html index 25a06fd..1c3532a 100644 --- a/index.html +++ b/index.html @@ -1,12 +1,18 @@
-
diff --git a/package-lock.json b/package-lock.json
index 4e29994..36e87f3 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,5 +1,5 @@
{
- "name": "match-game-swe1",
+ "name": "match-game-bootcamp",
"version": "1.0.0",
"lockfileVersion": 1,
"requires": true,
diff --git a/script.js b/script.js
index e2d0297..f11a926 100644
--- a/script.js
+++ b/script.js
@@ -1 +1,385 @@
// Please implement exercise logic here
+
+// boardSize has to be an even number
+const boardSize = 4;
+const cardSize = 16;
+const board = [];
+let firstCard = null;
+let firstCardElement;
+let deck = [];
+let canClick = false;
+let playerName = "";
+let timeLeftInSeconds = 180;
+let timeInterval;
+let matchedCards = 0;
+let matchesWon = 0;
+
+const cardClick = (cardElement, row, column) => {
+ canClick = false;
+ const clickedCard = board[row][column];
+
+ // first turn
+ if (firstCard === null) {
+ document.getElementById(clickedCard.id).classList.toggle("is-flipped");
+ firstCard = clickedCard;
+ firstCardElement = cardElement;
+ canClick = true;
+ document.getElementById("message").innerText = "Select the second card";
+ } else {
+ // second turn if user click the same card again
+ if (clickedCard.id === firstCard.id) {
+ document.getElementById("message").innerText = "Select the second card";
+ // reset();
+ canClick = true;
+ }
+ // if user matches both cards
+ else if (
+ clickedCard.name === firstCard.name &&
+ clickedCard.suit === firstCard.suit
+ ) {
+ document.getElementById(clickedCard.id).classList.toggle("is-flipped");
+
+ // turn this card over
+ document.getElementById(firstCard.id).classList.toggle("orange");
+ document.getElementById(clickedCard.id).classList.toggle("orange");
+
+ matchedCards += 2;
+
+ // if user matches all cards
+ if (matchedCards == cardSize) {
+ document.getElementById("message").innerText = "You win this round!";
+ document.getElementById(
+ "matchesWon"
+ ).innerHTML = `
`;
+
+ const cardFaceFront = document.createElement("div");
+ cardFaceFront.classList.add("card__face");
+ cardFaceFront.classList.add("card__face--front");
+ cardFaceFront.innerHTML = `