Skip to content

Commit

Permalink
add Experimental DPS stats
Browse files Browse the repository at this point in the history
  • Loading branch information
Drevarr committed Dec 10, 2024
1 parent b960cb3 commit 0f3d9fe
Show file tree
Hide file tree
Showing 4 changed files with 92 additions and 3 deletions.
7 changes: 5 additions & 2 deletions Example_Output/Top_Stats_Index.html

Large diffs are not rendered by default.

67 changes: 66 additions & 1 deletion output_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -1291,7 +1291,7 @@ def build_menu_tid(datetime: str) -> None:
text = (
f'<<tabs "[[{datetime}-Overview]] [[{datetime}-General-Stats]] [[{datetime}-Buffs]] '
f'[[{datetime}-Damage-Modifiers]] [[{datetime}-Mechanics]] [[{datetime}-Skill-Usage]] '
f'[[{datetime}-Minions]] [[{datetime}-High-Scores]] [[{datetime}-Top-Damage-By-Skill]] [[{datetime}-Player-Damage-By-Skill]] [[{datetime}-Squad-Composition]] [[{datetime}-On-Tag-Review]]" '
f'[[{datetime}-Minions]] [[{datetime}-High-Scores]] [[{datetime}-Top-Damage-By-Skill]] [[{datetime}-Player-Damage-By-Skill]] [[{datetime}-Squad-Composition]] [[{datetime}-On-Tag-Review]] [[{datetime}-DPS-Stats]]" '
f'"{datetime}-Overview" "$:/temp/menutab1">>'
)

Expand Down Expand Up @@ -1355,6 +1355,23 @@ def build_buffs_stats_tid(datetime):
tid_list
)

def build_dps_stats_menu(datetime):
buff_stats_tags = f"{datetime}"
buff_stats_title = f"{datetime}-DPS-Stats"
buff_stats_caption = f"DPS Stats"
buff_stats_creator = f"[email protected]"
buff_stats_text = "!!!`Experimental DPS stats `\n"
buff_stats_text += "* `Ch (t)s` = Damage/second done `t` seconds before an enemy goes down \n"
buff_stats_text += "* `Bur (t)s` = Maximum damage/second done over any `t` second interval \n"
buff_stats_text += "* `Ch5CaBur (t)s` = Maximum Chunk(5) + Carrion damage/second done over any `t` second interval \n\n"

buff_stats_text += f"<<tabs '[[{datetime}-DPS-Stats-chunkDamage]] [[{datetime}-DPS-Stats-burstDamage]] [[{datetime}-DPS-Stats-ch5CaBurstDamage]]' '{datetime}-DPS-Stats-chunkDamage' '$:/temp/tab1'>>"

append_tid_for_output(
create_new_tid_from_template(buff_stats_title, buff_stats_caption, buff_stats_text, buff_stats_tags, creator=buff_stats_creator),
tid_list
)

def build_boon_stats_tid(datetime):
buff_stats_tags = f"{datetime}"
buff_stats_title = f"{datetime}-Boons"
Expand Down Expand Up @@ -2262,6 +2279,54 @@ def build_on_tag_review(death_on_tag, tid_date_time):
)


def build_dps_stats_tids(DPSStats: dict, tid_date_time: str, tid_list: list) -> None:
exp_dps_stats = {"chunkDamage": "Ch", "burstDamage": "Bur", "ch5CaBurstDamage": "Ch5CaBur"}
sorted_DPSStats = []
for player_prof in DPSStats:
player = DPSStats[player_prof]['name']
profession = DPSStats[player_prof]['profession']
fightTime = DPSStats[player_prof]['duration']

if DPSStats[player_prof]['damageTotal'] / fightTime < 250:
continue
sorted_DPSStats.append([player_prof, DPSStats[player_prof]['damageTotal'] / fightTime])
sorted_DPSStats = sorted(sorted_DPSStats, key=lambda x: x[1], reverse=True)
sorted_DPSStats = list(map(lambda x: x[0], sorted_DPSStats))

for exp_dps_stat in exp_dps_stats:
rows = []

# Set the title, caption and tags for the table
tid_title = f"{tid_date_time}-DPS-Stats-{exp_dps_stat}"
tid_caption = exp_dps_stat
tid_tags = tid_date_time

