The project consists of developing the game "Rock, Paper, Scissors". In the game both players have to make a Rock, Paper, Scissors. It has only two possible outcomes: a draw or a win for one player and a loss for the other player. The game is developed with JavaScript and one player will play against the computer.
The program generates a random move between paper, rock and scissors (the indications to generate the random move are below). After the user plays, the program compares the moves and decides whether the user has won, lost or tied against the computer. The program also counts the number of points of the player and the computer. The game is restarted after 10 moves.
- At the top, the player selects the move from the drop-down menu. The options are Rock, Paper, Scissors.
- Below, in the next section, the following texts appear:
- At the top of the page: Let's Play.
- When the player enters a move that matches the random move, the message: Tie is displayed.
- When the player enters a move that beats the random move the message: You Won! is displayed.
- When the player enters a move that fails to match the random move, the message: You lost!
- The points of each player should be displayed at the bottom.
To make the game we have to perform the following functionalities from JavaScript:
-
Create a minimal layout with the select, the space for the result and the space for the points of each player.
-
Generate a random number
-
Generate a random move and for that you can follow the following indications:
- if the random number generated in the previous step is less than 3 the move is stone if the random number generated is greater than or equal to 6 the move is paper.
- and if not, the movement generated is scissors.
-
Compare the move that the player has selected with the move that the computer has generated, and paint the corresponding clues on the screen.
-
Update the point counter at each move.
-
The game restarts when 10 moves are made.
-
The game ends when it reaches 10 moves, add the necessary code to display a Restart Game button that will restart the game when this condition is met and the Play button disappears.
-
When we click the Restart Game button, this button disappears, reset all the counters to zero and the Play button reappears.