SPS2 editted#359
Open
GeoBanico wants to merge 1 commit into
Open
Conversation
gcskhor
reviewed
Jun 16, 2022
gcskhor
left a comment
There was a problem hiding this comment.
appropriately named variables and comments made your code easy to understand. Overall, very well done!
gcskhor
reviewed
Jun 16, 2022
Comment on lines
+160
to
+214
| if (gameMode_Current == gameMode_Name) { | ||
| userName = input; | ||
| gameMode_Current = gameMode_GameSel; //change game mode to game select | ||
| return `Welcome ${userName}. <br><br> | ||
| Please select a gamemode: <br> | ||
| -type 'rps' for Rock-Paper-Scissors<br> | ||
| -type 'rev' for reverse Rock-Paper-Scissors`; | ||
| } else { | ||
| if (gameMode_Current == gameMode_GameSel) { | ||
| if (input.toLowerCase() == "rps") { | ||
| gameMode_Current = gameMode_RPS; | ||
| return "Game Mode: Rock-Paper-Scissors<br> Type r|rock, p|paper, s|scissors"; | ||
| } else if (input.toLowerCase() == "rev") { | ||
| gameMode_Current = gameMode_Reverse; | ||
| return "Game Mode: Reverse Rock-Paper-Scissors<br> Type r|rock, p|paper, s|scissors"; | ||
| } else | ||
| return `Hi ${userName}, please enter a game mode. <br> | ||
| -type 'rps' for Rock-Paper-Scissors<br> | ||
| -type 'rev' for reverse Rock-Paper-Scissors`; | ||
| } | ||
| //game proper | ||
| else { | ||
| //game mode: change name | ||
| if (input.toLowerCase() == "name") { | ||
| gameMode_Current = gameMode_Name; | ||
| return `Game Mode: Naming<br> | ||
| Please Enter your name.`; | ||
| } | ||
| //game mode: change mode to rps | ||
| else if (input.toLowerCase() == "rps") { | ||
| if (gameMode_Current == gameMode_RPS) | ||
| return `Game Mode is already Rock-Paper-Scissors.<br> | ||
| Type r|rock, p|paper, s|scissors`; | ||
|
|
||
| gameMode_Current == gameMode_RPS; | ||
| return `Game Mode: Game Select<br> | ||
| Please Enter your game. <br> | ||
| -type 'rps' for Rock-Paper-Scissors<br> | ||
| -type 'rev' for reverse Rock-Paper-Scissors`; | ||
| } | ||
| //game mode: change mode to reverse | ||
| else if (input.toLowerCase() == "rev") { | ||
| if (gameMode_Current == gameMode_Reverse) | ||
| return `Game Mode is already Reverse Rock-Paper-Scissors.<br> | ||
| Type r|rock, p|paper, s|scissors`; | ||
|
|
||
| gameMode_Current == gameMode_Reverse; | ||
| return `Game Mode: Game Select<br> | ||
| Please Enter your game. <br> | ||
| -type 'rps' for Rock-Paper-Scissors<br> | ||
| -type 'rev' for reverse Rock-Paper-Scissors`; | ||
| } | ||
| //continue game | ||
| else return rpsGame(input); | ||
| } |
There was a problem hiding this comment.
You could also attempt the more advanced switch statement for a cleaner game mode selection in the main function:
https://www.w3schools.com/js/js_switch.asp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Please fill out the survey before submitting the pull request. Thanks!
🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀
How many hours did you spend on this assignment? 2-3hrs
Please fill in one error and/or error message you received while working on this assignment.
What part of the assignment did you spend the most time on? the game mode
Comfort Level (1-5): 4
Completeness Level (1-5): 4
What did you think of this deliverable? it is fair
Is there anything in this code that you feel pleased about? the game mode
What's one aspect of your code you would like specific, elaborate feedback on? none