From 9eee3c1101dcc32992893a1a749908add9d7595b Mon Sep 17 00:00:00 2001 From: "Glitch (rock-paper-scissors-proje)" Date: Wed, 10 Nov 2021 23:28:49 +0000 Subject: [PATCH 1/8] =?UTF-8?q?=F0=9F=90=B5=F0=9F=9A=A8=20Updated=20with?= =?UTF-8?q?=20Glitch?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .glitch-assets | 0 index.html | 2 ++ js/script.js | 31 +++++++++++++++++++++++++++++++ 3 files changed, 33 insertions(+) create mode 100644 .glitch-assets diff --git a/.glitch-assets b/.glitch-assets new file mode 100644 index 00000000..e69de29b diff --git a/index.html b/index.html index 820e449f..315b69d8 100644 --- a/index.html +++ b/index.html @@ -4,6 +4,8 @@ RPS Game + + diff --git a/js/script.js b/js/script.js index 8b137891..690a7d9e 100644 --- a/js/script.js +++ b/js/script.js @@ -1 +1,32 @@ +let computerChoiceNum= ["rock","paper","scissors"]; +// User clicks button +$(".play").click(function() { + + let user_choice = $(".input").val(); + + console.log(); + console.log(`Choice: ${user_choice}`); + +// // Show user choice + $(".userChoice").text(user_choice); + // Have rock paper scissors be numbers so ai can use random +let ranDecimal = Math.random(); +let randNumber = ranDecimal * computerChoiceNum.length; +let num1 = Math.floor(randNumber); + $(".computerChoice").append(num1); + + console.log(num1); + console.log(computerChoiceNum[num1]); + // Generate random number + + if (user_choice == "rock" && computerChoiceNum == "scissors"){ + $().append(); + } + + // Determine win or loss + + + // Display result of game +}); + From e37f21b91fb104cf4132a8fd8c12c7d3d38b28d6 Mon Sep 17 00:00:00 2001 From: "Glitch (rock-paper-scissors-proje)" Date: Wed, 17 Nov 2021 23:24:31 +0000 Subject: [PATCH 2/8] =?UTF-8?q?=F0=9F=8F=B5=F0=9F=90=B7=20Updated=20with?= =?UTF-8?q?=20Glitch?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- js/script.js | 139 +++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 117 insertions(+), 22 deletions(-) diff --git a/js/script.js b/js/script.js index 690a7d9e..fafcab1f 100644 --- a/js/script.js +++ b/js/script.js @@ -1,32 +1,127 @@ -let computerChoiceNum= ["rock","paper","scissors"]; +//for some unkown reason we if we use all lowercase it gives all 3 results \/(-_-)\/ +let computerChoiceNum = ["rock", "paper", "scissors"]; + +//Thunpitcha + +let randomNumber = 0; + // User clicks button -$(".play").click(function() { - + +$(".play").click(function() { let user_choice = $(".input").val(); - - console.log(); - console.log(`Choice: ${user_choice}`); - -// // Show user choice + $(".userChoice").text(user_choice); - // Have rock paper scissors be numbers so ai can use random -let ranDecimal = Math.random(); -let randNumber = ranDecimal * computerChoiceNum.length; -let num1 = Math.floor(randNumber); - $(".computerChoice").append(num1); - - console.log(num1); - console.log(computerChoiceNum[num1]); - // Generate random number - if (user_choice == "rock" && computerChoiceNum == "scissors"){ - $().append(); + randomNumber = Math.floor(Math.random() * 3); + + $(".computerChoice").text(computerChoiceNum[randomNumber]); + + if ( + user_choice == "rock" + || + user_choice == "Rock" + || + user_choice == "ROCK" + && + computerChoiceNum[randomNumber] == "scissors") { + + $(".result").append(`

You Won!

`); } - // Determine win or loss + if ( + user_choice == "rock" + || + user_choice == "Rock" + || + user_choice == "ROCK" + && + computerChoiceNum[randomNumber] == "rock") { + + $(".result").append(`

You Tied!

`); + } + if ( + user_choice == "rock" + || + user_choice == "Rock" + || + user_choice == "ROCK" + && + computerChoiceNum[randomNumber] == "paper") { + + $(".result").append(`

You Lost!

`); + } - // Display result of game -}); + if ( + user_choice == "paper" + || + user_choice == "Paper" + || + user_choice == "PAPER" + && + computerChoiceNum[randomNumber] == "rock") { + + $(".result").append(`

You Won!

`); + } + if ( + user_choice == "paper" + || + user_choice == "Paper" + || + user_choice == "PAPER" + && + computerChoiceNum[randomNumber] == "scissors") { + + $(".result").append(`

You Lost!

`); + } + + if ( + user_choice == "paper" + || + user_choice == "Paper" + || + user_choice == "PAPER" + && + computerChoiceNum[randomNumber] == "paper") { + + $(".result").append(`

You Tied!

`); + } + + if ( + user_choice == "scissors" + || + user_choice == "Scissors" + || + user_choice == "SCISSORS" + && + computerChoiceNum[randomNumber] == "scissors") { + + $(".result").append(`

You Tied!

`); + } + + if ( + user_choice == "scissors" + || + user_choice == "Scissors" + || + user_choice == "SCISSORS" + && + computerChoiceNum[randomNumber] == "rock") { + + $(".result").append(`

You Lost!

`); + } + + if ( + user_choice == "scissors" + || + user_choice == "Scissors" + || + user_choice == "SCISSORS" + && + computerChoiceNum[randomNumber] == "paper") { + + $(".result").append(`

You Won!

`); + } +}); \ No newline at end of file From f1cba27f343efd980283044aaa2339d94fac47f5 Mon Sep 17 00:00:00 2001 From: "Glitch (rock-paper-scissors-proje)" Date: Wed, 17 Nov 2021 23:33:14 +0000 Subject: [PATCH 3/8] =?UTF-8?q?=F0=9F=91=82=E2=98=BA=EF=B8=8F=20Updated=20?= =?UTF-8?q?with=20Glitch?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- js/script.js | 40 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 38 insertions(+), 2 deletions(-) diff --git a/js/script.js b/js/script.js index fafcab1f..e5ead2f7 100644 --- a/js/script.js +++ b/js/script.js @@ -17,21 +17,29 @@ $(".play").click(function() { $(".computerChoice").text(computerChoiceNum[randomNumber]); if ( - user_choice == "rock" + user_choice == "rock" + && + computerChoiceNum[randomNumber] == "scissors" || user_choice == "Rock" + && + computerChoiceNum[randomNumber] == "scissors" || user_choice == "ROCK" && - computerChoiceNum[randomNumber] == "scissors") { + computerChoiceNum[randomNumber] == "scissors" ) { $(".result").append(`

