-
Notifications
You must be signed in to change notification settings - Fork 250
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
base: main
Are you sure you want to change the base?
Conversation
…ore running the game
There was a problem hiding this 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.
get '/play' do | ||
@player_one = $player_one | ||
@player_two = $player_two | ||
if @player_two.name == 'computer' | ||
erb :play | ||
else | ||
erb :pvp_play | ||
end | ||
end |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 :)
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 |
There was a problem hiding this comment.
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.
Play Rock, Paper, Scissors vs the computer or another person