# Add the select component to the table
rows.append("\n\n|thead-dark table-caption-top table-hover sortable|k")
rows.append(f"| DPS Stats - {exp_dps_stat} |c")
header = "|!Player |!Profession | ! <span data-tooltip=`Number of seconds player was in squad logs`>Seconds</span>| !DPS|"
for i in range(1, 11):
header += f" !{exp_dps_stats[exp_dps_stat]} ({i})s|"
header += "h"
rows.append(header)
for player_prof in sorted_DPSStats:
player = DPSStats[player_prof]["name"]
profession = DPSStats[player_prof]["profession"]
fightTime = DPSStats[player_prof]['duration']
DPS = '<span data-tooltip="'+f"{DPSStats[player_prof]['damageTotal']:,.0f}"+' total damage">'+f"{round(DPSStats[player_prof]['damageTotal'] / fightTime):,.0f}</span>"
row = f"|{player} | {{{{{profession}}}}} | {fightTime} | {DPS} |"
for i in range(1, 11):
row += ' <span data-tooltip="'+f"{DPSStats[player_prof][exp_dps_stat][i]:,.0f}"+f' chunk({i}) damage">'+f"{round(DPSStats[player_prof][exp_dps_stat][i] / fightTime):,.0f}</span>|"

rows.append(row)

text = "\n".join(rows)

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
18 changes: 18 additions & 0 deletions parser_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,8 @@ def calculate_dps_stats(fight_json):
for index, target in enumerate(fight_json['targets']):
if 'enemyPlayer' in target and target['enemyPlayer'] == True:
for player in fight_json['players']:
if player['notInSquad']:
continue
player_prof_name = player['profession'] + " " + player['name']
if player_prof_name not in damage_ps:
damage_ps[player_prof_name] = [0] * fight_ticks
Expand All @@ -350,6 +352,8 @@ def calculate_dps_stats(fight_json):
for fight_tick in range(fight_ticks - 1):
squad_damage_on_tick = 0
for player in fight_json['players']:
if player['notInSquad']:
continue
combat_time = round(sum_breakpoints(get_combat_time_breakpoints(player)) / 1000)
if combat_time:
player_prof_name = player['profession'] + " " + player['name']
Expand All @@ -365,6 +369,8 @@ def calculate_dps_stats(fight_json):
ch5_ca_damage_1s = {}

for player in fight_json['players']:
if player['notInSquad']:
continue
player_prof_name = player['profession'] + " " + player['name']
combat_time = round(sum_breakpoints(get_combat_time_breakpoints(player)) / 1000)
if combat_time:
Expand Down Expand Up @@ -439,6 +445,8 @@ def calculate_dps_stats(fight_json):

squad_damage_on_target = 0
for player in fight_json['players']:
if player['notInSquad']:
continue
combat_time = round(sum_breakpoints(get_combat_time_breakpoints(player)) / 1000)
if combat_time:
player_prof_name = player['profession'] + " " + player['name']
Expand All @@ -453,6 +461,8 @@ def calculate_dps_stats(fight_json):
ch5_ca_damage_1s[player_prof_name][i] += damage_on_target[i + 1] - damage_on_target[i]

for player in fight_json['players']:
if player['notInSquad']:
continue
combat_time = round(sum_breakpoints(get_combat_time_breakpoints(player)) / 1000)
if combat_time:
player_prof_name = player['profession'] + " " + player['name']
Expand All @@ -472,6 +482,8 @@ def calculate_dps_stats(fight_json):

total_carrion_damage = 0
for player in fight_json['players']:
if player['notInSquad']:
continue
combat_time = round(sum_breakpoints(get_combat_time_breakpoints(player)) / 1000)
if combat_time:
player_prof_name = player['profession'] + " " + player['name']
Expand All @@ -485,13 +497,17 @@ def calculate_dps_stats(fight_json):
ch5_ca_damage_1s[player_prof_name][i] += damage_on_target[i + 1] - damage_on_target[i]

for player in fight_json['players']:
if player['notInSquad']:
continue
combat_time = round(sum_breakpoints(get_combat_time_breakpoints(player)) / 1000)
if combat_time:
player_prof_name = player['profession'] + " " + player['name']
DPSStats[player_prof_name]["carrionDamageTotal"] += total_carrion_damage

# Burst damage: max damage done in n seconds
for player in fight_json['players']:
if player['notInSquad']:
continue
combat_time = round(sum_breakpoints(get_combat_time_breakpoints(player)) / 1000)
if combat_time:
player_prof_name = player['profession'] + " " + player['name']
Expand All @@ -503,6 +519,8 @@ def calculate_dps_stats(fight_json):

# Ch5Ca Burst damage: max damage done in n seconds
for player in fight_json['players']:
if player['notInSquad']:
continue
combat_time = round(sum_breakpoints(get_combat_time_breakpoints(player)) / 1000)
if combat_time:
player_prof_name = player['profession'] + " " + player['name']
Expand Down
3 changes: 3 additions & 0 deletions tw5_top_stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,9 @@

build_on_tag_review(death_on_tag, tid_date_time)

build_dps_stats_tids(DPSStats, tid_date_time, tid_list)
build_dps_stats_menu(tid_date_time)

write_tid_list_to_json(tid_list, args.output_filename)

if write_all_data_to_json:
Expand Down

0 comments on commit 0f3d9fe

Please sign in to comment.