You Won!

`); } if ( user_choice == "rock" + && + computerChoiceNum[randomNumber] == "rock" || user_choice == "Rock" + && + computerChoiceNum[randomNumber] == "rock" || user_choice == "ROCK" && @@ -42,8 +50,12 @@ $(".play").click(function() { if ( user_choice == "rock" + && + computerChoiceNum[randomNumber] == "paper" || user_choice == "Rock" + && + computerChoiceNum[randomNumber] == "paper" || user_choice == "ROCK" && @@ -54,8 +66,12 @@ $(".play").click(function() { if ( user_choice == "paper" + && + computerChoiceNum[randomNumber] == "rock" || user_choice == "Paper" + && + computerChoiceNum[randomNumber] == "rock" || user_choice == "PAPER" && @@ -66,8 +82,12 @@ $(".play").click(function() { if ( user_choice == "paper" + && + computerChoiceNum[randomNumber] == "scissors" || user_choice == "Paper" + && + computerChoiceNum[randomNumber] == "scissors" || user_choice == "PAPER" && @@ -78,8 +98,12 @@ $(".play").click(function() { if ( user_choice == "paper" + && + computerChoiceNum[randomNumber] == "paper" || user_choice == "Paper" + && + computerChoiceNum[randomNumber] == "paper" || user_choice == "PAPER" && @@ -90,8 +114,12 @@ $(".play").click(function() { if ( user_choice == "scissors" + && + computerChoiceNum[randomNumber] == "scissors" || user_choice == "Scissors" + && + computerChoiceNum[randomNumber] == "scissors" || user_choice == "SCISSORS" && @@ -102,8 +130,12 @@ $(".play").click(function() { if ( user_choice == "scissors" + && + computerChoiceNum[randomNumber] == "rock" || user_choice == "Scissors" + && + computerChoiceNum[randomNumber] == "rock" || user_choice == "SCISSORS" && @@ -114,8 +146,12 @@ $(".play").click(function() { if ( user_choice == "scissors" + && + computerChoiceNum[randomNumber] == "paper" || user_choice == "Scissors" + && + computerChoiceNum[randomNumber] == "paper" || user_choice == "SCISSORS" && From 40a68d0fadb41ed250b3ced52b8d8d79cc51d5fc Mon Sep 17 00:00:00 2001 From: "Glitch (rock-paper-scissors-proje)" Date: Thu, 2 Dec 2021 00:08:47 +0000 Subject: [PATCH 4/8] =?UTF-8?q?=F0=9F=98=AC=F0=9F=90=80=20Updated=20with?= =?UTF-8?q?=20Glitch?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 28 +++---- js/script.js | 205 +++++++++++++++------------------------------------ 2 files changed, 74 insertions(+), 159 deletions(-) diff --git a/README.md b/README.md index f108acf1..423290aa 100644 --- a/README.md +++ b/README.md @@ -15,48 +15,48 @@ In this unit, coders will create a Rock, Paper, Scissors game. The Rock, Paper, #### GitHub Set-Up - [x] Go to the repository at https://github.com/itscodenation/rockpaperscissors -- [ ] Fork this repository to your Github account and import to a new workspace -- [ ] Link and commit your changes -- [ ] Make your site live on GitHub Pages +- [x] Fork this repository to your Github account and import to a new workspace +- [x] Link and commit your changes +- [x] Make your site live on GitHub Pages #### Code Walkthrough -- [ ] Read through the starter code given so you understand how the HTML is organized +- [x] Read through the starter code given so you understand how the HTML is organized ### Day 1 Goal 2: Capture user input and display it to the screen -- [ ] Add a click handler that saves the value of the user's input to a variable -- [ ] Display the user input value on the screen, in the user choice location +- [x] Add a click handler that saves the value of the user's input to a variable +- [x] Display the user input value on the screen, in the user choice location #### Wrap -- [ ] Commit your changes! +- [x] Commit your changes! ## Day 2 ### Day 2 Goal 1: Generate a new random number every time the user clicks the button -- [ ] Outside of your click handler, declare a randomNumber variable and set it equal to 0 -- [ ] In your click handler, generate a random number and assign it to the randomNumber variable +- [x] Outside of your click handler, declare a randomNumber variable and set it equal to 0 +- [x] In your click handler, generate a random number and assign it to the randomNumber variable ### Day 2 Goal 2: Display the random number to the screen -- [ ] Display the randomNumber value on the screen, in the computer choice location +- [x] Display the randomNumber value on the screen, in the computer choice location #### Wrap -- [ ] Commit your changes! +- [x] Commit your changes! ## Day 3 ### Day 3 Goal 1: Assign different computer choices depending on the random number -- [ ] Write a conditional statement which, given the number range of randomNumber, assigns ‘rock’, ‘paper’ or ‘scissors’ to a computerChoice variable -- [ ] Update the computer choice location so it displays the computerChoice to the screen +- [x] Write a conditional statement which, given the number range of randomNumber, assigns ‘rock’, ‘paper’ or ‘scissors’ to a computerChoice variable +- [x] Update the computer choice location so it displays the computerChoice to the screen ### Day 3 Goal 2: Increase user experience (BONUS!) -- [ ] Test for edge cases by ensuring that a result appears if the user does not type an acceptable input +- [x] Test for edge cases by ensuring that a result appears if the user does not type an acceptable input ## Day 4 diff --git a/js/script.js b/js/script.js index e5ead2f7..646a3eb5 100644 --- a/js/script.js +++ b/js/script.js @@ -1,163 +1,78 @@ -//for some unkown reason we if we use all lowercase it gives all 3 results \/(-_-)\/ let computerChoiceNum = ["rock", "paper", "scissors"]; -//Thunpitcha - let randomNumber = 0; +let result; // User clicks button -$(".play").click(function() { - let user_choice = $(".input").val(); - - $(".userChoice").text(user_choice); - +// Thunpitcha's function +// Docs: https://docs.google.com/document/d/1gq7oUif59sKDInbJrDTIeSQBaOlGb5ri06b2-noWWNI/edit#heading=h.x4lnrrw34ze2 +function getRandomComputerChoice() { + return computerChoiceNum; randomNumber = Math.floor(Math.random() * 3); $(".computerChoice").text(computerChoiceNum[randomNumber]); - if ( - user_choice == "rock" - && - computerChoiceNum[randomNumber] == "scissors" - || - user_choice == "Rock" - && - computerChoiceNum[randomNumber] == "scissors" - || - user_choice == "ROCK" - && - computerChoiceNum[randomNumber] == "scissors" ) { - - $(".result").append(`

You Won!

