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

implemented #141 #161

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,12 @@ def program_exit(status: int): # so we don't need to import the entire sys modu
message="Do you want to run vRY now?", default=True
).execute()
if run_app:
os.system('mode 150,35')
os.system('mode 175,35')
os.system('cls')
else:
os._exit(0)
else:
os.system('mode 150,35')
os.system('mode 175,35')
os.system('cls')
except Exception as e:
print("Something went wrong while running configurator!")
Expand Down Expand Up @@ -247,7 +247,7 @@ def program_exit(status: int): # so we don't need to import the entire sys modu
server = "New server"
presences.wait_for_presence(namesClass.get_players_puuid(Players))
names = namesClass.get_names_from_puuids(Players)
loadouts = loadoutsClass.get_match_loadouts(coregame.get_coregame_match_id(), Players, cfg.weapon, valoApiSkins, names, state="game")
loadouts = loadoutsClass.get_match_loadouts(coregame.get_coregame_match_id(), Players, cfg.weapons, valoApiSkins, names, cfg, state="game")
# with alive_bar(total=len(Players), title='Fetching Players', bar='classic2') as bar:
isRange = False
playersLoaded = 1
Expand Down Expand Up @@ -377,7 +377,7 @@ def program_exit(status: int): # so we don't need to import the entire sys modu
# views = get_views(names[player["Subject"]])

# skin
skin = loadouts[player["Subject"]]
skins = loadouts[player["Subject"]]

# RANK
rankName = NUMBERTORANKS[playerRank["rank"]]
Expand Down Expand Up @@ -414,7 +414,7 @@ def program_exit(status: int): # so we don't need to import the entire sys modu
agent,
name,
# views,
skin,
*[skins[weapon] for weapon in cfg.weapons],
rankName,
rr,
peakRank,
Expand Down Expand Up @@ -689,8 +689,10 @@ def program_exit(status: int): # so we don't need to import the entire sys modu

if game_state == "MENUS":
table.set_runtime_col_flag('Party', False)
table.set_runtime_col_flag('Agent',False)
table.set_runtime_col_flag('Skin',False)
table.set_runtime_col_flag('Agent', False)
for weapon in cfg.weapons:
table.set_runtime_col_flag(weapon, False)


if game_state == "INGAME":
if isRange:
Expand Down
35 changes: 23 additions & 12 deletions src/Loadouts.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def __init__(self, Requests, log, colors, Server):
# self.namesClass = namesClass
self.Server = Server

