@@ -13,7 +13,9 @@ def __init__(self, **kwargs):
1313 "map_name" : str ,
1414 "map_type" : str ,
1515 "team1_name" : str ,
16- "team2_name" : str
16+ "team2_name" : str ,
17+ "score_team1" : int ,
18+ "score_team2" : int ,
1719 }
1820
1921 super ().__init__ (data_schema , ** kwargs )
@@ -25,9 +27,10 @@ def add_round(self, data):
2527 teams = {}
2628 teams [self .team1_name ] = Team .from_json ({"name" : self .team1_name , "players" : {}})
2729 teams [self .team2_name ] = Team .from_json ({"name" : self .team2_name , "players" : {}})
28- self .rounds .append (Round .from_json ({"teams" : teams , "start_time" : data [0 ]}))
30+ self .rounds .append (Round .from_json ({"teams" : teams , "start_time" : data [2 ], "objective_captured" : [], "objective_progress" : [ ]}))
2931
3032 self .actual_round += 1
33+
3134 print ("###### NEW ROUND {} #######" .format (self .actual_round ))
3235
3336 def add_player (self , data ):
@@ -38,7 +41,7 @@ def add_player(self, data):
3841 else :
3942 self .rounds [self .actual_round ].teams [data ["team_name" ]].add_player (
4043 {"name" : data ["player_name" ], "characters" : {}})
41- print ("add player" , data ["player_name" ])
44+ # print("add player", data["player_name"])
4245 self .add_character (data )
4346 return 0
4447
@@ -47,7 +50,7 @@ def add_character(self, data):
4750 if data ["character_name" ] in self .rounds [self .actual_round ].teams [data ["team_name" ]].players [data ["player_name" ]].characters :
4851 return - 2
4952 else :
50- self .rounds [self .actual_round ].teams [data ["team_name" ]].players [data ["player_name" ]].add_character ({"name" : data ["character_name" ]})
53+ self .rounds [self .actual_round ].teams [data ["team_name" ]].players [data ["player_name" ]].add_character ({"name" : data ["character_name" ], "stats" : {}, "played_time" : [], "kills" : [], "deads" : [], "offensive_assists" : [], "defensive_assists" : [], "ultimate_charged" : [], "ultimate_use" : [] })
5154
5255 if len (self .rounds [self .actual_round ].teams [data ["team_name" ]].players [data ["player_name" ]].characters [data ["character_name" ]].played_time ) > 0 :
5356 self .rounds [self .actual_round ].teams [data ["team_name" ]].players [data ["player_name" ]].characters [data ["character_name" ]].played_time [- 1 ]["end" ] = data ["time" ]
@@ -56,38 +59,102 @@ def add_character(self, data):
5659
5760 def add_kill (self , data ):
5861
59- killer_data = {"time" : data [0 ], "player_victim" : data [7 ], "character_victim" : data [8 ]}
60- victim_data = {"time" : data [0 ], "player_killer" : data [4 ], "character_killer" : data [5 ]}
62+ killer_data = {"time" : data [2 ], "player_victim" : data [7 ], "character_victim" : data [8 ]}
63+ victim_data = {"time" : data [2 ], "player_killer" : data [4 ], "character_killer" : data [5 ]}
6164
6265 self .create_if_player_and_caracter_not_exist (data [3 ], data [4 ], data [5 ])
6366 self .create_if_player_and_caracter_not_exist (data [6 ], data [7 ], data [8 ])
6467
6568 if not data [5 ] in self .rounds [self .actual_round ].teams [data [3 ]].players [data [4 ]].characters :
66- self .add_character ({"time" : data [0 ], "team_name" : data [3 ], "player_name" : data [4 ], "character_name" : data [5 ]})
69+ self .add_character ({"time" : data [2 ], "team_name" : data [3 ], "player_name" : data [4 ], "character_name" : data [5 ]})
6770
6871 if not data [6 ] in self .rounds [self .actual_round ].teams [data [6 ]].players [data [7 ]].characters :
69- self .add_character ({"time" : data [0 ], "team_name" : data [6 ], "player_name" : data [7 ], "character_name" : data [8 ]})
72+ self .add_character ({"time" : data [2 ], "team_name" : data [6 ], "player_name" : data [7 ], "character_name" : data [8 ]})
7073
7174 self .rounds [self .actual_round ].teams [data [3 ]].players [data [4 ]].characters [data [5 ]].add_kill (killer_data )
7275 self .rounds [self .actual_round ].teams [data [6 ]].players [data [7 ]].characters [data [8 ]].add_death (victim_data )
7376
7477 def add_player_stat (self , data ):
7578
76- self .create_if_player_and_caracter_not_exist (data [4 ], data [5 ], data [6 ])
79+ # self.create_if_player_and_caracter_not_exist(data[4], data[5], data[6])
7780
7881 player_data = {"eliminations" : data [6 ], "final_blows" : data [7 ], "deaths" : data [8 ], "damage" : data [9 ],
7982 "barrier_damage" : data [10 ], "hero_damage" : data [11 ], "healing" : data [12 ], "healing_receive" : data [13 ],
8083 "self_healing" : data [14 ], "damage_taken" : data [15 ], "damage_blocked" : data [16 ], "defensive_assist" : data [17 ],
8184 "offensive_assists" : data [18 ], "ultimated_earn" : data [19 ], "ultimates_used" : data [20 ], "solo_kills" : data [23 ],
8285 "critical_hits_accuracy" : data [28 ], "weapon_accuracy" : data [37 ], "hero_time_played" : data [38 ]}
8386
84- if player_data ["hero_time_played" ] != "0" :
87+ if player_data ["hero_time_played" ] != "0" and data [ 6 ] in self . rounds [ self . actual_round ]. teams [ data [ 4 ]]. players [ data [ 5 ]]. characters :
8588 self .rounds [self .actual_round ].teams [data [4 ]].players [data [5 ]].characters [data [6 ]].add_character_stats (player_data )
8689
90+ def add_hero_swap (self , data ):
91+
92+ self .add_player (data )
93+ if data ["character_swap" ] in self .rounds [self .actual_round ].teams [data ["team_name" ]].players [data ["player_name" ]].characters :
94+ self .rounds [self .actual_round ].teams [data ["team_name" ]].players [data ["player_name" ]].characters [data ["character_swap" ]].add_played_time ({"end" : data ["time" ]})
95+
96+
8797 def create_if_player_and_caracter_not_exist (self , team , player_name , character_name ):
8898
8999 if not player_name in self .rounds [self .actual_round ].teams [team ].players :
90100 self .add_player ({"team_name" : team , "player_name" : player_name , "character_name" : character_name , "time" : self .rounds [self .actual_round ].start_time })
91101
92102 if not character_name in self .rounds [self .actual_round ].teams [team ].players [player_name ].characters :
93103 self .add_character ({"team_name" : team , "player_name" : player_name , "character_name" : character_name , "time" : self .rounds [self .actual_round ].start_time })
104+
105+ def add_ultimate_start (self , data ):
106+
107+ self .create_if_player_and_caracter_not_exist (data [3 ], data [4 ], data [5 ])
108+
109+ ultimate_start_data = {"start" : data [2 ]}
110+ self .rounds [self .actual_round ].teams [data [3 ]].players [data [4 ]].characters [data [5 ]].add_ultimate_start (ultimate_start_data )
111+
112+ def add_ultimate_end (self , data ):
113+
114+ self .create_if_player_and_caracter_not_exist (data [3 ], data [4 ], data [5 ])
115+
116+ ultimate_end_data = {"end" : data [2 ]}
117+ self .rounds [self .actual_round ].teams [data [3 ]].players [data [4 ]].characters [data [5 ]].add_ultimate_end (ultimate_end_data )
118+
119+ def add_ultimate_charged (self , data ):
120+
121+ self .create_if_player_and_caracter_not_exist (data [3 ], data [4 ], data [5 ])
122+
123+ ultimate_charged_data = data [2 ]
124+ self .rounds [self .actual_round ].teams [data [3 ]].players [data [4 ]].characters [data [5 ]].add_ultimate_charged (ultimate_charged_data )
125+
126+ def add_objective_captured (self , data ):
127+
128+ objective_capture_data = {"time" : data [2 ], "team_name" : data [4 ], "control_team1_progress" : data [6 ],
129+ "control_team2_progress" : data [7 ]}
130+
131+ self .rounds [self .actual_round ].add_objective_captured (objective_capture_data )
132+
133+
134+ def add_objective_progress (self , data ):
135+
136+ objectif_progress_data = {"time" : data [2 ], "team_name" : data [4 ], "progress" : data [6 ]}
137+ self .rounds [self .actual_round ].add_objective_progress (objectif_progress_data )
138+ pass
139+
140+ def end_round (self , data ):
141+
142+ end_round_data = {"time" : data [2 ], "score_team1" : data [5 ], "score_team2" : data [6 ]}
143+
144+ for team in self .rounds [self .actual_round ].teams :
145+ for player in self .rounds [self .actual_round ].teams [team ].players :
146+ for character in self .rounds [self .actual_round ].teams [team ].players [player ].characters :
147+ if not "end" in self .rounds [self .actual_round ].teams [team ].players [player ].characters [character ].played_time [- 1 ]:
148+ self .rounds [self .actual_round ].teams [team ].players [player ].characters [character ].played_time [- 1 ]["end" ] = end_round_data ["time" ]
149+
150+
151+ self .score_team1 = end_round_data ["score_team1" ]
152+ self .score_team2 = end_round_data ["score_team2" ]
153+ print ("###### END ROUND {} #######\n " .format (self .actual_round ))
154+
155+ def end_match (self , data ):
156+
157+ end_match_data = {"time" : data [2 ], "score_team1" : data [4 ], "score_team2" : data [5 ]}
158+
159+ self .score_team1 = end_match_data ["score_team1" ]
160+ self .score_team2 = end_match_data ["score_team2" ]
0 commit comments