`); - } - - if ( - user_choice == "rock" - && - computerChoiceNum[randomNumber] == "rock" - || - user_choice == "Rock" - && - computerChoiceNum[randomNumber] == "rock" - || - user_choice == "ROCK" - && - computerChoiceNum[randomNumber] == "rock") { - - $(".result").append(`

You Tied!

`); - } - - if ( - user_choice == "rock" - && - computerChoiceNum[randomNumber] == "paper" - || - user_choice == "Rock" - && - computerChoiceNum[randomNumber] == "paper" - || - user_choice == "ROCK" - && - computerChoiceNum[randomNumber] == "paper") { - - $(".result").append(`

You Lost!

`); - } + +} +$(".play").click(function() { + let user_choice = $(".input").val(); - if ( - user_choice == "paper" - && - computerChoiceNum[randomNumber] == "rock" - || - user_choice == "Paper" - && - computerChoiceNum[randomNumber] == "rock" - || - user_choice == "PAPER" - && - computerChoiceNum[randomNumber] == "rock") { - - $(".result").append(`

You Won!

`); - } + $(".userChoice").text(user_choice); - if ( - user_choice == "paper" - && - computerChoiceNum[randomNumber] == "scissors" - || - user_choice == "Paper" - && - computerChoiceNum[randomNumber] == "scissors" - || - user_choice == "PAPER" - && - computerChoiceNum[randomNumber] == "scissors") { - - $(".result").append(`

You Lost!

`); - } + user_choice = user_choice.toLowerCase(); - if ( - user_choice == "paper" - && - computerChoiceNum[randomNumber] == "paper" - || - user_choice == "Paper" - && - computerChoiceNum[randomNumber] == "paper" - || - user_choice == "PAPER" - && - computerChoiceNum[randomNumber] == "paper") { - - $(".result").append(`

You Tied!

`); - } + randomNumber = Math.floor(Math.random() * 3); - if ( - user_choice == "scissors" - && - computerChoiceNum[randomNumber] == "scissors" - || - user_choice == "Scissors" - && - computerChoiceNum[randomNumber] == "scissors" - || - user_choice == "SCISSORS" - && - computerChoiceNum[randomNumber] == "scissors") { - - $(".result").append(`

You Tied!

`); - } + $(".computerChoice").text(computerChoiceNum[randomNumber]); - if ( - user_choice == "scissors" - && - computerChoiceNum[randomNumber] == "rock" - || - user_choice == "Scissors" - && - computerChoiceNum[randomNumber] == "rock" - || - user_choice == "SCISSORS" - && - computerChoiceNum[randomNumber] == "rock") { - - $(".result").append(`

You Lost!

`); + if (user_choice == "rock" && computerChoiceNum[randomNumber] == "scissors") { + result = "You Won!"; + } else if ( + user_choice == "rock" && + computerChoiceNum[randomNumber] == "rock" + ) { + result = "You Tied!"; + } else if ( + user_choice == "rock" && + computerChoiceNum[randomNumber] == "paper" + ) { + result = "You Lost!"; + } else if ( + user_choice == "paper" && + computerChoiceNum[randomNumber] == "rock" + ) { + result = "You Won!"; + } else if ( + user_choice == "paper" && + computerChoiceNum[randomNumber] == "scissors" + ) { + result = "You Lost!"; + } else if ( + user_choice == "paper" && + computerChoiceNum[randomNumber] == "paper" + ) { + result = "You Tied!"; + } else if ( + user_choice == "scissors" && + computerChoiceNum[randomNumber] == "scissors" + ) { + result = "You Tied!"; + } else if ( + user_choice == "scissors" && + computerChoiceNum[randomNumber] == "rock" + ) { + result = "You Lost!"; + } else if ( + user_choice == "scissors" && + computerChoiceNum[randomNumber] == "paper" + ) { + result = "You Won!"; + } else { + $(".result").append(`

Your input is invalid, try again.

`); } - if ( - user_choice == "scissors" - && - computerChoiceNum[randomNumber] == "paper" - || - user_choice == "Scissors" - && - computerChoiceNum[randomNumber] == "paper" - || - user_choice == "SCISSORS" - && - computerChoiceNum[randomNumber] == "paper") { - - $(".result").append(`

You Won!

