File tree Expand file tree Collapse file tree 1 file changed +6
-8
lines changed Expand file tree Collapse file tree 1 file changed +6
-8
lines changed Original file line number Diff line number Diff line change 7
7
id = 0
8
8
nPlayers = 0
9
9
roles = []
10
- ip2role = {}
11
- ip2image = {}
10
+ ip2role_idx = {}
12
11
13
12
@app .route ('/' )
14
13
def index ():
15
- global id , ip2role , ip2image
14
+ global id , ip2role_idx
16
15
role = ""
17
16
image_name = ""
18
17
ip = str (request .remote_addr )
19
18
20
- if ip in ip2role .keys ():
21
- role = ip2role [ip ]
22
- image_name = ip2image [ip ]
19
+ if ip in ip2role_idx .keys ():
20
+ role = ip2role_idx [ip ][ 0 ]
21
+ image_name = ip2role_idx [ip ][ 0 ] + "_" + str ( ip2role_idx [ ip ][ 1 ])
23
22
else :
24
23
if id > nPlayers :
25
24
return "Numbers of players out of range!" #TODO:well defined Error Page
26
25
role = roles [id ]
27
26
image_name = role + "_" + str (randrange (1 , nRoles [role ] + 1 ))
28
- ip2role [ip ] = role
29
- ip2image [ip ] = image_name
27
+ ip2role_idx = (role , image_name )
30
28
print ("*" * 20 , "New Player" ,"*" * 20 )
31
29
print (ip + " : " + str (id ) + " --> " + role )
32
30
id += 1
You can’t perform that action at this time.
0 commit comments