This repository has been archived by the owner on Dec 7, 2022. It is now read-only.
forked from makersacademy/rps-challenge
-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.rb
136 lines (113 loc) · 2.3 KB
/
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
require 'sinatra/base'
require './lib/game'
class RockPaperScissors < Sinatra::Base
enable :sessions
set :session_secret, "secret"
get '/' do
erb :index
end
post '/' do
redirect '/'
end
post '/single' do
erb :single
end
post '/play' do
@game = Game.new(Player.new(params[:name]))
session[:game] = @game
erb :play
end
get '/rock' do
@game = session[:game]
@game.player.choose("rock")
@game.generate_random
erb :rock
end
get '/paper' do
@game = session[:game]
@game.player.choose("paper")
@game.generate_random
erb :paper
end
get '/scissors' do
@game = session[:game]
@game.player.choose("scissors")
@game.generate_random
erb :scissors
end
post '/new-round' do
erb :'new-round'
end
post '/multi' do
erb :multi
end
post '/play-multi' do
@game = Game.new(Player.new(params[:player_1_name]), Player.new(params[:player_2_name]))
session[:game] = @game
erb :'play-multi'
end
get '/rock-multi' do
@game = session[:game]
@game.player.choose('rock')
erb :'rock-multi'
end
get '/rr' do
@game = session[:game]
@game.player_2.choose('rock')
erb :winner
end
get '/rs' do
@game = session[:game]
@game.player_2.choose('scissors')
erb :winner
end
get '/rp' do
@game = session[:game]
@game.player_2.choose('paper')
erb :winner
end
get '/scissors-multi' do
@game = session[:game]
@game.player.choose('scissors')
erb :'scissors-multi'
end
get '/sr' do
@game = session[:game]
@game.player_2.choose('rock')
erb :winner
end
get '/sp' do
@game = session[:game]
@game.player_2.choose('paper')
erb :winner
end
get '/ss' do
@game = session[:game]
@game.player_2.choose('scissors')
erb :winner
end
get '/paper-multi' do
@game = session[:game]
@game.player.choose('paper')
erb :'paper-multi'
end
get '/pr' do
@game = session[:game]
@game.player_2.choose('rock')
erb :winner
end
get '/pp' do
@game = session[:game]
@game.player_2.choose('paper')
erb :winner
end
get '/ps' do
@game = session[:game]
@game.player_2.choose('scissors')
erb :winner
end
post '/play-multi-again' do
@game = session[:game]
erb :'play-multi'
end
end