Skip to content

Commit

Permalink
Beautify
Browse files Browse the repository at this point in the history
  • Loading branch information
scottjsh committed Apr 28, 2024
1 parent 485e449 commit f3f0965
Show file tree
Hide file tree
Showing 29 changed files with 774 additions and 600 deletions.
373 changes: 204 additions & 169 deletions main.py

Large diffs are not rendered by default.

9 changes: 5 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,16 @@

build_exe_options = {
"path": sys.path,
"include_files":['configurator.bat'],
"include_files": ['configurator.bat'],
"packages": ["requests", "colr", "InquirerPy", "websockets", "pypresence", "nest_asyncio", "rich", "websocket_server"],
"excludes": ["tkinter", "test", "unittest", "pygments", "xmlrpc"]
}

setup(
name = "ValoAssist",
version = version,
name="ValoAssist",
version=version,
description='VAS - ValoAssist',
executables = [Executable("main.py", icon="./assets/Logo.ico", target_name="VAS.exe")],
executables=[Executable(
"main.py", icon="./assets/Logo.ico", target_name="VAS.exe")],
options={"build_exe": build_exe_options}
)
86 changes: 52 additions & 34 deletions src/Loadouts.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,22 @@ def __init__(self, Requests, log, colors, Server, current_map):
def get_match_loadouts(self, match_id, players, weaponChoose, valoApiSkins, names, state="game"):
playersBackup = players
weaponLists = {}
valApiWeapons = requests.get("https://valorant-api.com/v1/weapons").json()
valApiWeapons = requests.get(
"https://valorant-api.com/v1/weapons").json()
if state == "game":
team_id = "Blue"
PlayerInventorys = self.Requests.fetch("glz", f"/core-game/v1/matches/{match_id}/loadouts", "get")
PlayerInventorys = self.Requests.fetch(
"glz", f"/core-game/v1/matches/{match_id}/loadouts", "get")
elif state == "pregame":
pregame_stats = players
players = players["AllyTeam"]["Players"]
team_id = pregame_stats['Teams'][0]['TeamID']
PlayerInventorys = self.Requests.fetch("glz", f"/pregame/v1/matches/{match_id}/loadouts", "get")
PlayerInventorys = self.Requests.fetch(
"glz", f"/pregame/v1/matches/{match_id}/loadouts", "get")
for player in range(len(players)):
if team_id == "Red":
invindex = player + len(players) - len(PlayerInventorys["Loadouts"])
invindex = player + len(players) - \
len(PlayerInventorys["Loadouts"])
else:
invindex = player
inv = PlayerInventorys["Loadouts"][invindex]
Expand All @@ -41,26 +45,31 @@ def get_match_loadouts(self, match_id, players, weaponChoose, valoApiSkins, name
"ID"]
for skin in valoApiSkins.json()["data"]:
if skin_id.lower() == skin["uuid"].lower():
rgb_color = self.colors.get_rgb_color_from_skin(skin["uuid"].lower(), valoApiSkins)
rgb_color = self.colors.get_rgb_color_from_skin(
skin["uuid"].lower(), valoApiSkins)
# if rgb_color is not None:
weaponLists.update({players[player]["Subject"]: color(skin["displayName"], fore=rgb_color)})
weaponLists.update({players[player]["Subject"]: color(
skin["displayName"], fore=rgb_color)})
# else:
# weaponLists.update({player["Subject"]: color(skin["Name"], fore=rgb_color)})
final_json = self.convertLoadoutToJsonArray(PlayerInventorys, playersBackup, state, names)
final_json = self.convertLoadoutToJsonArray(
PlayerInventorys, playersBackup, state, names)
# self.log(f"json for website: {final_json}")
self.Server.send_payload("matchLoadout",final_json)
return [weaponLists,final_json]
self.Server.send_payload("matchLoadout", final_json)
return [weaponLists, final_json]

#this will convert valorant loadouts to json with player names
# this will convert valorant loadouts to json with player names
def convertLoadoutToJsonArray(self, PlayerInventorys, players, state, names):
#get agent dict from main in future
# get agent dict from main in future
# names = self.namesClass.get_names_from_puuids(players)
valoApiSprays = requests.get("https://valorant-api.com/v1/sprays")
valoApiWeapons = requests.get("https://valorant-api.com/v1/weapons")
valoApiBuddies = requests.get("https://valorant-api.com/v1/buddies")
valoApiAgents = requests.get("https://valorant-api.com/v1/agents")
valoApiTitles = requests.get("https://valorant-api.com/v1/playertitles")
valoApiPlayerCards = requests.get("https://valorant-api.com/v1/playercards")
valoApiTitles = requests.get(
"https://valorant-api.com/v1/playertitles")
valoApiPlayerCards = requests.get(
"https://valorant-api.com/v1/playercards")