`); - } + // use 'result' -}); \ No newline at end of file + $(".result").text(result); +}); From 4f3db4e9ef055bb6056e274a67b6a43cab9d2e0c Mon Sep 17 00:00:00 2001 From: "Glitch (rock-paper-scissors-proje)" Date: Wed, 8 Dec 2021 23:27:38 +0000 Subject: [PATCH 5/8] =?UTF-8?q?=F0=9F=91=AF=F0=9F=8E=B1=20Updated=20with?= =?UTF-8?q?=20Glitch?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 22 +++++------ index.html | 19 +++++++++- js/script.js | 105 +++++++++++++++++++++++++++++---------------------- 3 files changed, 88 insertions(+), 58 deletions(-) diff --git a/README.md b/README.md index 423290aa..8773dd54 100644 --- a/README.md +++ b/README.md @@ -62,31 +62,31 @@ In this unit, coders will create a Rock, Paper, Scissors game. The Rock, Paper, ### Day 4 Goal 1: Compare the user choice and computer choice to determine a winner -- [ ] Write a compound conditional statement that compares the userChoice to the computerChoice -- [ ] Declare a variable to save the winner of the game -- [ ] Display the winner to the screen in the result div +- [x] Write a compound conditional statement that compares the userChoice to the computerChoice +- [x] Declare a variable to save the winner of the game +- [x] Display the winner to the screen in the result div ### Day 4 Goal 2: Increase user experience (BONUS!) -- [ ] Test that your game performs correctly in case of a tie -- [ ] Clear the input value once a result is displayed so your game is ready to play again +- [x] Test that your game performs correctly in case of a tie +- [x] Clear the input value once a result is displayed so your game is ready to play again #### Wrap -- [ ] Commit your changes! +- [x] Commit your changes! #### Day 5 ### Day 5 Goal 1: Create a function to handle your computer choice logic -- [ ] Write a function called getRandomComputerChoice that does not accept any parameters and returns computerChoice -- [ ] Move your `Math.random` inside your function -- [ ] Move your conditional logic that determines the computer choice inside your function +- [x] Write a function called getRandomComputerChoice that does not accept any parameters and returns computerChoice +- [x] Move your `Math.random` inside your function +- [x] Move your conditional logic that determines the computer choice inside your function ### Day 5 Goal 2: Call your getRandomComputerChoice function -- [ ] Call your function inside your click handler so that it determines the value of your computerChoice variable - - [ ] HINT: Your getRandomComputerChoice function works correctly if it returns rock, paper, or scissors when called +- [x] Call your function inside your click handler so that it determines the value of your computerChoice variable +- [x] HINT: Your getRandomComputerChoice function works correctly if it returns rock, paper, or scissors when called #### Wrap diff --git a/index.html b/index.html index 315b69d8..f5e57fc7 100644 --- a/index.html +++ b/index.html @@ -18,7 +18,9 @@

Please Submit Your Choice Below

- +
+ +

User Choice

@@ -31,6 +33,21 @@

Computer Choice

+
+

+
+
+

+
+
+

+
+
+

+
+
+

+
diff --git a/js/script.js b/js/script.js index 646a3eb5..a76af69b 100644 --- a/js/script.js +++ b/js/script.js @@ -1,78 +1,91 @@ let computerChoiceNum = ["rock", "paper", "scissors"]; +let totalWins = 0; +let totalTies = 0; +let totalLoses = 0; +let totalGames = 0; +let winRate = totalWins / totalGames; -let randomNumber = 0; - -let result; -// User clicks button // Thunpitcha's function // Docs: https://docs.google.com/document/d/1gq7oUif59sKDInbJrDTIeSQBaOlGb5ri06b2-noWWNI/edit#heading=h.x4lnrrw34ze2 function getRandomComputerChoice() { - return computerChoiceNum; - randomNumber = Math.floor(Math.random() * 3); + let randomNumber = Math.floor(Math.random() * 3); + + let choice; - $(".computerChoice").text(computerChoiceNum[randomNumber]); + if (randomNumber === 0) { + choice = "rock"; + } else if (randomNumber === 1) { + choice = "scissors"; + } else { + choice = "paper"; + } - + return choice; // value = "rock", "paper", "scissors" } + +$(".clear").click(function() { + $(".input").val(""); + $(".userChoice").text(""); + $(".result").text(""); + $(".computerChoice").text(""); +}); + $(".play").click(function() { + + let result; + totalGames = totalGames + 1; + + let choices = getRandomComputerChoice(); + let user_choice = $(".input").val(); $(".userChoice").text(user_choice); user_choice = user_choice.toLowerCase(); - randomNumber = Math.floor(Math.random() * 3); + $(".computerChoice").text(choices); - $(".computerChoice").text(computerChoiceNum[randomNumber]); - - if (user_choice == "rock" && computerChoiceNum[randomNumber] == "scissors") { + if (user_choice == "rock" && choices == "scissors") { result = "You Won!"; - } else if ( - user_choice == "rock" && - computerChoiceNum[randomNumber] == "rock" - ) { + } else if (user_choice == "rock" && choices == "rock") { result = "You Tied!"; - } else if ( - user_choice == "rock" && - computerChoiceNum[randomNumber] == "paper" - ) { + } else if (user_choice == "rock" && choices == "paper") { result = "You Lost!"; - } else if ( - user_choice == "paper" && - computerChoiceNum[randomNumber] == "rock" - ) { + } else if (user_choice == "paper" && choices == "rock") { result = "You Won!"; - } else if ( - user_choice == "paper" && - computerChoiceNum[randomNumber] == "scissors" - ) { + } else if (user_choice == "paper" && choices == "scissors") { result = "You Lost!"; - } else if ( - user_choice == "paper" && - computerChoiceNum[randomNumber] == "paper" - ) { + } else if (user_choice == "paper" && choices == "paper") { result = "You Tied!"; - } else if ( - user_choice == "scissors" && - computerChoiceNum[randomNumber] == "scissors" - ) { + } else if (user_choice == "scissors" && choices == "scissors") { result = "You Tied!"; - } else if ( - user_choice == "scissors" && - computerChoiceNum[randomNumber] == "rock" - ) { + } else if (user_choice == "scissors" && choices == "rock") { result = "You Lost!"; - } else if ( - user_choice == "scissors" && - computerChoiceNum[randomNumber] == "paper" - ) { + } else if (user_choice == "scissors" && choices == "paper") { result = "You Won!"; } else { $(".result").append(`

Your input is invalid, try again.

`); } - - // use 'result' + + for (totalWins = 0; totalWins <= totalGames;){ + totalWins = totalWins +1; + } + for (totalLoses = 0; totalLoses <= totalGames; ){ + totalLoses = totalLoses +1; + } + for (totalTies = 0; totalTies <= totalGames; ){ + totalTies = totalTies +1; +// move the writing out then just change the variable +} + + + // use 'result' + $(".ties").text("You have tied" + totalTies + "times"); + $(".loses").text("You have lost" + totalLoses + "times"); + $(".wins").text("You have won" + totalWins + "times"); $(".result").text(result); + $(".winRate").text("Your win rate is" + winRate + "percent"); + $(".games").text("You have played" + totalGames + "times"); }); From c192d8f02834b8e7977d90f71c61fa6acbadec30 Mon Sep 17 00:00:00 2001 From: "Glitch (rock-paper-scissors-proje)" Date: Sat, 11 Dec 2021 03:17:09 +0000 Subject: [PATCH 6/8] =?UTF-8?q?=F0=9F=8F=8B=F0=9F=8D=94=20Updated=20with?= =?UTF-8?q?=20Glitch?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- js/script.js | 38 +++++++++++++++++--------------------- 1 file changed, 17 insertions(+), 21 deletions(-) diff --git a/js/script.js b/js/script.js index a76af69b..ea5bae39 100644 --- a/js/script.js +++ b/js/script.js @@ -3,8 +3,6 @@ let totalWins = 0; let totalTies = 0; let totalLoses = 0; let totalGames = 0; -let winRate = totalWins / totalGames; - // Thunpitcha's function // Docs: https://docs.google.com/document/d/1gq7oUif59sKDInbJrDTIeSQBaOlGb5ri06b2-noWWNI/edit#heading=h.x4lnrrw34ze2 @@ -32,7 +30,6 @@ $(".clear").click(function() { }); $(".play").click(function() { - let result; totalGames = totalGames + 1; @@ -48,44 +45,43 @@ $(".play").click(function() { if (user_choice == "rock" && choices == "scissors") { result = "You Won!"; + totalWins = totalWins + 1; } else if (user_choice == "rock" && choices == "rock") { result = "You Tied!"; + totalTies = totalTies + 1; } else if (user_choice == "rock" && choices == "paper") { result = "You Lost!"; + totalLoses = totalLoses + 1; } else if (user_choice == "paper" && choices == "rock") { result = "You Won!"; + totalWins = totalWins + 1; } else if (user_choice == "paper" && choices == "scissors") { result = "You Lost!"; + totalLoses = totalLoses + 1; } else if (user_choice == "paper" && choices == "paper") { result = "You Tied!"; + totalTies = totalTies + 1; } else if (user_choice == "scissors" && choices == "scissors") { result = "You Tied!"; + totalTies = totalTies + 1; } else if (user_choice == "scissors" && choices == "rock") { result = "You Lost!"; + totalLoses = totalLoses + 1; } else if (user_choice == "scissors" && choices == "paper") { result = "You Won!"; + totalWins = totalWins + 1; } else { $(".result").append(`

