Skip to content

Commit

Permalink
Display player on tag review
Browse files Browse the repository at this point in the history
  • Loading branch information
Drevarr committed Nov 21, 2024
1 parent f5bb775 commit eddbd7c
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 9 deletions.
36 changes: 35 additions & 1 deletion output_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -1282,7 +1282,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]]" '
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}-Overview" "$:/temp/menutab1">>'
)

Expand Down Expand Up @@ -2137,7 +2137,41 @@ def build_squad_composition(top_stats: dict, tid_date_time: str, tid_list: list)
)


def build_on_tag_review(death_on_tag, tid_date_time):
rows = []
# Set the title, caption and tags for the table
tid_title = f"{tid_date_time}-On-Tag-Review"
tid_caption = "Player On Tag Review"
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("| On Tag Review |c")
header = "|!Player |!Profession | !Avg Dist| !On-Tag<br>{{deadCount}} | !Off-Tag<br>{{deadCount}} | !After-Tag<br>{{deadCount}} | !Run-Back<br>{{deadCount}} | !Total<br>{{deadCount}} |!OffTag Ranges|h"
rows.append(header)
for name_prof in death_on_tag:
player = death_on_tag[name_prof]['name']
profession = death_on_tag[name_prof]['profession']
avg_dist = round(sum(death_on_tag[name_prof]['distToTag']) / len(death_on_tag[name_prof]['distToTag']))
on_tag = death_on_tag[name_prof]['On_Tag']
off_tag = death_on_tag[name_prof]['Off_Tag']
after_tag = death_on_tag[name_prof]['After_Tag_Death']
run_back = death_on_tag[name_prof]['Run_Back']
total = death_on_tag[name_prof]['Total']
off_tag_ranges = death_on_tag[name_prof]['Ranges']
row = f"|{player} | {{{{{profession}}}}} | {avg_dist} | {on_tag} | {off_tag} | {after_tag} | {run_back} | {total} |{off_tag_ranges} |"
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")
"""Write the top_stats dictionary to the database."""
conn = sqlite3.connect('Top_Stats.db')
Expand Down
16 changes: 8 additions & 8 deletions parser_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,12 +169,13 @@ def get_player_death_on_tag(player, commander_tag_positions, dead_tag_mark, dead
"After_Tag_Death": 0,
"Total": 0,
"Ranges": [],
}
}

player_dist_to_tag = round(player['statsAll'][0]['distToCom'])

if player['combatReplayData']['dead'] and player['combatReplayData']['down']:
player_deaths = dict(player['combatReplayData']['dead'])
player_downs = dict(player['combatReplayData']['down'])
player_dist_to_tag = player['statsAll'][0]['distToCom']

for death_key, death_value in player_deaths.items():
if death_key < 0: # Handle death on the field before main squad combat log starts
Expand All @@ -191,8 +192,7 @@ def get_player_death_on_tag(player, commander_tag_positions, dead_tag_mark, dead
x2, y2 = commander_tag_positions[position_mark]
#y2 = commander_tag_positions[position_mark][1]
death_distance = math.sqrt((x1 - x2) ** 2 + (y1 - y2) ** 2)
death_range = death_distance / inch_to_pixel

death_range = round(death_distance / inch_to_pixel)
death_on_tag[name_prof]["Total"] += 1

if int(down_key) > int(dead_tag_mark) and dead_tag:
Expand All @@ -206,7 +206,7 @@ def get_player_death_on_tag(player, commander_tag_positions, dead_tag_mark, dead
delta_y = position[1] - tag_position[1]
player_distances.append(math.sqrt(delta_x * delta_x + delta_y * delta_y))

player_dist_to_tag = (sum(player_distances) / len(player_distances)) / inch_to_pixel
player_dist_to_tag = round((sum(player_distances) / len(player_distances)) / inch_to_pixel)
else:
player_dead_poll = position_mark
player_positions = player['combatReplayData']['positions']
Expand All @@ -216,7 +216,7 @@ def get_player_death_on_tag(player, commander_tag_positions, dead_tag_mark, dead
delta_y = position[1] - tag_position[1]
player_distances.append(math.sqrt(delta_x * delta_x + delta_y * delta_y))

player_dist_to_tag = (sum(player_distances) / len(player_distances)) / inch_to_pixel
player_dist_to_tag = round((sum(player_distances) / len(player_distances)) / inch_to_pixel)

if death_range <= On_Tag:
death_on_tag[name_prof]["On_Tag"] += 1
Expand All @@ -228,8 +228,8 @@ def get_player_death_on_tag(player, commander_tag_positions, dead_tag_mark, dead
if death_range > Run_Back:
death_on_tag[name_prof]["Run_Back"] += 1

if player_dist_to_tag <= Run_Back:
death_on_tag[name_prof]["distToTag"].append(player_dist_to_tag)
if player_dist_to_tag <= Run_Back:
death_on_tag[name_prof]["distToTag"].append(player_dist_to_tag)



Expand Down
2 changes: 2 additions & 0 deletions tw5_top_stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,8 @@

build_damage_summary_table(top_stats, "Damage", tid_date_time)

build_on_tag_review(death_on_tag, 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 eddbd7c

Please sign in to comment.