From 18f9b38d2515d422c5ede67da9707662d7c087ff Mon Sep 17 00:00:00 2001 From: walterroach <37820425+walterroach@users.noreply.github.com> Date: Sat, 7 Nov 2020 17:09:40 -0600 Subject: [PATCH] Keep only last base capture per base in debrief --- game/debriefing.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/game/debriefing.py b/game/debriefing.py index b33b24b6..6bf15569 100644 --- a/game/debriefing.py +++ b/game/debriefing.py @@ -24,7 +24,7 @@ class DebriefingDeadUnitInfo: class Debriefing: def __init__(self, state_data, game): - self.base_capture_events = state_data["base_capture_events"] + self.state_data = state_data self.killed_aircrafts = state_data["killed_aircrafts"] self.killed_ground_units = state_data["killed_ground_units"] self.weapons_fired = state_data["weapons_fired"] @@ -162,6 +162,18 @@ class Debriefing: logging.info(self.player_dead_buildings_dict) logging.info(self.enemy_dead_buildings_dict) + @property + def base_capture_events(self): + """Keeps only the last instance of a base capture event for each base ID""" + reversed_captures = [i for i in self.state_data["base_capture_events"][::-1]] + last_base_cap_indexes = [] + for idx, base in enumerate(i.split("||")[0] for i in reversed_captures): + if base in [x[1] for x in last_base_cap_indexes]: + continue + else: + last_base_cap_indexes.append((idx, base)) + return [reversed_captures[idx[0]] for idx in last_base_cap_indexes] + class PollDebriefingFileThread(threading.Thread): """Thread class with a stop() method. The thread itself has to check