final_final_json = {"Players": {},
"time": int(time.time()),
Expand All @@ -77,36 +86,43 @@ def convertLoadoutToJsonArray(self, PlayerInventorys, players, state, names):
}
)

#creates name field
# creates name field
if hide_names:
for agent in valoApiAgents.json()["data"]:
if agent["uuid"] == players[i]["CharacterID"]:
final_json[players[i]["Subject"]].update({"Name": agent["displayName"]})
final_json[players[i]["Subject"]].update(
{"Name": agent["displayName"]})
else:
final_json[players[i]["Subject"]].update({"Name": names[players[i]["Subject"]]})
final_json[players[i]["Subject"]].update(
{"Name": names[players[i]["Subject"]]})

#creates team field
final_json[players[i]["Subject"]].update({"Team": players[i]["TeamID"]})
# creates team field
final_json[players[i]["Subject"]].update(
{"Team": players[i]["TeamID"]})

#create spray field
# create spray field
final_json[players[i]["Subject"]].update({"Sprays": {}})
#append sprays to field
# append sprays to field

final_json[players[i]["Subject"]].update({"Level": players[i]["PlayerIdentity"]["AccountLevel"]})
final_json[players[i]["Subject"]].update(
{"Level": players[i]["PlayerIdentity"]["AccountLevel"]})

for title in valoApiTitles.json()["data"]:
if title["uuid"] == players[i]["PlayerIdentity"]["PlayerTitleID"]:
final_json[players[i]["Subject"]].update({"Title": title["titleText"]})

final_json[players[i]["Subject"]].update(
{"Title": title["titleText"]})

for PCard in valoApiPlayerCards.json()["data"]:
if PCard["uuid"] == players[i]["PlayerIdentity"]["PlayerCardID"]:
final_json[players[i]["Subject"]].update({"PlayerCard": PCard["largeArt"]})
final_json[players[i]["Subject"]].update(
{"PlayerCard": PCard["largeArt"]})

for agent in valoApiAgents.json()["data"]:
if agent["uuid"] == players[i]["CharacterID"]:
final_json[players[i]["Subject"]].update({"AgentArtworkName": agent["displayName"] + "Artwork"})
final_json[players[i]["Subject"]].update({"Agent": agent["displayIcon"]})
final_json[players[i]["Subject"]].update(
{"AgentArtworkName": agent["displayName"] + "Artwork"})
final_json[players[i]["Subject"]].update(
{"Agent": agent["displayIcon"]})

for j in range(len(PlayerInventory["Sprays"]["SpraySelections"])):
spray = PlayerInventory["Sprays"]["SpraySelections"][j]
Expand All @@ -119,16 +135,17 @@ def convertLoadoutToJsonArray(self, PlayerInventorys, players, state, names):
"fullTransparentIcon": sprayValApi["fullTransparentIcon"]
})

#create weapons field
# create weapons field
final_json[players[i]["Subject"]].update({"Weapons": {}})

for skin in PlayerInventory["Items"]:

#create skin field
final_json[players[i]["Subject"]]["Weapons"].update({skin: {}})
# create skin field
final_json[players[i]["Subject"]
]["Weapons"].update({skin: {}})

for socket in PlayerInventory["Items"][skin]["Sockets"]:
#predefined sockets
# predefined sockets
for var_socket in sockets:
if socket == sockets[var_socket]:
final_json[players[i]["Subject"]]["Weapons"][skin].update(
Expand All @@ -137,11 +154,11 @@ def convertLoadoutToJsonArray(self, PlayerInventorys, players, state, names):
}
)

#create buddy field
# create buddy field
# self.log("predefined sockets")
# final_json[players[i]["Subject"]]["Weapons"].update({skin: {}})

#buddies
# buddies
for socket in PlayerInventory["Items"][skin]["Sockets"]:
if sockets["skin_buddy"] == socket:
for buddy in valoApiBuddies.json()["data"]:
Expand All @@ -152,7 +169,7 @@ def convertLoadoutToJsonArray(self, PlayerInventorys, players, state, names):
}
)

#append names to field
# append names to field
for weapon in valoApiWeapons.json()["data"]:
if skin == weapon["uuid"]:
final_json[players[i]["Subject"]]["Weapons"][skin].update(
Expand Down Expand Up @@ -194,6 +211,7 @@ def convertLoadoutToJsonArray(self, PlayerInventorys, players, state, names):
}
)
if skinValApi["displayName"].startswith("Standard") or skinValApi["displayName"].startswith("Melee"):
final_json[players[i]["Subject"]]["Weapons"][skin]["skinDisplayIcon"] = weapon["displayIcon"]
final_json[players[i]["Subject"]
]["Weapons"][skin]["skinDisplayIcon"] = weapon["displayIcon"]

return final_final_json
Loading

0 comments on commit f3f0965

Please sign in to comment.