forked from makersacademy/rps-challenge-apprenticeships
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.rb
47 lines (36 loc) · 670 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
45
46
47
require 'sinatra/base'
require './lib/computer'
require './lib/game'
require './lib/player'
class RockPaperScissors < Sinatra::Base
enable :session
get '/test' do
'test page'
end
before do
@game = Game.instance
end
get '/' do
erb(:index)
end
post '/name' do
player = Player.new(params[:name])
@game = Game.create(player)
redirect '/play'
end
get '/play' do
erb :play
end
post '/weapon' do
@game.player.weapon = params[:weapon]
redirect('/result')
end
get '/result' do
@game.computer.choose_weapon
erb(:result)
end
get '/thanks' do
erb(:thanks)
end
run! if app_file == $0
end