Your input is invalid, try again.

`); } - - for (totalWins = 0; totalWins <= totalGames;){ - totalWins = totalWins +1; - } - for (totalLoses = 0; totalLoses <= totalGames; ){ - totalLoses = totalLoses +1; - } - for (totalTies = 0; totalTies <= totalGames; ){ - totalTies = totalTies +1; -// move the writing out then just change the variable -} - - - // use 'result' - $(".ties").text("You have tied" + totalTies + "times"); - $(".loses").text("You have lost" + totalLoses + "times"); - $(".wins").text("You have won" + totalWins + "times"); + let winRate = totalWins / totalGames; + winRate = winRate.toFixed(2); + + // use 'result' + $(".ties").text("You have tied" + totalTies + "times"); + $(".loses").text("You have lost" + totalLoses + "times"); + $(".wins").text("You have won" + totalWins + "times"); $(".result").text(result); - $(".winRate").text("Your win rate is" + winRate + "percent"); $(".games").text("You have played" + totalGames + "times"); + $(".winRate").text("Your win rate is" + winRate + "percent"); }); From b8553b67fdea5b48076d1e8994a52e0699121fc0 Mon Sep 17 00:00:00 2001 From: "Glitch (rock-paper-scissors-proje)" Date: Wed, 15 Dec 2021 23:33:07 +0000 Subject: [PATCH 7/8] =?UTF-8?q?=F0=9F=9A=90=F0=9F=8C=83=20Updated=20with?= =?UTF-8?q?=20Glitch?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .glitch-assets | 14 ++++++ css/style.css | 36 ++++++++++++++ index.html | 9 ++++ js/script.js | 131 +++++++++++++++++++++++++++++++------------------ 4 files changed, 143 insertions(+), 47 deletions(-) diff --git a/.glitch-assets b/.glitch-assets index e69de29b..e537de02 100644 --- a/.glitch-assets +++ b/.glitch-assets @@ -0,0 +1,14 @@ +{"name":"paper-removebg-preview.png","date":"2021-12-15T22:39:04.543Z","url":"https://cdn.glitch.me/19eb4570-f75b-462d-a5e0-d2b8108fa4bf/paper-removebg-preview.png","type":"image/png","size":28410,"imageWidth":287,"imageHeight":217,"thumbnail":"https://cdn.glitch.me/19eb4570-f75b-462d-a5e0-d2b8108fa4bf/paper-removebg-preview.png","thumbnailWidth":287,"thumbnailHeight":217,"uuid":"yNvSYfSXJszebF2e"} +{"name":"paper.jpg","date":"2021-12-15T22:39:22.546Z","url":"https://cdn.glitch.me/19eb4570-f75b-462d-a5e0-d2b8108fa4bf/paper.jpg","type":"image/jpeg","size":11943,"imageWidth":287,"imageHeight":217,"thumbnail":"https://cdn.glitch.me/19eb4570-f75b-462d-a5e0-d2b8108fa4bf/paper.jpg","thumbnailWidth":287,"thumbnailHeight":217,"uuid":"vUCjKYBtYQpMwi7r"} +{"uuid":"vUCjKYBtYQpMwi7r","deleted":true} +{"name":"rock-removebg-preview.png","date":"2021-12-15T22:40:35.283Z","url":"https://cdn.glitch.me/19eb4570-f75b-462d-a5e0-d2b8108fa4bf/rock-removebg-preview.png","type":"image/png","size":18580,"imageWidth":207,"imageHeight":220,"thumbnail":"https://cdn.glitch.me/19eb4570-f75b-462d-a5e0-d2b8108fa4bf/rock-removebg-preview.png","thumbnailWidth":207,"thumbnailHeight":220,"uuid":"7PkQoHXP2IkbcViZ"} +{"name":"Screenshot_2021-12-08_181708-removebg-preview (1).png","date":"2021-12-15T22:40:43.065Z","url":"https://cdn.glitch.me/19eb4570-f75b-462d-a5e0-d2b8108fa4bf/Screenshot_2021-12-08_181708-removebg-preview%20(1).png","type":"image/png","size":22995,"imageWidth":236,"imageHeight":182,"thumbnail":"https://cdn.glitch.me/19eb4570-f75b-462d-a5e0-d2b8108fa4bf/Screenshot_2021-12-08_181708-removebg-preview%20(1).png","thumbnailWidth":236,"thumbnailHeight":182,"uuid":"yEpblEdvsWjfokyt"} +{"name":"download.png","date":"2021-12-15T22:42:39.362Z","url":"https://cdn.glitch.me/19eb4570-f75b-462d-a5e0-d2b8108fa4bf/download.png","type":"image/png","size":22153,"imageWidth":207,"imageHeight":220,"thumbnail":"https://cdn.glitch.me/19eb4570-f75b-462d-a5e0-d2b8108fa4bf/download.png","thumbnailWidth":207,"thumbnailHeight":220,"uuid":"8vikUtqci0bj2tzB"} +{"name":"paper-removebg-preview (1).png","date":"2021-12-15T22:43:44.611Z","url":"https://cdn.glitch.me/19eb4570-f75b-462d-a5e0-d2b8108fa4bf/paper-removebg-preview%20(1).png","type":"image/png","size":21576,"imageWidth":287,"imageHeight":217,"thumbnail":"https://cdn.glitch.me/19eb4570-f75b-462d-a5e0-d2b8108fa4bf/paper-removebg-preview%20(1).png","thumbnailWidth":287,"thumbnailHeight":217,"uuid":"gbPC3NDrtyaGJZcn"} +{"uuid":"gbPC3NDrtyaGJZcn","deleted":true} +{"name":"paper-removebg-preview__1_-removebg-preview.png","date":"2021-12-15T22:44:00.299Z","url":"https://cdn.glitch.me/19eb4570-f75b-462d-a5e0-d2b8108fa4bf/paper-removebg-preview__1_-removebg-preview.png","type":"image/png","size":22752,"imageWidth":287,"imageHeight":217,"thumbnail":"https://cdn.glitch.me/19eb4570-f75b-462d-a5e0-d2b8108fa4bf/paper-removebg-preview__1_-removebg-preview.png","thumbnailWidth":287,"thumbnailHeight":217,"uuid":"nosqiEuBxet8iWzb"} +{"uuid":"8vikUtqci0bj2tzB","deleted":true} +{"name":"rock-removebg-preview__1_-removebg-preview.png","date":"2021-12-15T22:45:55.384Z","url":"https://cdn.glitch.me/19eb4570-f75b-462d-a5e0-d2b8108fa4bf/rock-removebg-preview__1_-removebg-preview.png","type":"image/png","size":15433,"imageWidth":206,"imageHeight":220,"thumbnail":"https://cdn.glitch.me/19eb4570-f75b-462d-a5e0-d2b8108fa4bf/rock-removebg-preview__1_-removebg-preview.png","thumbnailWidth":206,"thumbnailHeight":220,"uuid":"VIsfnVhb0TeT1v50"} +{"name":"Screenshot_2021-12-08_181708-removebg-preview__1_-removebg-preview.png","date":"2021-12-15T22:48:17.402Z","url":"https://cdn.glitch.me/19eb4570-f75b-462d-a5e0-d2b8108fa4bf/Screenshot_2021-12-08_181708-removebg-preview__1_-removebg-preview.png","type":"image/png","size":19011,"imageWidth":236,"imageHeight":182,"thumbnail":"https://cdn.glitch.me/19eb4570-f75b-462d-a5e0-d2b8108fa4bf/Screenshot_2021-12-08_181708-removebg-preview__1_-removebg-preview.png","thumbnailWidth":236,"thumbnailHeight":182,"uuid":"atiNLgfYfFqOOVOj"} +{"name":"download-removebg-preview.png","date":"2021-12-15T22:49:22.696Z","url":"https://cdn.glitch.me/19eb4570-f75b-462d-a5e0-d2b8108fa4bf/download-removebg-preview.png","type":"image/png","size":15313,"imageWidth":206,"imageHeight":220,"thumbnail":"https://cdn.glitch.me/19eb4570-f75b-462d-a5e0-d2b8108fa4bf/download-removebg-preview.png","thumbnailWidth":206,"thumbnailHeight":220,"uuid":"BtFyFvcffe1e6m8X"} +{"uuid":"7PkQoHXP2IkbcViZ","deleted":true} diff --git a/css/style.css b/css/style.css index bc6701af..c9fcc269 100644 --- a/css/style.css +++ b/css/style.css @@ -5,3 +5,39 @@ display: flex; justify-content: space-between; } + +.userPaper { + display: none; +} + +.computerPaper { + display: none; +} + +.userScissor { + display: none; +} + +.computerScissor { + display: none; +} + +.userRock { + display: none; +} + +.computerRock { + display: none; +} + +@keyframes moveUpanDown { + 0% { +/* transform: translateY(where ever this is in pixels); */ + } + 50%{ +/* transform: translateY(whenever this goes down) ; */ + } + 100%{ +/* transform: translateY(goes back up to origin); */ + } +} \ No newline at end of file diff --git a/index.html b/index.html index f5e57fc7..74a07a2d 100644 --- a/index.html +++ b/index.html @@ -24,10 +24,19 @@

Please Submit Your Choice Below

User Choice

+ + + + +

Computer Choice

+ + + +

diff --git a/js/script.js b/js/script.js index ea5bae39..f0b9c267 100644 --- a/js/script.js +++ b/js/script.js @@ -1,11 +1,8 @@ -let computerChoiceNum = ["rock", "paper", "scissors"]; let totalWins = 0; let totalTies = 0; let totalLoses = 0; let totalGames = 0; -// Thunpitcha's function -// Docs: https://docs.google.com/document/d/1gq7oUif59sKDInbJrDTIeSQBaOlGb5ri06b2-noWWNI/edit#heading=h.x4lnrrw34ze2 function getRandomComputerChoice() { let randomNumber = Math.floor(Math.random() * 3); @@ -30,58 +27,98 @@ $(".clear").click(function() { }); $(".play").click(function() { - let result; - totalGames = totalGames + 1; + + // what ever this is.style.animation="moveUpandDown 3s linear infinite" - let choices = getRandomComputerChoice(); - - let user_choice = $(".input").val(); - - $(".userChoice").text(user_choice); - - user_choice = user_choice.toLowerCase(); - - $(".computerChoice").text(choices); - - if (user_choice == "rock" && choices == "scissors") { - result = "You Won!"; - totalWins = totalWins + 1; - } else if (user_choice == "rock" && choices == "rock") { - result = "You Tied!"; - totalTies = totalTies + 1; - } else if (user_choice == "rock" && choices == "paper") { - result = "You Lost!"; - totalLoses = totalLoses + 1; - } else if (user_choice == "paper" && choices == "rock") { - result = "You Won!"; - totalWins = totalWins + 1; - } else if (user_choice == "paper" && choices == "scissors") { - result = "You Lost!"; - totalLoses = totalLoses + 1; - } else if (user_choice == "paper" && choices == "paper") { - result = "You Tied!"; - totalTies = totalTies + 1; - } else if (user_choice == "scissors" && choices == "scissors") { - result = "You Tied!"; - totalTies = totalTies + 1; - } else if (user_choice == "scissors" && choices == "rock") { - result = "You Lost!"; - totalLoses = totalLoses + 1; - } else if (user_choice == "scissors" && choices == "paper") { - result = "You Won!"; - totalWins = totalWins + 1; - } else { - $(".result").append(`

