-
Notifications
You must be signed in to change notification settings - Fork 12
/
eric2.js
141 lines (127 loc) · 1.89 KB
/
eric2.js
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
137
138
139
140
function echo_evt(req) {
req = req || {};
req.evt = req.evt || {'no':'event_passed'}
return req.evt
}
function make_rsp(req) {
return {
msg_id: req.msg_id,
type: req.type,
}
}
function move_to_signpost(req) {
var rsp = make_rsp(req);
rsp.success = true;
rsp.street = streets_map[req.street_id]
return rsp;
}
function get_init_ob(req) {
var rsp = make_rsp(req);
rsp.success = true;
rsp.pc = {
id: 'pc1',
name: 'serguei',
is_you: true,
location: {
hub_id: 'hub1',
street_id: 'street1'
}
}
return rsp;
}
function get_hub_ob(req) {
var rsp = make_rsp(req);
var hub = hubs[req.hub_id];
if (!hub){
rsp.success = false;
return rsp;
}
rsp.success = true;
rsp.hub = hub;
return rsp;
}
var hubs = {}
streets = [{
tsid: 'street1',
label: 'Main st',
w: 3000,
h: 1000,
ladders: [{
tsid: 'ladder1',
x: 600,
y: 1000,
h: 400
}],
platforms: [],
doors: [{
tsid: 'door1',
x: 100,
y: 1000
},{
tsid: 'door2',
x: 800,
y: 700
}],
signposts: [{
tsid: 'signpost1',
x: 400,
y: 1000,
connects:[{
tsid: 'street2',
label: '2nd ave',
signpost: {
tsid: 'signpost3'
}
},{
tsid: 'street3',
label: '3rd ave',
signpost: {
tsid: 'signpost2'
}
}]
}]
},{
tsid: 'street2',
label: '2nd ave',
w: 2000,
h: 1000,
ladders: [],
platforms: [],
doors: [],
signposts: [{
tsid: 'signpost3',
x: 800,
y: 1000,
connects:[{
tsid: 'street1',
label: 'Main St',
signpost: {
tsid: 'signpost1'
}
}]
}]
},{
tsid: 'street3',
label: '3rd ave',
w: 4000,
h: 2000,
ladders: [],
platforms: [],
doors: [],
signposts: [{
tsid: 'signpost2',
x: 1200,
y: 2000,
connects:[{
tsid: 'street1',
label: 'Main St',
signpost: {
tsid: 'signpost1'
}
}]
}]
}]
streets_map = [];
streets_map.street1 = streets[0];
streets_map.street2 = streets[1];
streets_map.street3 = streets[2];