Skip to content

RPS Challenge - #2132

Open
abacus2020 wants to merge 2 commits into
makersacademy:mainfrom
abacus2020:main
Open

RPS Challenge#2132
abacus2020 wants to merge 2 commits into
makersacademy:mainfrom
abacus2020:main

Conversation

@abacus2020

Copy link
Copy Markdown

No description provided.

Comment thread app.rb

post '/name' do
session[:namegiven] = params[:username]
redirect '/play'

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Reasonable to see the separation of retrieving user input from displaying a new page.
I think it's a good thing.

Comment thread views/play.erb
@@ -0,0 +1,10 @@
<h1>Welcome <%= @name %> to Rock, Paper, Scissors <%= @name_1 %></h1>

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

@name_1 probably needs to be deleted

Comment thread views/result.erb
<h1>The computer played <%= @comp_selected %></h1>
<%if @tool_selected == @comp_selected %>
<h1>It is a draw</h1>
<%elsif @tool_selected == "paper" && @comp_selected == "rock" || @tool_selected == "rock" && @comp_selected == "scissors" || @tool_selected == "scissors" && @comp_selected == "paper" %>

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I would use a hash in winning conditions, because it's easier to edit later

Comment thread app.rb
@@ -0,0 +1,37 @@
require 'sinatra/base'

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Adding test cases would be easier for testing multiple times.

Comment thread views/result.erb
@@ -0,0 +1,9 @@
<h1>You played <%=@tool_selected%></h1>
<h1>The computer played <%= @comp_selected %></h1>

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Very nice to show both choices: user and computer. Good user experience, also good for testing.

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