Skip to content

Commit

Permalink
Handle zero damage shield calc
Browse files Browse the repository at this point in the history
  • Loading branch information
Drevarr committed Dec 3, 2024
1 parent d9e7073 commit 9609965
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
11 changes: 5 additions & 6 deletions output_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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']
Expand Down
6 changes: 4 additions & 2 deletions parser_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit 9609965

Please sign in to comment.