@@ -14,8 +14,10 @@ def __init__(self, **kwargs):
1414 "map_type" : str ,
1515 "team1_name" : str ,
1616 "team2_name" : str ,
17- "score_team1" : int ,
18- "score_team2" : int ,
17+ "team1_score" : int ,
18+ "team2_score" : int ,
19+ "team_id" : str ,
20+ "events" : list ,
1921 }
2022
2123 super ().__init__ (data_schema , ** kwargs )
@@ -27,12 +29,15 @@ def add_round(self, data):
2729 teams = {}
2830 teams [self .team1_name ] = Team .from_json ({"name" : self .team1_name , "players" : {}})
2931 teams [self .team2_name ] = Team .from_json ({"name" : self .team2_name , "players" : {}})
30- self .rounds .append (Round .from_json ({"teams" : teams , "start_time" : data [2 ], "objective_captured" : [], "objective_progress" : []}))
32+ self .rounds .append (Round .from_json ({"teams" : teams , "start_time" : data [2 ], "end_time" : "" , "objective_captured" : [], "objective_progress" : []}))
33+
34+ # self.events.append({"type": "round_start", "timestamp": data[2], "value": 1, "description": "Round {} start".format(len(self.rounds))})
3135
3236 self .actual_round += 1
3337
3438 print ("###### NEW ROUND {} #######" .format (self .actual_round ))
3539
40+
3641 def add_player (self , data ):
3742
3843 if data ["player_name" ] in self .rounds [self .actual_round ].teams [data ["team_name" ]].players :
@@ -74,15 +79,22 @@ def add_kill(self, data):
7479 self .rounds [self .actual_round ].teams [data [3 ]].players [data [4 ]].characters [data [5 ]].add_kill (killer_data )
7580 self .rounds [self .actual_round ].teams [data [6 ]].players [data [7 ]].characters [data [8 ]].add_death (victim_data )
7681
82+ team = self .find_team_for_player (data [4 ])
83+
84+ if team == list (self .rounds [self .actual_round ].teams .keys ())[0 ]:
85+ self .events .append ({"type" : "kill_team1" , "timestamp" : data [2 ], "value" : 1 , "description" : "{} kill {}" .format (data [4 ], data [7 ])})
86+ else :
87+ self .events .append ({"type" : "kill_team2" , "timestamp" : data [2 ], "value" : 1 ,
88+ "description" : "{} kill {}" .format (data [4 ], data [7 ])})
7789 def add_player_stat (self , data ):
7890
7991 # self.create_if_player_and_caracter_not_exist(data[4], data[5], data[6])
8092
81- player_data = {"eliminations" : data [6 ], "final_blows" : data [7 ], "deaths" : data [8 ], "damage" : data [9 ],
82- "barrier_damage" : data [10 ], "hero_damage" : data [11 ], "healing" : data [12 ], "healing_receive" : data [13 ],
83- "self_healing" : data [14 ], "damage_taken" : data [15 ], "damage_blocked" : data [16 ], "defensive_assist" : data [17 ],
84- "offensive_assists" : data [18 ], "ultimated_earn" : data [19 ], "ultimates_used" : data [20 ], "solo_kills" : data [23 ],
85- "critical_hits_accuracy" : data [28 ], "weapon_accuracy" : data [37 ], "hero_time_played" : data [38 ]}
93+ player_data = {"eliminations" : data [7 ], "final_blows" : data [8 ], "deaths" : data [9 ], "damage" : data [10 ],
94+ "barrier_damage" : data [11 ], "hero_damage" : data [12 ], "healing" : data [13 ], "healing_receive" : data [14 ],
95+ "self_healing" : data [15 ], "damage_taken" : data [16 ], "damage_blocked" : data [17 ], "defensive_assist" : data [18 ],
96+ "offensive_assists" : data [19 ], "ultimated_earn" : data [20 ], "ultimates_used" : data [21 ], "solo_kills" : data [24 ],
97+ "critical_hits_accuracy" : data [29 ], "weapon_accuracy" : data [38 ], "hero_time_played" : data [39 ]}
8698
8799 if player_data ["hero_time_played" ] != "0" and data [6 ] in self .rounds [self .actual_round ].teams [data [4 ]].players [data [5 ]].characters :
88100 self .rounds [self .actual_round ].teams [data [4 ]].players [data [5 ]].characters [data [6 ]].add_character_stats (player_data )
@@ -139,22 +151,34 @@ def add_objective_progress(self, data):
139151
140152 def end_round (self , data ):
141153
142- end_round_data = {"time" : data [2 ], "score_team1 " : data [5 ], "score_team2 " : data [6 ]}
143-
154+ end_round_data = {"time" : data [2 ], "team1_score " : data [5 ], "team2_score " : data [6 ]}
155+ self . rounds [ self . actual_round ]. end_time = data [ 2 ]
144156 for team in self .rounds [self .actual_round ].teams :
145157 for player in self .rounds [self .actual_round ].teams [team ].players :
146158 for character in self .rounds [self .actual_round ].teams [team ].players [player ].characters :
147159 if not "end" in self .rounds [self .actual_round ].teams [team ].players [player ].characters [character ].played_time [- 1 ]:
148160 self .rounds [self .actual_round ].teams [team ].players [player ].characters [character ].played_time [- 1 ]["end" ] = end_round_data ["time" ]
149161
150162
151- self .score_team1 = end_round_data ["score_team1" ]
152- self .score_team2 = end_round_data ["score_team2" ]
163+ self .team1_score = end_round_data ["team1_score" ]
164+ self .team2_score = end_round_data ["team2_score" ]
165+ print (" score team 1 : " , self .team1_score )
166+ print (" score team 2 : " , self .team2_score )
153167 print ("###### END ROUND {} #######\n " .format (self .actual_round ))
154168
169+
155170 def end_map (self , data ):
156171
157- end_map_data = {"time" : data [2 ], "score_team1" : data [4 ], "score_team2" : data [5 ]}
172+ end_map_data = {"time" : data [2 ], "team1_score" : data [4 ], "team2_score" : data [5 ]}
173+
174+ self .team1_score = end_map_data ["team1_score" ]
175+ self .team2_score = end_map_data ["team2_score" ]
176+
177+
178+ def find_team_for_player (self , player_name ):
179+
180+ for team in self .rounds [self .actual_round ].teams :
181+ if player_name in self .rounds [self .actual_round ].teams [team ].players :
182+ return team
158183
159- self .score_team1 = end_map_data ["score_team1" ]
160- self .score_team2 = end_map_data ["score_team2" ]
184+ return None
0 commit comments