Open
Conversation
…ore running the game
Contributor
alicelieutier
left a comment
There was a problem hiding this comment.
Good challenge, and nice to see you reached some stretch goals.
You can improve the separation of concern between Model/Views/Controller even more.
Comment on lines
+30
to
+38
| get '/play' do | ||
| @player_one = $player_one | ||
| @player_two = $player_two | ||
| if @player_two.name == 'computer' | ||
| erb :play | ||
| else | ||
| erb :pvp_play | ||
| end | ||
| end |
Contributor
There was a problem hiding this comment.
This logic would be better in the model.
Author
There was a problem hiding this comment.
Thanks for the feedback, really useful :)
Comment on lines
+13
to
+25
| def run_vs_ai | ||
| if @player_one.choice == @ai_choice | ||
| return "It's a draw!" | ||
| elsif @player_one.choice == "rock" && @ai_choice == "scissors" | ||
| return "#{@player_one.name} wins!" | ||
| elsif @player_one.choice == "paper" && @ai_choice == "rock" | ||
| return "#{@player_one.name} wins!" | ||
| elsif @player_one.choice == "scissors" && @ai_choice == "paper" | ||
| return "#{@player_one.name} wins!" | ||
| else | ||
| return "You lose!" | ||
| end | ||
| end |
Contributor
There was a problem hiding this comment.
You are mixing presentation (the sentence used) and logic (who wins) here. It would be better to have the model/this file just handle the logic, and let the view handle the presentation.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Play Rock, Paper, Scissors vs the computer or another person