Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Russells - Rock/Paper/Scissors Challenge #2110

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

Rmorbey
Copy link

@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

@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.

@robot_guess = nil
@pvr_results = nil
redirect '/pvr'
end

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

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