Skip to content

Commit 008c6cf

Browse files
committed
replace : ip2role_idx replaced ip2role and ip2image.
1 parent ea46ec9 commit 008c6cf

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

mafia.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,26 +7,24 @@
77
id = 0
88
nPlayers = 0
99
roles = []
10-
ip2role = {}
11-
ip2image = {}
10+
ip2role_idx = {}
1211

1312
@app.route('/')
1413
def index():
15-
global id, ip2role, ip2image
14+
global id, ip2role_idx
1615
role = ""
1716
image_name = ""
1817
ip = str(request.remote_addr)
1918

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])
2322
else:
2423
if id > nPlayers:
2524
return "Numbers of players out of range!" #TODO:well defined Error Page
2625
role = roles[id]
2726
image_name = role + "_" + str(randrange(1, nRoles[role] + 1))
28-
ip2role[ip] = role
29-
ip2image[ip] = image_name
27+
ip2role_idx = (role, image_name)
3028
print("*" * 20, "New Player","*" * 20)
3129
print(ip + " : " + str(id) + " --> " + role)
3230
id += 1

0 commit comments

Comments
 (0)