Skip to content

Commit

Permalink
check zero div for damage mods
Browse files Browse the repository at this point in the history
initial squad comp
  • Loading branch information
Drevarr committed Nov 11, 2024
1 parent 05a8961 commit 62dc5f2
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 7 deletions.
Binary file added Top_Stats.db
Binary file not shown.
1 change: 1 addition & 0 deletions config.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
"fight": {},
"player": {},
"parties_by_fight": {},
"enemies_by_fight": {},
"skill_casts_by_role": {},
"players_running_healing_addon": [],
}
Expand Down
35 changes: 33 additions & 2 deletions output_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -969,10 +969,10 @@ def build_personal_damage_modifier_summary(top_stats: dict, personal_damage_mod_
if mod in player_data['damageModifiers']:
# Get the hit count and total hit count
hit_count = player_data['damageModifiers'][mod]['hitCount']
total_count = player_data['damageModifiers'][mod]['totalHitCount']
total_count = player_data['damageModifiers'][mod].get('totalHitCount',1)
# Get the damage gain and total damage
damage_gain = player_data['damageModifiers'][mod]['damageGain']
total_damage = player_data['damageModifiers'][mod]['totalDamage']
total_damage = player_data['damageModifiers'][mod].get('totalDamage',1)
# Calculate the damage percentage and hit percentage
damage_pct = damage_gain / total_damage * 100
hit_pct = hit_count / total_count * 100
Expand Down Expand Up @@ -2012,6 +2012,36 @@ def build_damage_outgoing_by_player_skill_tids(top_stats: dict, skill_data: dict
)


def build_squad_composition(top_stats: dict, tid_date_time: str, tid_list: list) -> None:
rows = []

for fight in top_stats['parties_by_fight']:
header = "\n\n|thead-dark table-caption-top table-hover sortable w-75 table-center|k\n"
header += f"|Fight - {fight} |c"
rows.append(header)
for group in top_stats['parties_by_fight'][fight]:

row = f"|{group:02} |"
for player in top_stats['parties_by_fight'][fight][group]:
profession, name = player.split("|")
profession = "{{"+profession+"}}"
tooltip = f" {name} "
detailEntry = f'<div class="xtooltip"> {profession} <span class="xtooltiptext">'+name+'</span></div>'
row += f" {detailEntry} |"
rows.append(row)

text = "\n".join(rows)

tid_title = f"{tid_date_time}-Squad-Composition"
tid_caption = "Squad Composition"
tid_tags = tid_date_time

append_tid_for_output(
create_new_tid_from_template(tid_title, tid_caption, text, tid_tags),
tid_list
)



def write_data_to_db(top_stats: dict, last_fight: str) -> None:
print("Writing raid stats to database")
Expand Down Expand Up @@ -2084,6 +2114,7 @@ def output_top_stats_json(top_stats: dict, buff_data: dict, skill_data: dict, da
json_dict["overall_raid_stats"] = {key: value for key, value in top_stats['overall'].items()}
json_dict["fights"] = {key: value for key, value in top_stats['fight'].items()}
json_dict["parties_by_fight"] = {key: value for key, value in top_stats["parties_by_fight"].items()}
json_dict["enemies_by_fight"] = {key: value for key, value in top_stats["enemies_by_fight"].items()}
json_dict["players"] = {key: value for key, value in top_stats['player'].items()}
json_dict["buff_data"] = {key: value for key, value in buff_data.items()}
json_dict["skill_data"] = {key: value for key, value in skill_data.items()}
Expand Down
17 changes: 13 additions & 4 deletions parser_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,22 +280,30 @@ def get_enemies_by_fight(fight_num: int, targets: dict) -> None:
if fight_num not in top_stats["fight"]:
top_stats["fight"][fight_num] = {}

if fight_num not in top_stats["enemies_by_fight"]:
top_stats["enemies_by_fight"][fight_num] = {}

for target in targets:
if target["isFake"]:
continue

if target['enemyPlayer']:
team = target["teamID"]
enemy_prof = target['name'].split(" ")[0]

if team in team_colors:
team = "enemy_" + team_colors[team]
else:
team = "enemy_Unk"

if team not in top_stats["fight"][fight_num]:
# Create a new team if it doesn't exist
top_stats["fight"][fight_num][team] = 0

if enemy_prof not in top_stats["enemies_by_fight"][fight_num]:
top_stats["enemies_by_fight"][fight_num][enemy_prof] = 0
top_stats["enemies_by_fight"][fight_num][enemy_prof] += 1

top_stats["fight"][fight_num][team] += 1

top_stats["fight"][fight_num]["enemy_count"] += 1
Expand Down Expand Up @@ -355,12 +363,14 @@ def get_parties_by_fight(fight_num: int, players: list) -> None:
top_stats["fight"][fight_num]["squad_count"] += 1
group = player["group"]
name = player["name"]
profession = player["profession"]
prof_name = profession+"|"+name
if group not in top_stats["parties_by_fight"][fight_num]:
# Create a new group if it doesn't exist
top_stats["parties_by_fight"][fight_num][group] = []
if name not in top_stats["parties_by_fight"][fight_num][group]:
if prof_name not in top_stats["parties_by_fight"][fight_num][group]:
# Add the player to the group
top_stats["parties_by_fight"][fight_num][group].append(name)
top_stats["parties_by_fight"][fight_num][group].append(prof_name)


def get_stat_by_key(fight_num: int, player: dict, stat_category: str, name_prof: str) -> None:
Expand Down Expand Up @@ -1119,7 +1129,6 @@ def parse_file(file_path, fight_num):
'enemy_Green': 0,
'enemy_Blue': 0,
'enemy_Unk': 0,
'parties_by_fight': {},
}

#collect player counts and parties
Expand Down
2 changes: 1 addition & 1 deletion top_stats_config.ini
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ json_output_filename = None
# json_output_filename overrides the default dbname
db_output_filename = TopStats.db
# write_all_data_to_json toggle writing all accumulated data
write_all_data_to_json = false
write_all_data_to_json = true
#db_update toggle writing to the database
db_update = true
3 changes: 3 additions & 0 deletions tw5_top_stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,9 @@
debuff_list[buff] = debuffs_buffs[buff]
build_uptime_summary(top_stats, debuff_list, buff_data, "Debuffs-In", tid_date_time)

#get squad comp and output table
build_squad_composition(top_stats, tid_date_time, tid_list)


#get heal stats found and output table
build_healing_summary(top_stats, "Heal Stats", tid_date_time)
Expand Down

0 comments on commit 62dc5f2

Please sign in to comment.