Skip to content

Commit

Permalink
Make --show-rank work on different client languages.
Browse files Browse the repository at this point in the history
  • Loading branch information
Its-Haze committed Jan 7, 2024
1 parent 50f6114 commit 9ceecc9
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 1 deletion.
10 changes: 10 additions & 0 deletions league_rpc_linux/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,13 @@

LEAGUE_RANKED_EMBLEM = "https://github.com/Its-Haze/league-assets/blob/master/ranked_emblems/{tier}.png?raw=true"
LEAGUE_CHERRY_RANKED_EMBLEM = "https://github.com/Its-Haze/league-assets/blob/master/cherry_rated_medallions/{tier}.png?raw=true"


RANKED_TYPE_MAPPER = {
"RANKED_SOLO_5x5": "Ranked Solo/Duo",
"RANKED_FLEX_SR": "Ranked Flex",
"RANKED_TFT": "Teamfight Tactics (Ranked)",
"RANKED_TFT_DOUBLE_UP": "Teamfight Tactics (Double Up Workshop)",
"RANKED_TFT_TURBO": "Teamfight Tactics (Hyper Roll)",
"CHERRY": "Arena",
}
1 change: 1 addition & 0 deletions league_rpc_linux/lcu_api/base_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ async def gather_queue_data(connection: Connection, data: ClientData):
)
lobby_queue_info = await lobby_queue_info_raw.json()
data.queue = lobby_queue_info[LolGameQueuesQueue.NAME]
data.queue_type = lobby_queue_info[LolGameQueuesQueue.TYPE]
data.max_players = int(
lobby_queue_info[LolGameQueuesQueue.MAXIMUM_PARTICIPANT_LIST_SIZE]
)
Expand Down
1 change: 1 addition & 0 deletions league_rpc_linux/lcu_api/lcu_connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ async def in_lobby(connection: Connection, event: WebsocketEventResponse) -> Non
lobby_queue_info = await lobby_queue_info_raw.json()

data.queue = lobby_queue_info[LolGameQueuesQueue.NAME]
data.queue_type = lobby_queue_info[LolGameQueuesQueue.TYPE]
data.queue_is_ranked = lobby_queue_info[LolGameQueuesQueue.IS_RANKED]

rpc_updater.delay_update(module_data)
Expand Down
1 change: 1 addition & 0 deletions league_rpc_linux/models/client_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class ClientData:
max_players: int = 0 # max players in lobby
players: int = 0 # players in lobby
queue: str = ""
queue_type = ""
queue_id: int = -1
queue_is_ranked: bool = False
summoner_icon: int = 0
Expand Down
3 changes: 2 additions & 1 deletion league_rpc_linux/models/rpc_updater.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
LEAGUE_OF_LEGENDS_LOGO,
MAP_ICON_CONVERT_MAP,
PROFILE_ICON_BASE_URL,
RANKED_TYPE_MAPPER,
SMALL_TEXT,
)
from league_rpc_linux.lcu_api.lcu_connector import ModuleData
Expand Down Expand Up @@ -124,7 +125,7 @@ def show_ranked_data(
) -> tuple[str, ...]:
large_text = small_text = small_image = ""

match module_data.client_data.queue:
match RANKED_TYPE_MAPPER.get(module_data.client_data.queue_type):
case "Ranked Solo/Duo":
summoner_rank = module_data.client_data.summoner_rank
if summoner_rank.tier:
Expand Down

0 comments on commit 9ceecc9

Please sign in to comment.