def get_match_loadouts(self, match_id, players, weaponChoose, valoApiSkins, names, state="game"):
def get_match_loadouts(self, match_id, players, weaponChoose, valoApiSkins, names, cfg, state="game"):
playersBackup = players
weaponLists = {}
valApiWeapons = requests.get("https://valorant-api.com/v1/weapons").json()
Expand All @@ -34,18 +34,29 @@ def get_match_loadouts(self, match_id, players, weaponChoose, valoApiSkins, name
inv = PlayerInventorys["Loadouts"][invindex]
if state == "game":
inv = inv["Loadout"]

weaponLists[players[player]["Subject"]] = {}
for weapon in valApiWeapons["data"]:
if weapon["displayName"].lower() == weaponChoose.lower():
skin_id = \
inv["Items"][weapon["uuid"].lower()]["Sockets"]["bcef87d6-209b-46c6-8b19-fbe40bd95abc"]["Item"][
"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)
# if rgb_color is not None:
weaponLists.update({players[player]["Subject"]: color(skin["displayName"], fore=rgb_color)})
# else:
# weaponLists.update({player["Subject"]: color(skin["Name"], fore=rgb_color)})
if weapon["displayName"].lower() not in [weapon.lower() for weapon in weaponChoose]:
continue
skin_id = \
inv["Items"][weapon["uuid"].lower()]["Sockets"]["bcef87d6-209b-46c6-8b19-fbe40bd95abc"]["Item"]["ID"]

for skin in valoApiSkins.json()["data"]:
if skin_id.lower() != skin["uuid"].lower():
continue
rgb_color = self.colors.get_rgb_color_from_skin(skin["uuid"].lower(), valoApiSkins)
# if rgb_color is not None:
skin_name = skin["displayName"]
if cfg.hide_skin_weapon_suffix:
skin_name = " ".join(skin["displayName"].split(" ")[0:-1])
if cfg.skin_abbreviations["status"]:
skin_name = cfg.skin_abbreviations["abbreviations"].get(skin_name, skin_name)

weaponLists[players[player]["Subject"]][weapon["displayName"]] = (color(skin_name, fore=rgb_color))
# else:
# weaponLists.update({player["Subject"]: color(skin["Name"], fore=rgb_color)})

final_json = self.convertLoadoutToJsonArray(PlayerInventorys, playersBackup, state, names)
# self.log(f"json for website: {final_json}")
self.Server.send_message(json.dumps(final_json))
Expand Down
22 changes: 13 additions & 9 deletions src/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,12 @@ def __init__(self, log):

self.log(f"got cooldown with value '{self.cooldown}'")

if not self.weapon_check(config["weapon"]):
self.weapon = "vandal" # if the user manually entered a wrong name into the config file, this will be the default until changed by the user.
else:
self.weapon = config["weapon"]
weapons = [weapon.strip() for weapon in config["weapons"].split(",")]
if not self.weapon_checks(weapons):
self.weapons = ["vandal"] # if the user manually entered a wrong name into the config file, this will be the default until changed by the user.
self.log(f"Invalid weapon name in config, defaulting to vandal")
else:
self.weapons = weapons

def get_feature_flag(self,key):
return self.__dict__.get("flags",DEFAULT_CONFIG["flags"]).get(key,DEFAULT_CONFIG["flags"][key])
Expand All @@ -71,8 +73,10 @@ def config_dialog(self, fileToWrite: TextIOWrapper):
json.dump(jsonToWrite, fileToWrite, indent=4)
return jsonToWrite

def weapon_check(self, name):
if name in [weapon["displayName"] for weapon in requests.get("https://valorant-api.com/v1/weapons").json()["data"]]:
return True
else:
return False
def weapon_checks(self, names):
weapon_data = requests.get("https://valorant-api.com/v1/weapons").json()["data"]
weapon_names = [weapon["displayName"] for weapon in weapon_data]
for name in names:
if name not in weapon_names:
return False
return True
18 changes: 17 additions & 1 deletion src/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,24 @@
DEFAULT_CONFIG = {
"cooldown": 10,
"port": 1100,
"weapon": "Vandal",
"weapons": "Vandal, Phantom",
"chat_limit": 5,
"hide_skin_weapon_suffix": True,
"skin_abbreviations": {
"status": True,
"abbreviations": {
"Gravitational Uranium Neuroblaster": "GUN",
"Radiant Entertainment System": "RES",
"VALORANT GO! Vol. 1": "V. G. Vol. 1",
"VALORANT GO! Vol. 2": "V. G. Vol. 2",
"Radiant Crisis 001": "RC 001",
"Sentinels of Light": "SoL",
"Prelude to Chaos": "PtC",
"Winterwunderland": "Winter",
"Kohaku & Matsuba": "K&M",
"Gaia's Vengeance": "Gaia"
}
},
Comment on lines +159 to +174
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"table": {
"skin": True,
"rr": True,
Expand Down
14 changes: 11 additions & 3 deletions src/table.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,19 @@
from rich.table import Table as RichTable
from rich.console import Console as RichConsole

TABLE_COLUMN_NAMES = Literal[
from src.config import Config
from src.logs import Logging


Logging = Logging()
log = Logging.log
cfg = Config(log)

TABLE_COLUMN_NAMES = Literal [
"Party",
"Agent",
"Name",
"Skin",
*[weapon for weapon in cfg.weapons],
"Rank",
"RR",
"Peak Rank",
Expand All @@ -29,7 +37,7 @@ def __init__(self, config, chatlog, log):
True, # Party
True, # Agent
True, # Name
bool(config.table.get("skin", True)), # Skin
*([True for _ in cfg.weapons] if len(cfg.weapons) > 0 else [False]),
True, # Rank
bool(config.table.get("rr", True)), # RR
bool(config.table.get("peakrank", True)), # Peak Rank
Expand Down