-
Notifications
You must be signed in to change notification settings - Fork 0
/
web.rb
executable file
·55 lines (42 loc) · 1.21 KB
/
web.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
require 'sinatra'
require 'json'
get '/' do
responseObject = {
"color"=> "#fff000",
"head_url"=> "url/to/your/img/file"
}
return responseObject.to_json
end
post '/start' do
requestBody = request.body.read
requestJson = requestBody ? JSON.parse(requestBody) : {}
# Get ready to start a game with the request data
# Dummy response
responseObject = {
"color" => "#FF0000",
"head_url" => "http://placecage.com/c/100/100",
"name" => "ZeldaSnake",
"taunt" => "OH GOD NOT THE BEES",
"head_type" => "pixel",
"tail_type" => "pixel"
}
return responseObject.to_json
end
post '/move' do
requestBody = request.body.read
requestJson = requestBody ? JSON.parse(requestBody) : {}
# Calculate a move with the request data
# Dummy response
responseObject = {
"move" => "north", # One of either "north", "east", "south", or "west".
"taunt" => "going north!",
}
return responseObject.to_json
end
post '/end' do
requestBody = request.body.read
requestJson = requestBody ? JSON.parse(requestBody) : {}
# No response required
responseObject = {}
return responseObject.to_json
end