diff --git a/MiniProjects/RockPaperScissors/game.html b/MiniProjects/RockPaperScissors/game.html new file mode 100644 index 0000000..6c9a986 --- /dev/null +++ b/MiniProjects/RockPaperScissors/game.html @@ -0,0 +1,104 @@ + + + + + + Document + + + +

Rock Paper Scissors

+
+ Rock + Paper + Scissors +
+ +
+

Your Choice:

+

-


+

Computer Choice:

+

-

+
+ +
+

+
+ +
+

Your Score:

+

0

+

Computer Score:

+

0

+
+ + + + diff --git a/MiniProjects/RockPaperScissors/paper.jpg b/MiniProjects/RockPaperScissors/paper.jpg new file mode 100644 index 0000000..0e2e15e Binary files /dev/null and b/MiniProjects/RockPaperScissors/paper.jpg differ diff --git a/MiniProjects/RockPaperScissors/rock.jpg b/MiniProjects/RockPaperScissors/rock.jpg new file mode 100644 index 0000000..b493b1e Binary files /dev/null and b/MiniProjects/RockPaperScissors/rock.jpg differ diff --git a/MiniProjects/RockPaperScissors/scissors.jpg b/MiniProjects/RockPaperScissors/scissors.jpg new file mode 100644 index 0000000..a854748 Binary files /dev/null and b/MiniProjects/RockPaperScissors/scissors.jpg differ diff --git a/MiniProjects/RockPaperScissors/script.js b/MiniProjects/RockPaperScissors/script.js new file mode 100644 index 0000000..dc2dfa1 --- /dev/null +++ b/MiniProjects/RockPaperScissors/script.js @@ -0,0 +1,68 @@ +window.onload = () =>{ + document.getElementById("yourscore").innerText = localStorage.getItem("playerScore"); + document.getElementById("computerscore").innerText = localStorage.getItem("computerScore"); +}; + +function play(choice) { + let playerScore = localStorage.getItem("playerScore") == null ? 0 : Number(localStorage.getItem("playerScore")); + let computerScore = Number(localStorage.getItem("computerScore")) == NaN ? 0 : Number(localStorage.getItem("computerScore")); + choice = Number(choice) + let num = Math.floor(Math.random() * 3); + let computerChoice = makeittext(num); + document.getElementById("computerchoice").innerText = computerChoice; + document.getElementById("yourchoice").innerText = makeittext(choice); + + if(num == choice){ + document.getElementById("winnertext").innerText = "It is a TIE!"; + } + else if(num == 0 && choice == 1){ + document.getElementById("winnertext").innerText = "YOU WON!"; + playerScore += 1; + } + else if(choice == 0 && num == 1){ + document.getElementById("winnertext").innerText = "The COMPUTER WON!"; + computerScore += 1; + } + else if(num == 0 && choice == 2){ + document.getElementById("winnertext").innerText = "The COMPUTER WON!"; + computerScore += 1; + } + else if(num == 2 && choice == 0){ + document.getElementById("winnertext").innerText = "YOU WON!"; + playerScore += 1; + } + else if(num == 1 && choice == 2){ + document.getElementById("winnertext").innerText = "YOU WON!"; + playerScore += 1; + } + else if(num == 2 && choice == 1){ + document.getElementById("winnertext").innerText = "The COMPUTER WON!"; + computerScore += 1; + } + + document.getElementById("yourscore").innerText = playerScore; + document.getElementById("computerscore").innerText = computerScore; + + localStorage.setItem("playerScore", playerScore) + localStorage.setItem("computerScore", computerScore) +} + +function computerChoise() { + let num = Math.floor(Math.random() * 3); + return makeittext(num); +} +function makeittext(num){ + let res = ""; + switch (num) { + case 0: + res = "Rock"; + break; + case 1: + res = "Paper"; + break; + case 2: + res = "Scissors"; + break; + } + return res; +} diff --git a/Practice/NodeListsAndOtherLists/script.js b/Practice/NodeListsAndOtherLists/script.js index 3680222..b32d0c8 100644 --- a/Practice/NodeListsAndOtherLists/script.js +++ b/Practice/NodeListsAndOtherLists/script.js @@ -41,3 +41,5 @@ buttone = document.getElementById("buttontwo"); buttone.addEventListener("mouseover", event =>{ buttone.classList.toggle("texttwo"); //toggle will add if the class is not there and remove if it is there }); + +//https://www.youtube.com/watch?v=lfmg-EJ8gm4&t=35022s \ No newline at end of file