From 9609965e04e2e184a908fa6e0f9635bbac051fa7 Mon Sep 17 00:00:00 2001 From: Drevarr Date: Tue, 3 Dec 2024 09:38:44 -0500 Subject: [PATCH] Handle zero damage shield calc --- output_functions.py | 11 +++++------ parser_functions.py | 6 ++++-- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/output_functions.py b/output_functions.py index 2eec466..cc2181b 100644 --- a/output_functions.py +++ b/output_functions.py @@ -416,23 +416,22 @@ def build_fight_summary(top_stats: dict, caption: str, tid_date_time : str) -> N fight_link = f"[[{fight_data['fight_date']} - {fight_data['fight_end']} - {abbrv}|{fight_data['fight_link']}]]" # Build the row - damage_taken = fight_data['defenses'].get('damageTaken', 1) + damage_taken = fight_data['defenses'].get('damageTaken', 0) downed = fight_data['statsTargets'].get('downed', 0) killed = fight_data['statsTargets'].get('killed', 0) def_down = fight_data['defenses'].get('downCount', 0) def_dead = fight_data['defenses'].get('deadCount', 0) dmg_out = fight_data['dpsTargets'].get('damage', 0) def_barrier = fight_data['defenses'].get('damageBarrier', 0) + def_barrier_pct = (def_barrier / damage_taken) * 100 if damage_taken > 0 else 0 row += f"|{fight_num} |{fight_link} | {fight_data['fight_duration']}| {fight_data['squad_count']} | {fight_data['non_squad_count']} | {fight_data['enemy_count']} " row += f"| {fight_data['enemy_Red']}/{fight_data['enemy_Green']}/{fight_data['enemy_Blue']} | {downed} | {killed} " row += f"| {def_down} | {def_dead} | {dmg_out:,}| {damage_taken:,}" - row += f"| {def_barrier:,}| {(def_barrier / damage_taken * 100):.2f}%| {fight_shield_damage:,}" + row += f"| {def_barrier:,}| {def_barrier_pct:.2f}%| {fight_shield_damage:,}" # Calculate the shield damage percentage - if dmg_out: - shield_damage_pct = (fight_shield_damage / dmg_out * 100) - else: - shield_damage_pct = 0 + shield_damage_pct = (fight_shield_damage / dmg_out) * 100 if dmg_out else 0 row += f"| {shield_damage_pct:.2f}%|" + # Keep track of the last fight number, end time, and total duration last_fight = fight_num total_durationMS += fight_data['fight_durationMS'] diff --git a/parser_functions.py b/parser_functions.py index 6517284..9014c1f 100644 --- a/parser_functions.py +++ b/parser_functions.py @@ -231,8 +231,6 @@ def get_player_death_on_tag(player, commander_tag_positions, dead_tag_mark, dead if player_dist_to_tag <= Run_Back: death_on_tag[name_prof]["distToTag"].append(player_dist_to_tag) - - def get_player_fight_dps(dpsTargets: dict, name: str, profession: str, fight_num: int, fight_time: int) -> None: """ Get the maximum damage hit by skill. @@ -433,6 +431,10 @@ def get_personal_mod_data(personal_damage_mods: dict) -> None: personal_damage_mod_data['total'].append(mod_id) +def get_personal_buff_data(personal_buffs: dict) -> None: + pass + + def get_enemies_by_fight(fight_num: int, targets: dict) -> None: """ Organize targets by enemy for a fight.