Russells - Rock/Paper/Scissors Challenge#2110
Conversation
eoinmakers
left a comment
There was a problem hiding this comment.
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.
| @robot_guess = nil | ||
| @pvr_results = nil | ||
| redirect '/pvr' | ||
| end |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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
First Two User Stories Complete.
If I had more time I would:
Refactored in newest commit