Skip to content
Newer
Older
100644 52 lines (46 sloc) 1.33 KB
239f7b7 initial commit
Topher authored Feb 27, 2010
1 require 'rubygems'
2 require 'sinatra'
3 require 'builder'
4
65b316f initial commit3
Topher authored Feb 27, 2010
5 get '/' do
66ae11f fixed route
Topher authored Feb 27, 2010
6 'HighLow is a <a href="teleku.com">Teleku Voice Application</a><br>'
7 'curl --data-urlencode "caller=test" http://highlow.heroku.com'
65b316f initial commit3
Topher authored Feb 28, 2010
8 end
9
239f7b7 initial commit
Topher authored Feb 28, 2010
10 post '/' do
66ae11f fixed route
Topher authored Feb 28, 2010
11 deal = 1 + rand(10)
239f7b7 initial commit
Topher authored Feb 28, 2010
12 builder do |xml|
13 xml.instruct!
14 xml.phoneml do
15 xml.speak "welcome to the game of high low"
66ae11f fixed route
Topher authored Feb 28, 2010
16 xml.speak "the dealer randomly selected " + deal.to_s
239f7b7 initial commit
Topher authored Feb 28, 2010
17 xml.speak "will his next number be higher or lower? press 1 or say higher or press 2 or say lower"
1abd693 added relative url support
Topher authored Feb 28, 2010
18 xml.input "/guess/" + deal.to_s, "options"=>"1,2,higher,lower"
239f7b7 initial commit
Topher authored Feb 28, 2010
19 end
20 end
21 end
22
66ae11f fixed route
Topher authored Feb 28, 2010
23 post '/guess/:deal' do
24 newdeal = 1 + rand(10)
789e38d added hilo game source4
Topher authored Feb 27, 2010
25 guess = params[:callerinput]
239f7b7 initial commit
Topher authored Feb 28, 2010
26 if guess == '1' or guess == 'higher'
66ae11f fixed route
Topher authored Feb 28, 2010
27 if newdeal > params[:deal].to_i
239f7b7 initial commit
Topher authored Feb 28, 2010
28 gamestatus = "winner"
29 else
30 gamestatus = "loser"
31 end
32 end
33
34 if guess == '2' or guess == 'lower'
66ae11f fixed route
Topher authored Feb 28, 2010
35 if newdeal < params[:deal].to_i
239f7b7 initial commit
Topher authored Feb 28, 2010
36 gamestatus = "winner"
37 else
38 gamestatus = "loser"
39 end
40 end
41
42 builder do |xml|
43 xml.instruct!
44 xml.phoneml do
ec11352 fixed route2
Topher authored Feb 27, 2010
45 xml.speak "the dealer randomly selected " + newdeal.to_s
239f7b7 initial commit
Topher authored Feb 28, 2010
46 xml.speak "you are a " + gamestatus
47 xml.speak "will his next number be higher or lower? press 1 or say higher or press 2 or say lower"
1abd693 added relative url support
Topher authored Feb 28, 2010
48 xml.input "/guess/" + newdeal.to_s, "options"=>"1,2,higher,lower"
239f7b7 initial commit
Topher authored Feb 28, 2010
49 end
50 end
51 end
52
Something went wrong with that request. Please try again.