Your input is invalid, try again.

`); + function userChoice(user_choices) { + user_choices = $(".input").val(); + $(".userChoice").text(user_choices); + + user_choices = user_choices.toLowerCase(); + return user_choices; } + function chooseWinner(user_choice, computer_choice) { + let result; + + computer_choice = getRandomComputerChoice(); + + user_choice = userChoice(); + + if (user_choice === "rock") { + $(".userRock").show(); + $(".userScissor").hide(); + $(".userPaper").hide(); + } else if (user_choice === "paper") { + $(".userPaper").show(); + $(".userScissor").hide(); + $(".userRock").hide(); + } else { + $(".userScissor").show(); + $(".userPaper").hide(); + $(".userRock").hide(); + } + + if (computer_choice === "rock") { + $(".computerRock").show(); + $(".computerScissor").hide(); + $(".computerPaper").hide(); + } else if (computer_choice === "paper") { + $(".computerPaper").show(); + $(".computerScissor").hide(); + $(".computerRock").hide(); + } else { + $(".computerScissor").show(); + $(".computerRock").hide(); + $(".computerPaper").hide(); + } + console.log(user_choice); + + $(".computerChoice").text(computer_choice); + // console.log(userChoice()); + + if (user_choice == "rock" && computer_choice == "scissors") { + result = "User Wins!"; + totalWins = totalWins + 1; + } else if (user_choice == "rock" && computer_choice == "rock") { + result = "You Tied, no one wins!"; + totalTies = totalTies + 1; + } else if (user_choice == "rock" && computer_choice == "paper") { + result = "You Lost, Computer Wins!"; + totalLoses = totalLoses + 1; + } else if (user_choice == "paper" && computer_choice == "rock") { + result = "User Wins!"; + totalWins = totalWins + 1; + } else if (user_choice == "paper" && computer_choice == "scissors") { + result = "You Lost, Computer Wins!"; + totalLoses = totalLoses + 1; + } else if (user_choice == "paper" && computer_choice == "paper") { + result = "You Tied, no one wins!"; + totalTies = totalTies + 1; + } else if (user_choice == "scissors" && computer_choice == "scissors") { + result = "You Tied, no one wins!"; + totalTies = totalTies + 1; + } else if (user_choice == "scissors" && computer_choice == "rock") { + result = "You Lost, Computer Wins!"; + totalLoses = totalLoses + 1; + } else if (user_choice == "scissors" && computer_choice == "paper") { + result = "User Wins!"; + totalWins = totalWins + 1; + } else { + $(".result").append(`

