From 68fb2bc3ace332fb04d6f674005fa92fc0f62d9a Mon Sep 17 00:00:00 2001 From: JanEickholt Date: Mon, 31 Jul 2023 06:00:10 +0200 Subject: [PATCH 1/6] implemented #141 usage in config: "weapons": "Vandal, Phantom, ..." https://legende.cc/ss/9670865ba4.png --- main.py | 16 +++++++++------- src/Loadouts.py | 27 ++++++++++++++++----------- src/config.py | 22 +++++++++++++--------- src/constants.py | 2 +- src/table.py | 14 +++++++++++--- 5 files changed, 50 insertions(+), 31 deletions(-) diff --git a/main.py b/main.py index 80d7ff48..e9a721d0 100644 --- a/main.py +++ b/main.py @@ -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!") @@ -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, state="game") # with alive_bar(total=len(Players), title='Fetching Players', bar='classic2') as bar: isRange = False playersLoaded = 1 @@ -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"]] @@ -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, @@ -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: diff --git a/src/Loadouts.py b/src/Loadouts.py index 13326fa3..58acf43a 100644 --- a/src/Loadouts.py +++ b/src/Loadouts.py @@ -34,18 +34,23 @@ 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: + weaponLists[players[player]["Subject"]][weapon["displayName"]] = (color(" ".join(skin["displayName"].split(" ")[0:-1]), 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)) diff --git a/src/config.py b/src/config.py index 83f0b009..73f1cd26 100644 --- a/src/config.py +++ b/src/config.py @@ -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]) @@ -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 \ No newline at end of file diff --git a/src/constants.py b/src/constants.py index cef85867..904369af 100644 --- a/src/constants.py +++ b/src/constants.py @@ -154,7 +154,7 @@ DEFAULT_CONFIG = { "cooldown": 10, "port": 1100, - "weapon": "Vandal", + "weapons": "Vandal, Phantom", "chat_limit": 5, "table": { "skin": True, diff --git a/src/table.py b/src/table.py index 05d3d4c4..9a69b08c 100644 --- a/src/table.py +++ b/src/table.py @@ -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", @@ -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 From f6aa5cd37f25e6cc2c52ab1eb12cc8176677a362 Mon Sep 17 00:00:00 2001 From: JanEickholt Date: Mon, 31 Jul 2023 19:12:20 +0200 Subject: [PATCH 2/6] added some abbreviations, made hiding the weapon suffix optional via the config --- main.py | 2 +- src/Loadouts.py | 10 ++++++++-- src/constants.py | 16 ++++++++++++++++ 3 files changed, 25 insertions(+), 3 deletions(-) diff --git a/main.py b/main.py index e9a721d0..6e1d1b71 100644 --- a/main.py +++ b/main.py @@ -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.weapons, 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 diff --git a/src/Loadouts.py b/src/Loadouts.py index 58acf43a..6667af5c 100644 --- a/src/Loadouts.py +++ b/src/Loadouts.py @@ -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() @@ -47,7 +47,13 @@ def get_match_loadouts(self, match_id, players, weaponChoose, valoApiSkins, name continue rgb_color = self.colors.get_rgb_color_from_skin(skin["uuid"].lower(), valoApiSkins) # if rgb_color is not None: - weaponLists[players[player]["Subject"]][weapon["displayName"]] = (color(" ".join(skin["displayName"].split(" ")[0:-1]), fore=rgb_color)) + 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)}) diff --git a/src/constants.py b/src/constants.py index 904369af..649d5890 100644 --- a/src/constants.py +++ b/src/constants.py @@ -156,6 +156,22 @@ "port": 1100, "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" + } + }, "table": { "skin": True, "rr": True, From 08f12e9d16ad5de9b944dfe060a0dd63d4f3da56 Mon Sep 17 00:00:00 2001 From: JanEickholt Date: Tue, 1 Aug 2023 14:09:14 +0200 Subject: [PATCH 3/6] bugfix, weapon fields are now "clear" while in agent select --- main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.py b/main.py index 6e1d1b71..f1d78312 100644 --- a/main.py +++ b/main.py @@ -573,7 +573,7 @@ def program_exit(status: int): # so we don't need to import the entire sys modu agent, name, # views, - "", + *["" for _ in cfg.weapons], rankName, rr, peakRank, From 2f17a21cef3a0672bd80501524d019f5541c6e87 Mon Sep 17 00:00:00 2001 From: JanEickholt Date: Tue, 1 Aug 2023 21:56:43 +0200 Subject: [PATCH 4/6] bugfix, weapon fields are now hidden correctly while in menu --- main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.py b/main.py index f1d78312..0b86dad2 100644 --- a/main.py +++ b/main.py @@ -663,7 +663,7 @@ def program_exit(status: int): # so we don't need to import the entire sys modu table.add_row_table([party_icon, agent, name, - "", + *["" for weapon in cfg.weapons], rankName, rr, peakRank, From 01cb347be788e1a87e8194ca1ac97832c9609c7f Mon Sep 17 00:00:00 2001 From: JanEickholt Date: Wed, 2 Aug 2023 14:51:54 +0200 Subject: [PATCH 5/6] added option to choose from multiple weapons with the --config tag added all weapon skins to the abbreviations list, that are longer than 10 characters (suggestions wanted) --- src/config.py | 2 +- src/configurator.py | 16 ++++++- src/constants.py | 102 +++++++++++++++++++++++++++----------------- src/questions.py | 26 +++++++---- 4 files changed, 95 insertions(+), 51 deletions(-) diff --git a/src/config.py b/src/config.py index 73f1cd26..8511cdfe 100644 --- a/src/config.py +++ b/src/config.py @@ -55,7 +55,7 @@ def __init__(self, log): 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.weapons = ["vandal", "phantom"] # 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 diff --git a/src/configurator.py b/src/configurator.py index bd57a51b..042fc425 100644 --- a/src/configurator.py +++ b/src/configurator.py @@ -34,6 +34,15 @@ def configure(): "Exit Configurator" ] + def weapon_prompt(cfg): + cfg |= prompt(weapon_amount_question(config=cfg)) + weapons = [] + for i in range(cfg["weapon_amount"]): + cfg |= prompt(weapon_question(config=cfg, index=i)) + weapons.append(cfg[f"weapon"]) + cfg["weapons"] = ", ".join(weapons) + return cfg + changed_config = {} while True: loop_config = user_config | changed_config @@ -45,17 +54,20 @@ def configure(): ).execute() if choice is menu_choices[0]: - changed_config |= prompt([weapon_question(config=loop_config)]) + changed_config |= weapon_prompt(loop_config) elif choice is menu_choices[1]: changed_config |= prompt([table_question(config=loop_config)]) elif choice is menu_choices[2]: changed_config |= prompt([flags_question(config=loop_config)]) elif choice is menu_choices[4]: + changed_config |= weapon_prompt(loop_config) changed_config |= prompt(basic_questions(config=loop_config)) elif choice is menu_choices[5]: changed_config |= prompt(advance_questions(config=loop_config)) + changed_config |= weapon_prompt(loop_config) + changed_config |= prompt(basic_questions(config=loop_config)) elif choice is menu_choices[7]: - proceed=True + proceed = True break else: proceed = (not len(changed_config.keys()) > 0) or inquirer.confirm( diff --git a/src/constants.py b/src/constants.py index 584d145d..a3d9322b 100644 --- a/src/constants.py +++ b/src/constants.py @@ -152,44 +152,68 @@ ] DEFAULT_CONFIG = { - "cooldown": 10, - "port": 1100, - "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" - } - }, - "table": { - "skin": True, - "rr": True, - "peakrank": True, - "previousrank" : False, - "leaderboard": True, - "headshot_percent": True, - "winrate": True, - "kd": False, - "level": True - }, - "flags": { - "last_played": True, - "auto_hide_leaderboard": True, - "pre_cls": False, - "game_chat": True, - "peak_rank_act": True, - "discord_rpc": True, - "aggregate_rank_rr": True + "cooldown": 10, + "port": 1100, + "weapon_amount": 2, + "weapons": "Vandal, Phantom", + "chat_limit": 5, + "hide_skin_weapon_suffix": True, + "skin_abbreviations": { + "status": True, + "abbreviations": { + "Gravitational Uranium Neuroblaster": "G.U.N.", + "Radiant Entertainment System": "R.E.S.", + "VALORANT GO! Vol. 1": "Val. Go! 1", + "VALORANT GO! Vol. 2": "Val. Go! 2", + "Radiant Crisis 001": "R.C. 001", + "Sentinels of Light": "SoL", + "Premiere Collision": "Premiere", + "Kohaku & Matsuba": "K&M", + "Winterwunderland": "Winter", + "Gaia's Vengeance": "Gaia", + "Prelude to Chaos": "Chaos", + "Coalition: Cobra": "Cobra", + "Nunca Olvidados": "Nunca", + "Tethered Realms": "Tethered", + "Starlit Odyssey": "Odyssey", + "Protocol 781-A": "Protocol", + "Champions 2021": "Champ 2021", + "Champions 2022": "Champ 2022", + "Champions 2023": "Champ 2023", + "Piedra del Sol": "Piedra", + "Task Force 809": "Task Force", + "Iridian Thorn": "Iridian", + "Black.Market": "Black M.", + "Crimsonbeast": "Crimson", + "Neo Frontier": "Neo", + "VCT LOCK//IN": "VCT", + "Divine Swine": "Swine", + "Immortalized": "Immortal", + "Lycan's Bane": "Lycan", + "Doodle Buds": "Doodle", + "RGX 11z Pro": "RGX 11z", + "Singularity": "Sing.", + "Monstrocity": "Monst.", } + }, + "table": { + "skin": True, + "rr": True, + "peakrank": True, + "previousrank" : False, + "leaderboard": True, + "headshot_percent": True, + "winrate": True, + "kd": False, + "level": True + }, + "flags": { + "last_played": True, + "auto_hide_leaderboard": True, + "pre_cls": False, + "game_chat": True, + "peak_rank_act": True, + "discord_rpc": True, + "aggregate_rank_rr": True } +} diff --git a/src/questions.py b/src/questions.py index c747e694..a144a0e9 100644 --- a/src/questions.py +++ b/src/questions.py @@ -23,13 +23,22 @@ "aggregate_rank_rr": "Display Rank and Ranked Rating in the same column" } -weapon_question = lambda config: { - "type": "fuzzy", - "name": "weapon", - "message": "Please select a weapon to show skin for:", - "default": config.get("weapon","Vandal"), - "choices": WEAPONS, - } +weapon_amount_question = lambda config: { + "type": "number", + "name": "weapon_amount", + "message": "Please select the amount of weapons to display:", + "min_allowed": 0, + "max_allowed": 100, + "filter": lambda ans: int(ans) +} + +weapon_question = lambda config, index: { + "type": "fuzzy", + "name": f"weapon", + "message": f"Please select a weapon to display at position {index + 1}:", + "choices": WEAPONS +} + table_question = lambda config: { "type": "checkbox", @@ -76,11 +85,10 @@ } basic_questions = lambda config: [ - weapon_question(config=config), table_question(config=config), chat_limit_question(config=config) ] advance_questions = lambda config: [ port_question(config=config), -] + basic_questions(config=config) +] From 73badf1127e14e846e5e147e2f8ecd089499aae2 Mon Sep 17 00:00:00 2001 From: JanEickholt Date: Wed, 30 Aug 2023 13:56:13 +0200 Subject: [PATCH 6/6] removed skin abbreviations for now --- src/Loadouts.py | 6 +----- src/constants.py | 38 -------------------------------------- 2 files changed, 1 insertion(+), 43 deletions(-) diff --git a/src/Loadouts.py b/src/Loadouts.py index 2751ad17..63a5f89e 100644 --- a/src/Loadouts.py +++ b/src/Loadouts.py @@ -47,11 +47,7 @@ def get_match_loadouts(self, match_id, players, weaponChoose, valoApiSkins, name 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) + skin_name = " ".join(skin["displayName"].split(" ")[0:-1]) weaponLists[players[player]["Subject"]][weapon["displayName"]] = (color(skin_name, fore=rgb_color)) # else: diff --git a/src/constants.py b/src/constants.py index 71bb4df6..780ebc82 100644 --- a/src/constants.py +++ b/src/constants.py @@ -159,44 +159,6 @@ "weapons": "Vandal, Phantom", "chat_limit": 5, "hide_skin_weapon_suffix": True, - "skin_abbreviations": { - "status": True, - "abbreviations": { - "Gravitational Uranium Neuroblaster": "G.U.N.", - "Radiant Entertainment System": "R.E.S.", - "VALORANT GO! Vol. 1": "Val. Go! 1", - "VALORANT GO! Vol. 2": "Val. Go! 2", - "Radiant Crisis 001": "R.C. 001", - "Sentinels of Light": "SoL", - "Premiere Collision": "Premiere", - "Kohaku & Matsuba": "K&M", - "Winterwunderland": "Winter", - "Gaia's Vengeance": "Gaia", - "Prelude to Chaos": "Chaos", - "Coalition: Cobra": "Cobra", - "Nunca Olvidados": "Nunca", - "Tethered Realms": "Tethered", - "Starlit Odyssey": "Odyssey", - "Protocol 781-A": "Protocol", - "Champions 2021": "Champ 2021", - "Champions 2022": "Champ 2022", - "Champions 2023": "Champ 2023", - "Piedra del Sol": "Piedra", - "Task Force 809": "Task Force", - "Iridian Thorn": "Iridian", - "Black.Market": "Black M.", - "Crimsonbeast": "Crimson", - "Neo Frontier": "Neo", - "VCT LOCK//IN": "VCT", - "Divine Swine": "Swine", - "Immortalized": "Immortal", - "Lycan's Bane": "Lycan", - "Doodle Buds": "Doodle", - "RGX 11z Pro": "RGX 11z", - "Singularity": "Sing.", - "Monstrocity": "Monst.", - } - }, "table": { "skin": True, "rr": True,