-
Notifications
You must be signed in to change notification settings - Fork 12
didnt finish #8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
didnt finish #8
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,17 +4,44 @@ var aiPoint = 0; | |
| // This function returns the selection of the computer | ||
| function getAISelection() { | ||
| //TODO: randomly choose between 'rock', 'paper', or 'scissors' | ||
| var random = Math.floor(Math.random * 3); | ||
| var choices = ["Rock", "Paper", "Scissors"]; | ||
| return choices[random]; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. awesome! just don't forget to invoke |
||
| } | ||
|
|
||
| // This function picks the winner | ||
| function pickWinner(userValue, aiValue) { | ||
| //TODO: pick the correct winner: user or ai | ||
| //TODO: Add one point for the winner | ||
| if(userValue == aiValue){ | ||
| return "draw"; | ||
| } else if(userValue == "Rock"){ | ||
| if(aiValue == "Paper"){ | ||
| return "cpu"; | ||
| } else { | ||
| return "user"; | ||
| } | ||
| } else if(userValue == "Paper"){ | ||
| if(aiValue == "Scissors"){ | ||
| return "cpu"; | ||
| } else { | ||
| return "user"; | ||
| } | ||
| } else if(userValue == "Scissors"){ | ||
| if(aiValue == "Rock"){ | ||
| return "cpu"; | ||
| } else { | ||
| return "user"; | ||
| } | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. slick |
||
| } | ||
| } | ||
|
|
||
| // This function sets the scoreboard with the correct points | ||
| function setScore() { | ||
|
|
||
| var userText = $('#userPoint'); | ||
| userText.text(userPoint); | ||
| var aiText = $('#aiPoint'); | ||
| aiText.text(aiPoint); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. very nice! but just cause i have to be a stickler, why store the element in a var if we're only using it once? |
||
| } | ||
|
|
||
| // This function captures the click and picks the winner | ||
|
|
@@ -26,14 +53,17 @@ function evaluate(evt) { | |
|
|
||
| if ( 'user' === winner ) { | ||
| $('#message').delay(50).text('You have won!, Click a box to play again'); | ||
| userPoint ++; | ||
| } else if ( winner === 'draw' ) { | ||
| $('#message').delay(50).text('Draw! Click a box to play again'); | ||
| } else { | ||
| $('#message').delay(50).text('You have lost!, Click a box to play again'); | ||
| aiPoint++; | ||
| } | ||
| setScore(); | ||
| } | ||
|
|
||
| // This function runs on page load | ||
| $(document).ready(function(){ | ||
|
|
||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. seems like you're only missing binding the |
||
| }); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,4 +17,8 @@ | |
| } | ||
| #message { | ||
| text-align: center; | ||
| } | ||
| .token img{ | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. noice! |
||
| width: 200px; | ||
| height: 200px; | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a
divwith avalueattribute? pour que?