Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

friendly_fire for players is not calculated (correctly) #74

Open
Root-DE opened this issue Mar 17, 2024 · 1 comment
Open

friendly_fire for players is not calculated (correctly) #74

Root-DE opened this issue Mar 17, 2024 · 1 comment
Labels
bug Something isn't working to be confirmed

Comments

@Root-DE
Copy link

Root-DE commented Mar 17, 2024

In the ["players"]["all_players"] list returned by the /valorant/v3/by-puuid/matches/{affinity}/{puuid} endpoint, each entry has the behavior dictonary which includes the key friendly_fire among others. However its value is always set to 0, it is possible to calculate it yourself beacuse you can iterate over the damage_events. Here as python example:

import json
import requests

match_id = "0123456789" # CHANGE THIS TO THE MATCH ID YOU WANT TO CHECK

response = json.loads(
    requests.get("https://api.henrikdev.xyz/valorant/v2/match/" + match_id).content
)

for round_num, round in enumerate(response["data"]["rounds"]):
    for player_stats in round["player_stats"]:
        # check if on the same team
        source_team = player_stats["player_team"]
        source_player = player_stats["player_display_name"]
        for damage_event in player_stats["damage_events"]:
            receiver_team = damage_event["receiver_team"]
            receiver_player = damage_event["receiver_display_name"]
            if source_team == receiver_team and not source_player == receiver_player:
                print(
                    f"Friendly fire in round {round_num+1} by {source_player} to {receiver_player} for {damage_event['damage']} damage"
                )
            )
@Henrik-3
Copy link
Owner

Henrik-3 commented May 7, 2024

Do you have an example match ID where the calculation is wrong?

@Henrik-3 Henrik-3 added bug Something isn't working to be confirmed labels May 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working to be confirmed
Projects
None yet
Development

No branches or pull requests

2 participants