forked from appdev-projects/sinatra-rps
-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.rb
52 lines (41 loc) · 791 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
48
49
50
51
52
require "sinatra"
require "sinatra/reloader"
get("/") do
erb(:homepage)
end
get("/rock") do
moves=["rock", "paper", "scissors"]
@comp_move = moves.sample
if @comp_move == "rock"
@outcome = "tied"
elsif @comp_move == "paper"
@outcome = "lost"
else
@outcome = "won"
end
erb(:rock)
end
get("/paper") do
moves=["rock", "paper", "scissors"]
@comp_move = moves.sample
if @comp_move == "rock"
@outcome = "win"
elsif @comp_move == "paper"
@outcome = "tied"
else
@outcome = "lost"
end
erb(:paper)
end
get("/scissors") do
moves=["rock", "paper", "scissors"]
@comp_move = moves.sample
if @comp_move == "rock"
@outcome = "lose"
elsif @comp_move == "paper"
@outcome = "won"
else
@outcome = "tied"
end
erb(:scissors)
end