Your input is invalid, try again.

`); + } + + return $(".result").text(result); + // use 'result' + } + totalGames = totalGames + 1; let winRate = totalWins / totalGames; winRate = winRate.toFixed(2); - - // use 'result' $(".ties").text("You have tied" + totalTies + "times"); $(".loses").text("You have lost" + totalLoses + "times"); $(".wins").text("You have won" + totalWins + "times"); - $(".result").text(result); + $(".games").text("You have played" + totalGames + "times"); $(".winRate").text("Your win rate is" + winRate + "percent"); + chooseWinner(); }); From 50d83c91e66ac97f16377a76d35f1909e1691cff Mon Sep 17 00:00:00 2001 From: "Glitch (rock-paper-scissors-proje)" Date: Wed, 12 Jan 2022 22:02:56 +0000 Subject: [PATCH 8/8] =?UTF-8?q?=E2=9B=B3=E2=98=91=EF=B8=8F=20Updated=20wit?= =?UTF-8?q?h=20Glitch?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .glitch-assets | 3 + css/style.css | 24 +++++++ index.html | 1 + js/script.js | 167 +++++++++++++++++++++++++------------------------ 4 files changed, 112 insertions(+), 83 deletions(-) diff --git a/.glitch-assets b/.glitch-assets index e537de02..71d849a7 100644 --- a/.glitch-assets +++ b/.glitch-assets @@ -12,3 +12,6 @@ {"name":"Screenshot_2021-12-08_181708-removebg-preview__1_-removebg-preview.png","date":"2021-12-15T22:48:17.402Z","url":"https://cdn.glitch.me/19eb4570-f75b-462d-a5e0-d2b8108fa4bf/Screenshot_2021-12-08_181708-removebg-preview__1_-removebg-preview.png","type":"image/png","size":19011,"imageWidth":236,"imageHeight":182,"thumbnail":"https://cdn.glitch.me/19eb4570-f75b-462d-a5e0-d2b8108fa4bf/Screenshot_2021-12-08_181708-removebg-preview__1_-removebg-preview.png","thumbnailWidth":236,"thumbnailHeight":182,"uuid":"atiNLgfYfFqOOVOj"} {"name":"download-removebg-preview.png","date":"2021-12-15T22:49:22.696Z","url":"https://cdn.glitch.me/19eb4570-f75b-462d-a5e0-d2b8108fa4bf/download-removebg-preview.png","type":"image/png","size":15313,"imageWidth":206,"imageHeight":220,"thumbnail":"https://cdn.glitch.me/19eb4570-f75b-462d-a5e0-d2b8108fa4bf/download-removebg-preview.png","thumbnailWidth":206,"thumbnailHeight":220,"uuid":"BtFyFvcffe1e6m8X"} {"uuid":"7PkQoHXP2IkbcViZ","deleted":true} +{"name":"images.jpg","date":"2022-01-05T23:01:59.601Z","url":"https://cdn.glitch.global/19eb4570-f75b-462d-a5e0-d2b8108fa4bf/images.jpg","type":"image/jpeg","size":1266,"imageWidth":262,"imageHeight":192,"thumbnail":"https://cdn.glitch.global/19eb4570-f75b-462d-a5e0-d2b8108fa4bf/images.jpg","thumbnailWidth":262,"thumbnailHeight":192,"uuid":"3TTNY4QUWOwJQbij"} +{"name":"High_resolution_wallpaper_background_ID_77700451514-692x376.jpg","date":"2022-01-05T23:05:13.382Z","url":"https://cdn.glitch.global/19eb4570-f75b-462d-a5e0-d2b8108fa4bf/High_resolution_wallpaper_background_ID_77700451514-692x376.jpg","type":"image/jpeg","size":11821,"imageWidth":692,"imageHeight":376,"thumbnail":"https://cdn.glitch.global/19eb4570-f75b-462d-a5e0-d2b8108fa4bf/thumbnails%2FHigh_resolution_wallpaper_background_ID_77700451514-692x376.jpg","thumbnailWidth":330,"thumbnailHeight":180,"uuid":"nL5A6nwgkeqhp7kM"} +{"name":"xF4zkp.jpg","date":"2022-01-05T23:13:01.520Z","url":"https://cdn.glitch.global/19eb4570-f75b-462d-a5e0-d2b8108fa4bf/xF4zkp.jpg","type":"image/jpeg","size":499661,"imageWidth":1680,"imageHeight":1050,"thumbnail":"https://cdn.glitch.global/19eb4570-f75b-462d-a5e0-d2b8108fa4bf/thumbnails%2FxF4zkp.jpg","thumbnailWidth":330,"thumbnailHeight":207,"uuid":"OBGDLJsCCgm9it0p"} diff --git a/css/style.css b/css/style.css index c9fcc269..a242ebbe 100644 --- a/css/style.css +++ b/css/style.css @@ -1,5 +1,6 @@ .row { text-align: center; + font-family: 'Nanum Gothic', sans-serif; } .choices { display: flex; @@ -8,28 +9,51 @@ .userPaper { display: none; + width: 200px; + height: 200px; } .computerPaper { display: none; + width: 200px; + height: 200px; } .userScissor { display: none; + width: 200px; + height: 200px; } .computerScissor { display: none; + width: 200px; + height: 200px; } .userRock { display: none; + width: 200px; + height: 200px; } .computerRock { display: none; + width: 200px; + height: 200px; } +body { + background: url("https://cdn.glitch.global/19eb4570-f75b-462d-a5e0-d2b8108fa4bf/High_resolution_wallpaper_background_ID_77700451514-692x376.jpg?v=1641423913382"); + background-size: cover; + background-repeat: no-repeat; +} + +html { + height: 100%; +} + + @keyframes moveUpanDown { 0% { /* transform: translateY(where ever this is in pixels); */ diff --git a/index.html b/index.html index 74a07a2d..feeb4ad7 100644 --- a/index.html +++ b/index.html @@ -5,6 +5,7 @@ + diff --git a/js/script.js b/js/script.js index f0b9c267..00f3bc98 100644 --- a/js/script.js +++ b/js/script.js @@ -19,98 +19,98 @@ function getRandomComputerChoice() { return choice; // value = "rock", "paper", "scissors" } -$(".clear").click(function() { +$(".clear").click(function () { $(".input").val(""); $(".userChoice").text(""); $(".result").text(""); $(".computerChoice").text(""); }); -$(".play").click(function() { - - // what ever this is.style.animation="moveUpandDown 3s linear infinite" +function userChoice(user_choices) { + user_choices = $(".input").val(); + $(".userChoice").text(user_choices); - function userChoice(user_choices) { - user_choices = $(".input").val(); - $(".userChoice").text(user_choices); + user_choices = user_choices.toLowerCase(); + return user_choices; +} +function chooseWinner(user_choice, computer_choice) { + let result; + + if (user_choice === "rock") { + $(".userRock").show(); + $(".userScissor").hide(); + $(".userPaper").hide(); + } else if (user_choice === "paper") { + $(".userPaper").show(); + $(".userScissor").hide(); + $(".userRock").hide(); + } else { + $(".userScissor").show(); + $(".userPaper").hide(); + $(".userRock").hide(); + } - user_choices = user_choices.toLowerCase(); - return user_choices; + if (computer_choice === "rock") { + $(".computerRock").show(); + $(".computerScissor").hide(); + $(".computerPaper").hide(); + } else if (computer_choice === "paper") { + $(".computerPaper").show(); + $(".computerScissor").hide(); + $(".computerRock").hide(); + } else { + $(".computerScissor").show(); + $(".computerRock").hide(); + $(".computerPaper").hide(); } - function chooseWinner(user_choice, computer_choice) { - let result; - - computer_choice = getRandomComputerChoice(); - - user_choice = userChoice(); - - if (user_choice === "rock") { - $(".userRock").show(); - $(".userScissor").hide(); - $(".userPaper").hide(); - } else if (user_choice === "paper") { - $(".userPaper").show(); - $(".userScissor").hide(); - $(".userRock").hide(); - } else { - $(".userScissor").show(); - $(".userPaper").hide(); - $(".userRock").hide(); - } - - if (computer_choice === "rock") { - $(".computerRock").show(); - $(".computerScissor").hide(); - $(".computerPaper").hide(); - } else if (computer_choice === "paper") { - $(".computerPaper").show(); - $(".computerScissor").hide(); - $(".computerRock").hide(); - } else { - $(".computerScissor").show(); - $(".computerRock").hide(); - $(".computerPaper").hide(); - } - - console.log(user_choice); - - $(".computerChoice").text(computer_choice); - // console.log(userChoice()); - - if (user_choice == "rock" && computer_choice == "scissors") { - result = "User Wins!"; - totalWins = totalWins + 1; - } else if (user_choice == "rock" && computer_choice == "rock") { - result = "You Tied, no one wins!"; - totalTies = totalTies + 1; - } else if (user_choice == "rock" && computer_choice == "paper") { - result = "You Lost, Computer Wins!"; - totalLoses = totalLoses + 1; - } else if (user_choice == "paper" && computer_choice == "rock") { - result = "User Wins!"; - totalWins = totalWins + 1; - } else if (user_choice == "paper" && computer_choice == "scissors") { - result = "You Lost, Computer Wins!"; - totalLoses = totalLoses + 1; - } else if (user_choice == "paper" && computer_choice == "paper") { - result = "You Tied, no one wins!"; - totalTies = totalTies + 1; - } else if (user_choice == "scissors" && computer_choice == "scissors") { - result = "You Tied, no one wins!"; - totalTies = totalTies + 1; - } else if (user_choice == "scissors" && computer_choice == "rock") { - result = "You Lost, Computer Wins!"; - totalLoses = totalLoses + 1; - } else if (user_choice == "scissors" && computer_choice == "paper") { - result = "User Wins!"; - totalWins = totalWins + 1; - } else { - $(".result").append(`

