Question: You will create a game based on the Rock, Paper, Scissors game you may have played in your childhood. The player in the game will
You will create a game based on the Rock, Paper, Scissors game you may have played in your childhood. The player in the game will compete against the computer. You will first display a welcome screen. The user will press a key to continue and will then be prompted to "make a move" by specifying rock R paper P or scissors S The player may also quit the game by entering the letter Q Once the player makes a move, the computer will make a move, determine the winner of that round, and display the result. The player will then be prompted to make another move. If the player enters anything other than R P S or Q a message will be displayed saying the selection is invalid. The game will end when the player enters a Q At that point, another message will be displayed, followed by another screen displaying the game statistics.
Overview:
At this point, you should have already followed the Part and Part to have a working script that allows the user to play the game one time. For Part you will edit and add on to the RockPaperScissors.ps script you have been working on
Steps for Part :
Create an outer while loop to control the game play, allowing the users to play the game until they enter a Q to quit the game. This should come immediately after the ReadHost cmdlet following the game's opening screen. The entire game should be inside this loop, so the beginning should be just before the random number assignment, and the closing should be at the very end at this point. In this loop, you will compare the variable controlling the game play to "False" ie the game will continue as long as this variable remains true.
You will need a second while loop just before you clear the screen and prompt the player to choose an option. Compare the variable holding the player's move to blank space; this is what it should have been initialized to when it was declared. As long as it continues to be display the instructions. The closing for the loop should be just before the validation of the player's move.
In the IF statement comparing the player's letter guess to Q add a "continue" as the last statement in the code block to skip the remainder of the loop. In the elseif comparing the player's letter guess R P or S add a "continue" as the last statement in the code block to skip the remainder of the loop.
At the end of the game's main while loop, just before the closing the variable values should be reset to their default values to be ready for a new round of play. Reset the following: variable storing numeric version of computer's move, variable storing the letter version of the player's move, variable storing the string word version of the computer's move, and the variable storing the string word version of the player's move.
$computerMoveNum #Variable to store the numeric version of the computer's move
$robotChoiceNum #Computer's numeric choice
$robotChoiceWord #Computer's Word choice
$playerChoiceWord #Player's Word choice
$playerChoiceLet #Player's letter choice
$tie #Variable to keep track of tied games
$gamePlay $true #To control gameplay
$gamesPlayed #Number of games played
$gamesLost #Variable to keep track of the number of games lost
$gamesWon #Variable to keep track of games won
#Clears screen before beginning, writes welcome message on screen
cls
Writehost "Welcome to the n n vRock Paper, Scissors Game"
Writehost n v vPress Enter to continue"
$player ReadHost
StartSleep seconds ; ReadHost
while $gamePlay $true
cls
#Chooses a random number between and ; Rock Paper Scissors
$robotChoiceNum GetRandom Minimum Maximum
#Sets number to matching word
if $robotChoiceNum eq
$robotChoiceWord "Rock"
if $robotChoiceNum eq
$robotChoiceWord "Paper"
if $robotChoiceNum eq
$robotChoiceWord "Scissors"
while $playerChoiceLet
cls
WriteHost "Enter one of the following options:
$dash
WriteHost $dashn
WriteHost R Rock nP Paper nS Scissors nQ Quitn
WriteHost $dashn
#WriteHost "Make a move
# Validate player's move
$playerChoiceLet ReadHost "Make a move"
if $playerChoiceLet eq Q
ClearHost
WriteHost "Thank you for playing!"
$gamePlay $true
continue #Skip the remainder of the loop
elseif $playerChoiceLet notin RPS
WriteHost "Invalid input. Please try again."
Can you correct my code its not working.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
