From 6d408b4079b09ee6a243edf83659f854ff70b982 Mon Sep 17 00:00:00 2001 From: Arunabh Date: Mon, 14 Feb 2022 22:44:36 +0530 Subject: [PATCH 1/3] changed the main.js file --- main.js | 72 ++++++++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 64 insertions(+), 8 deletions(-) diff --git a/main.js b/main.js index f242959..971bcb8 100644 --- a/main.js +++ b/main.js @@ -14,8 +14,8 @@ var playerLife = 5; var hackerLife = 5; // Message to be displayed when the game is over -var hackerWinnerMessage = "Write the message here"; -var playerWinnerMessage = "Write the message here"; +var hackerWinnerMessage = "Hacker won the game. "; +var playerWinnerMessage = "You won the game, Hacker lost"; // ---------------Game code starts here ---------------// @@ -27,20 +27,38 @@ var hackerStartLife = parseInt(hackerLife); // we will declare the functions for you and you will complete those updateScores(); +//card is not selected currently +var cardSelected = false; // you learnt DOM manipulation right? here's an example of the same. Go ahead and use manipulate the DOM! document.querySelector(".game-board").classList.add("before-game"); var allCardElements = document.querySelectorAll(".card"); -// Adds click handler to all player card elements so that your cards are actionable +// Adds click handler to all player card elements so that your cards are actionable +for(var i=0; i Date: Tue, 15 Feb 2022 06:25:38 +0530 Subject: [PATCH 2/3] final changes --- index.html | 8 +-- main.js | 154 +++++++++++++++++++++++++++++++---------------------- style.css | 6 +-- 3 files changed, 98 insertions(+), 70 deletions(-) diff --git a/index.html b/index.html index bb03a42..7e8faf5 100644 --- a/index.html +++ b/index.html @@ -30,7 +30,7 @@

Hacker
-
+
@@ -46,17 +46,17 @@

You

-
+
-
+
-
+
diff --git a/main.js b/main.js index 971bcb8..873d766 100644 --- a/main.js +++ b/main.js @@ -17,7 +17,7 @@ var hackerLife = 5; var hackerWinnerMessage = "Hacker won the game. "; var playerWinnerMessage = "You won the game, Hacker lost"; - // ---------------Game code starts here ---------------// +// ---------------Game code starts here ---------------// // declare a few handy variables like we've done :p @@ -29,6 +29,10 @@ updateScores(); //card is not selected currently var cardSelected = false; + +//index of the scenerios +let scene = 0; + // you learnt DOM manipulation right? here's an example of the same. Go ahead and use manipulate the DOM! document.querySelector(".game-board").classList.add("before-game"); @@ -36,114 +40,118 @@ var allCardElements = document.querySelectorAll(".card"); // Adds click handler to all player card elements so that your cards are actionable -for(var i=0; i hackerScore) { + hackerLife -= hackerScore; + } + else if (hackerScore > playerScore) { + playerLife -= playerScore; + } + updateScores(); + setTimeout(function () { + document.querySelector(".next-turn").style.display = 'block'; + }, 300); + } //Use conditional statements and complete the function that shows the winner message function gameOver(winner) { - + } // Write a function that starts the game function startGame() { var cards = document.getElementsByClassName('card'); - // console.log(cards.length) - for(var i=0; i Date: Tue, 15 Feb 2022 06:26:55 +0530 Subject: [PATCH 3/3] final changes 2.0 --- main.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/main.js b/main.js index 873d766..24213e8 100644 --- a/main.js +++ b/main.js @@ -181,10 +181,10 @@ function playTurn() { // console.log(window.getComputedStyle(btn).transform); var cards = document.getElementsByClassName('card'); for(var i=0; i