Skip to content

Russells - Rock/Paper/Scissors Challenge#2110

Open
Rmorbey wants to merge 5 commits into
makersacademy:mainfrom
Rmorbey:main
Open

Russells - Rock/Paper/Scissors Challenge#2110
Rmorbey wants to merge 5 commits into
makersacademy:mainfrom
Rmorbey:main

Conversation

@Rmorbey
Copy link
Copy Markdown

@Rmorbey Rmorbey commented May 8, 2022

First Two User Stories Complete.

If I had more time I would:

  • make it look nicer
  • add multiplayer

Refactored in newest commit

  • Changed how my rule engine works, I initially found a way to do it while watching a youtube video. I decided to change it to a Case statement because I wasn't getting the correct outcomes. I also wanted to refactor it my way.
  • Successfully added spock/lizard special rules
  • It now outputs what the player and the robot chose on the results page, so you can verify the outcome of the match.

Copy link
Copy Markdown

@eoinmakers eoinmakers left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work on this! You've achieved the user stories and learning objectives of the week. There's a good range of both feature and unit tests.

Fully comprehensive unit testing would cover every possible combination of the game rules - which sounds long, but would provide 100% test coverage.

There's an opportunity to do some refactoring to reduce duplication of code - see inline comments.

Comment thread app.rb
@robot_guess = nil
@pvr_results = nil
redirect '/pvr'
end
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You trigger a different route depending on what move the player chooses, and each of these routes runs the same five lines of code - there's an opportunity here to re-use existing code, keeping your implementation DRY.

An alternative approach would pass the player's chosen move as a param instead, then passing this into sessions or an instance of Player, for example.

@computer_guess == :spock && @guess == :scissors ||
@computer_guess == :spock && @guess == :rock
'Robot wins'
end
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are a few approaches to the this game logic, and although your logic is easy to read, an alternative approach could be more concise: https://github.com/makersacademy/rps-challenge/blob/main/docs/review.md#use-of-ifelsif-conditionals-for-business-logic

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants