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

Jon Clarke - RPS challenge #232

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

Conversation

JonClarke84
Copy link

Play Rock, Paper, Scissors vs the computer or another person

Copy link
Contributor

@alicelieutier alicelieutier left a comment

Choose a reason for hiding this comment

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

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
Copy link
Contributor

Choose a reason for hiding this comment

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

This logic would be better in the model.

Copy link
Author

Choose a reason for hiding this comment

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

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
Copy link
Contributor

Choose a reason for hiding this comment

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

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.

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