Adding best and favorite classes+weapons to the API blob
This commit is contained in:
parent
ce3b03631f
commit
9fdc808445
@ -1,4 +1,4 @@
|
|||||||
import requests, json, pprint, discord
|
import requests, json, pprint, discord, datetime
|
||||||
|
|
||||||
|
|
||||||
def get_player(player):
|
def get_player(player):
|
||||||
@ -25,7 +25,6 @@ def get_player(player):
|
|||||||
# )
|
# )
|
||||||
|
|
||||||
gameplay_stats = {
|
gameplay_stats = {
|
||||||
"bestClass": "Best Class",
|
|
||||||
"mvp": "Times you were an MVP",
|
"mvp": "Times you were an MVP",
|
||||||
"matchesPlayed": "Total games played",
|
"matchesPlayed": "Total games played",
|
||||||
"kills": "Total Kills",
|
"kills": "Total Kills",
|
||||||
@ -48,6 +47,7 @@ def get_player(player):
|
|||||||
"repairs": "Total vehicle damage repaired",
|
"repairs": "Total vehicle damage repaired",
|
||||||
"squadmateRevive": "Squad mate revives",
|
"squadmateRevive": "Squad mate revives",
|
||||||
"vehiclesDestroyed": "Total vehicles destroyed",
|
"vehiclesDestroyed": "Total vehicles destroyed",
|
||||||
|
# "bestClass": ":trophy:Best Class:trophy:",
|
||||||
}
|
}
|
||||||
|
|
||||||
for stat, readable in gameplay_stats.items():
|
for stat, readable in gameplay_stats.items():
|
||||||
@ -56,4 +56,41 @@ def get_player(player):
|
|||||||
value=response[stat],
|
value=response[stat],
|
||||||
inline=True,
|
inline=True,
|
||||||
)
|
)
|
||||||
|
best_weapon = find_best(response["weapons"], "kills")
|
||||||
|
|
||||||
|
embed.add_field(
|
||||||
|
name=":trophy:**Best Weapon**:trophy:",
|
||||||
|
value="%s,\nkills: %s,\naccuracy: %s\nHeadshots:%s"
|
||||||
|
% (
|
||||||
|
best_weapon["weaponName"],
|
||||||
|
best_weapon["kills"],
|
||||||
|
best_weapon["accuracy"],
|
||||||
|
best_weapon["headshotKills"],
|
||||||
|
),
|
||||||
|
inline=True,
|
||||||
|
)
|
||||||
|
|
||||||
|
favorite_class = find_best(response["classes"], "secondsPlayed")
|
||||||
|
|
||||||
|
embed.add_field(
|
||||||
|
name=":trophy:**Favorite Class**:trophy:",
|
||||||
|
value="%s,\nKDR: %s,\nTime Played: %s"
|
||||||
|
% (
|
||||||
|
favorite_class["characterName"],
|
||||||
|
favorite_class["killDeath"],
|
||||||
|
str(datetime.timedelta(seconds=favorite_class["secondsPlayed"])),
|
||||||
|
),
|
||||||
|
inline=True,
|
||||||
|
)
|
||||||
return embed
|
return embed
|
||||||
|
|
||||||
|
|
||||||
|
def find_best(blob, key):
|
||||||
|
"""
|
||||||
|
find_bset(blob, key)
|
||||||
|
blob should be the list within the request you want to find the best of,
|
||||||
|
must be one of [weapopns, vehicles, classes, gamemodes, maps, gadgets], eg response["weapons"],
|
||||||
|
and the key to use to make that distinction, for example, for weapons, you could use kills
|
||||||
|
"""
|
||||||
|
|
||||||
|
return max(blob, key=lambda x: x[key])
|
||||||
|
Loading…
x
Reference in New Issue
Block a user