-
Notifications
You must be signed in to change notification settings - Fork 0
/
payloadparser.py
23 lines (18 loc) · 938 Bytes
/
payloadparser.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import gamestate
import time
class PayloadParser:
def parse_payload(self, payload, gamestate):
for item in payload: #parsing allplayers (three indexes)
if item == "allplayers":
# print(payload)
index = 0
for player in payload[item]: #cycles thrue each player and every stat that he has (name,match_stats etc.)
for stat in payload[item][player]:
setattr(getattr(gamestate.allplayers , "p"+ str(index)), stat , payload[item][player][stat])
setattr(getattr(gamestate.allplayers , "p"+ str(index)), "steamid" , player)
index += 1
for i in payload[item]: #parsing "normal" items (two indexes)
try:
setattr(getattr(gamestate, item), i, payload[item][i])
except:
pass