Your input is invalid, try again.

`); - } - - return $(".result").text(result); - // use 'result' + + console.log(user_choice); + + $(".computerChoice").text(computer_choice); + // console.log(userChoice()); + + if (user_choice == "rock" && computer_choice == "scissors") { + result = "User Wins!"; + totalWins = totalWins + 1; + } else if (user_choice == "rock" && computer_choice == "rock") { + result = "You Tied, no one wins!"; + totalTies = totalTies + 1; + } else if (user_choice == "rock" && computer_choice == "paper") { + result = "You Lost, Computer Wins!"; + totalLoses = totalLoses + 1; + } else if (user_choice == "paper" && computer_choice == "rock") { + result = "User Wins!"; + totalWins = totalWins + 1; + } else if (user_choice == "paper" && computer_choice == "scissors") { + result = "You Lost, Computer Wins!"; + totalLoses = totalLoses + 1; + } else if (user_choice == "paper" && computer_choice == "paper") { + result = "You Tied, no one wins!"; + totalTies = totalTies + 1; + } else if (user_choice == "scissors" && computer_choice == "scissors") { + result = "You Tied, no one wins!"; + totalTies = totalTies + 1; + } else if (user_choice == "scissors" && computer_choice == "rock") { + result = "You Lost, Computer Wins!"; + totalLoses = totalLoses + 1; + } else if (user_choice == "scissors" && computer_choice == "paper") { + result = "User Wins!"; + totalWins = totalWins + 1; + } else { + $(".result").append(`

Your input is invalid, try again.

`); } + + $(".result").text(result); + // use 'result' +} + +$(".play").click(function () { + // what ever this is.style.animation="moveUpandDown 3s linear infinite" + + let computer_choice = getRandomComputerChoice(); + + let user_choice = userChoice(); + totalGames = totalGames + 1; let winRate = totalWins / totalGames; winRate = winRate.toFixed(2); @@ -120,5 +120,6 @@ $(".play").click(function() { $(".games").text("You have played" + totalGames + "times"); $(".winRate").text("Your win rate is" + winRate + "percent"); - chooseWinner(); + + chooseWinner(user_choice, computer_choice); });