Skip to content

Commit

Permalink
Update combatlog.py to work with new parsing logic
Browse files Browse the repository at this point in the history
  • Loading branch information
Shinga13 authored Dec 15, 2024
1 parent 3c0396f commit 358fe08
Showing 1 changed file with 17 additions and 8 deletions.
25 changes: 17 additions & 8 deletions combatlog/models/combatlog.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,17 +110,23 @@ def update_metadata_file(self, file, force=False):

results = []

parser = OSCR.OSCR(file.name)
parser.analyze_log_file()

# Only look at the first combat for now.
dmg_out, _, _, _ = parser.full_combat_analysis(0)
damage_out = self.tree_to_dict(dmg_out)
combat = parser.active_combat
parser_settings = {
'combats_to_parse': 1,
'seconds_between_combats': 100,
'graph_resolution': 2.0, # could probably use even greater resolution to save memory
}

parser = OSCR.OSCR(log_path=file.name, settings=parser_settings)
parser.analyze_log_file(max_combats=1)
try:
combat = parser.combats[0]
except IndexError:
raise APIException('Combat log is empty')
damage_out = self.tree_to_dict(combat.damage_out)

players = {}
for name, player in combat.players.items():
players[name] = player.__dict__
players[name] = player.to_dict()

players = sorted(
players.items(),
Expand All @@ -143,6 +149,9 @@ def update_metadata_file(self, file, force=False):
raise APIException("Combat log is empty")

# TBD: We use 0.9 combat time until a better choice can be made.
# +++ ADDED +++
# combat.meta['log_duration']
# combat.meta['player_duration']
combat_time = players[0][1]["combat_time"] * 0.90

# Check to see if map / difficulty combination exists in the ladder
Expand Down

0 comments on commit 358fe08

Please sign in to comment.