Skip to content

Commit 6428866

Browse files
committed
refactor de Matche en Map
1 parent 3a6b0a7 commit 6428866

File tree

4 files changed

+28
-29
lines changed

4 files changed

+28
-29
lines changed

src/log_analyser/log_analyser.py

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import os
22
from datetime import datetime, timedelta
3-
from log_analyser.objects.match import Match
3+
from log_analyser.objects.map import Map
44

55

66
class LogAnalyser:
@@ -12,9 +12,9 @@ def __init__(self, path_csv, name) -> None:
1212

1313
self.date = self.name2datetime()
1414

15-
self.match = None
15+
self.map = None
1616

17-
self.actions = {"match_start": self.process_match_start}
17+
self.actions = {"match_start": self.process_map_start}
1818

1919
def run(self):
2020

@@ -30,7 +30,7 @@ def run(self):
3030
self.actions[type](line_split)
3131

3232
# with open("../logs_process/{}.json".format(self.name.split(".")[0]), "w") as file:
33-
# file.write(self.match.export_json())
33+
# file.write(self.map.export_json())
3434

3535

3636
def name2datetime(self):
@@ -40,9 +40,9 @@ def name2datetime(self):
4040

4141
return date_object
4242

43-
def process_match_start(self, data):
43+
def process_map_start(self, data):
4444

45-
self.match = Match.from_json({"rounds": [],
45+
self.map = Map.from_json({"rounds": [],
4646
"date": self.date,
4747
"map_name": data[3],
4848
"map_type": data[4],
@@ -52,30 +52,30 @@ def process_match_start(self, data):
5252
"score_team2": 0,
5353
})
5454

55-
self.actions = {"match_start": self.process_match_start,
56-
"round_start": self.match.add_round,
57-
"round_end": self.match.end_round,
55+
self.actions = {"match_start": self.process_map_start,
56+
"round_start": self.map.add_round,
57+
"round_end": self.map.end_round,
5858
"hero_spawn": self.process_hero_spawn,
5959
"hero_swap": self.process_hero_swap,
60-
"kill": self.match.add_kill,
61-
"ultimate_charged": self.match.add_ultimate_charged,
62-
"ultimate_start": self.match.add_ultimate_start,
63-
"ultimate_end": self.match.add_ultimate_end,
64-
"objective_captured": self.match.add_objective_captured,
65-
"player_stat": self.match.add_player_stat,
66-
"point_progress": self.match.add_objective_progress,
67-
"payload_progress": self.match.add_objective_progress,
60+
"kill": self.map.add_kill,
61+
"ultimate_charged": self.map.add_ultimate_charged,
62+
"ultimate_start": self.map.add_ultimate_start,
63+
"ultimate_end": self.map.add_ultimate_end,
64+
"objective_captured": self.map.add_objective_captured,
65+
"player_stat": self.map.add_player_stat,
66+
"point_progress": self.map.add_objective_progress,
67+
"payload_progress": self.map.add_objective_progress,
6868
}
6969

7070
def process_hero_spawn(self, data):
7171

7272
player_data = {"time": data[2], "team_name": data[3], "player_name": data[4], "character_name": data[5]}
73-
self.match.add_player(player_data)
73+
self.map.add_player(player_data)
7474

7575
def process_hero_swap(self, data):
7676

7777
hero_data = {"time": data[2], "team_name": data[3], "player_name": data[4], "character_name": data[5], "character_swap": data[6]}
78-
self.match.add_hero_swap(hero_data)
78+
self.map.add_hero_swap(hero_data)
7979

8080
def convert_timefile_to_datetime(self, time_string):
8181

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from datetime import datetime
55

66

7-
class Match(Object):
7+
class Map(Object):
88

99
def __init__(self, **kwargs):
1010

@@ -152,9 +152,9 @@ def end_round(self, data):
152152
self.score_team2 = end_round_data["score_team2"]
153153
print("###### END ROUND {} #######\n".format(self.actual_round))
154154

155-
def end_match(self, data):
155+
def end_map(self, data):
156156

157-
end_match_data = {"time": data[2], "score_team1": data[4], "score_team2": data[5]}
157+
end_map_data = {"time": data[2], "score_team1": data[4], "score_team2": data[5]}
158158

159-
self.score_team1 = end_match_data["score_team1"]
160-
self.score_team2 = end_match_data["score_team2"]
159+
self.score_team1 = end_map_data["score_team1"]
160+
self.score_team2 = end_map_data["score_team2"]

src/log_analyser/objects/object.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def export_json_recursive(self, data):
3131
dict_class_final = dict_class.copy()
3232

3333
for key, value in dict_class.items():
34-
if not key in data.class_model:
34+
if not key in data.class_model and key != "class_name":
3535
dict_class_final.pop(key)
3636

3737
return data.export_json_recursive(dict_class_final)
@@ -51,7 +51,7 @@ def export_json(self):
5151
dict_class_final = dict_class.copy()
5252

5353
for key, value in dict_class.items():
54-
if not key in self.class_model:
54+
if not key in self.class_model and key != "class_name":
5555
dict_class_final.pop(key)
5656
else:
5757
dict_class_final[key] = self.export_json_recursive(value)

src/main.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,12 @@ def on_callback_test(self, topic, data):
2424

2525
la = LogAnalyser('logs/Log-2023-12-22-21-12-32.txt', "Log-2023-12-22-21-12-32.txt")
2626
la.run()
27-
a = la.match.export_json()
28-
self.producer_thread.send("analyse.report", la.match.export_json())
27+
self.producer_thread.send("analyse.report", la.map.export_json())
2928

3029
def run(self):
3130

3231
while self.running:
33-
print("Service en cours d'exécution...")
32+
# print("Service en cours d'exécution...")
3433
time.sleep(1)
3534

3635
print("Service stop.")

0 commit comments

Comments
 (0)