Skip to content

Commit

Permalink
Fix div zero high score stat by key
Browse files Browse the repository at this point in the history
Update caption output
  • Loading branch information
Drevarr committed Nov 17, 2024
1 parent 1f3b07f commit 39e347e
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 10 deletions.
Binary file modified Top_Stats.db
Binary file not shown.
20 changes: 16 additions & 4 deletions output_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ def build_tag_summary(top_stats):
"""
tag_summary = {}

tag_list = []
for fight, fight_data in top_stats["fight"].items():
commander = fight_data["commander"]
if commander not in tag_summary:
Expand All @@ -282,6 +282,8 @@ def build_tag_summary(top_stats):
"squad_downed": 0,
"squad_deaths": 0,
}
if commander.split("|")[0] not in tag_list:
tag_list.append(commander.split("|")[0])

tag_summary[commander]["num_fights"] += 1
tag_summary[commander]["fight_time"] += fight_data["fight_durationMS"]
Expand All @@ -290,7 +292,7 @@ def build_tag_summary(top_stats):
tag_summary[commander]["squad_downed"] += fight_data["defenses"]["downCount"]
tag_summary[commander]["squad_deaths"] += fight_data["defenses"]["deadCount"]

return tag_summary
return tag_summary, tag_list

def output_tag_summary(tag_summary: dict, tid_date_time) -> None:
"""Output a summary of the tag data in a human-readable format."""
Expand Down Expand Up @@ -1227,12 +1229,22 @@ def build_combat_resurrection_stats_tid(top_stats: dict, skill_data: dict, buff_
tid_list
)

def build_main_tid(datetime):
def build_main_tid(datetime, tag_list, guild_name):
tag_str = ""
for tag in tag_list:
if tag == tag_list[-1] and len(tag_list) > 1:
tag_str += f"and {tag}"
if tag != tag_list[-1] and len(tag_list) > 1:
tag_str += f"{tag}, "
if len(tag_list) == 1:
tag_str += f"{tag} "


main_created = f"{datetime}"
main_modified = f"{datetime}"
main_tags = f"{datetime} Logs"
main_title = f"{datetime}-Log-Summary"
main_caption = f"{datetime} - Log Summary"
main_caption = f"{datetime} - {guild_name} - Log Summary with {tag_str}"
main_creator = f"[email protected]"

main_text = "{{"+datetime+"-Tag_Stats}}\n\n{{"+datetime+"-Menu}}"
Expand Down
3 changes: 2 additions & 1 deletion parser_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,8 @@ def get_stat_by_key(fight_num: int, player: dict, stat_category: str, name_prof:
"""
for stat, value in player[stat_category][0].items():
if stat in config.high_scores:
high_score_value = round(value/(player['activeTimes'][0]/1000),3)
active_time_seconds = player['activeTimes'][0] / 1000
high_score_value = round(value / active_time_seconds, 3) if active_time_seconds > 0 else 0
update_high_score(f"{stat_category}_{stat}", "{{"+player["profession"]+"}}"+player["name"]+"-"+str(fight_num)+" | "+stat, high_score_value)
top_stats['player'][name_prof][stat_category][stat] = top_stats['player'][name_prof][stat_category].get(stat, 0) + value
top_stats['fight'][fight_num][stat_category][stat] = top_stats['fight'][fight_num][stat_category].get(stat, 0) + value
Expand Down
10 changes: 5 additions & 5 deletions tw5_top_stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,12 @@

print("Parsing Complete")

tag_data, tag_list = build_tag_summary(top_stats)

#create the main tiddler and append to tid_list
build_main_tid(tid_date_time)
build_main_tid(tid_date_time, tag_list, guild_name)

output_tag_summary(tag_data, tid_date_time)

#create the menu tiddler and append to tid_list
build_menu_tid(tid_date_time)
Expand Down Expand Up @@ -254,10 +258,6 @@
build_gear_buff_summary(top_stats, gear_buff_ids, buff_data, tid_date_time)
build_gear_skill_summary(top_stats, gear_skill_ids, skill_data, tid_date_time)

tag_data = build_tag_summary(top_stats)
output_tag_summary(tag_data, tid_date_time)


build_damage_summary_table(top_stats, "Damage", tid_date_time)

write_tid_list_to_json(tid_list, args.output_filename)
Expand Down

0 comments on commit 39e347e

Please sign in to comment.