forked from makersacademy/rps-challenge-apprenticeships
-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.rb
44 lines (34 loc) · 766 Bytes
/
app.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
require 'sinatra/base'
require 'sinatra/reloader'
require_relative './lib/game'
class RockPaperScissors < Sinatra::Base
enable :sessions
configure :development do
register Sinatra::Reloader
end
get '/test' do
'test page'
end
get '/' do
erb :index
end
post '/name-registered' do
session[:player_name] = params[:name]
redirect '/play'
end
get '/play' do
@player_name = session[:player_name]
erb :play
end
post '/player-choice' do
session[:player_choice] = params[:player_choice]
redirect '/outcome'
end
get '/outcome' do
new_game = Game.new(session[:player_choice])
@outcome = new_game.run_game
@game_choice = new_game.game_turn
erb :outcome
end
run! if app_file == $0
end