Skip to main content

Part 5: Game Logic

  1. Create a state to manage which View to display. You can use a boolean value to manage this state.
  2. pass the stateModifier as a prop to the WelcomeView component and use it to update the state when the user clicks the Start Game button.
  3. Use the state to conditionally render the WelcomeView or the GameView component.
  • you can use the ternary operator .. ? .. : .. to conditionally render the WelcomeView or the GameView components.
  1. Copy over the RockPaperScissors class from the previous assignment and import it into the GameView component. The RockPaperScissors class will be used to handle the game logic and determine the winner of the game.
  2. Create different state hooks to manage the game state and the user's choice.
  • userChoice
  • userScore
  • cpuScore
  • gameHistory (an array to store the history of the game)

You will need to update those state values on Go click.

::: info This covers the big components of what we need to work on. Use those concepts to finish the game logic. :::