forked from raghubetina/sinatra-dice-dynamic
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.rb
More file actions
47 lines (34 loc) · 970 Bytes
/
app.rb
File metadata and controls
47 lines (34 loc) · 970 Bytes
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"
require "sinatra/reloader"
get("/") do
erb(:homepage)
end
get("/dice/2/6") do
first_die = rand(1..6)
second_die = rand(1..6)
sum = first_die + second_die
@outcome = "You rolled a #{first_die} and a #{second_die} for a total of #{sum}."
erb(:two_six)
end
get("/dice/2/10") do
first_die = rand(1..10)
second_die = rand(1..10)
sum = first_die + second_die
@outcome = "You rolled a #{first_die} and a #{second_die} for a total of #{sum}."
erb(:two_ten)
end
get("/dice/1/20") do
@die = rand(1..20)
@outcome = "You rolled a #{@die}."
erb(:one_twenty)
end
get("/dice/5/4") do
first_die = rand(1..4)
second_die = rand(1..4)
third_die = rand(1..4)
fourth_die = rand(1..4)
fifth_die = rand(1..4)
sum = first_die + second_die + third_die + fourth_die + fifth_die
@outcome = "You rolled a #{first_die}, #{second_die}, #{third_die}, #{fourth_die}, and #{fifth_die} for a total of #{sum}."
erb(:five_four)
end