From de3ede363d8a9be4299fe942115ff15838193250 Mon Sep 17 00:00:00 2001 From: Lennart <65763511+schrotle@users.noreply.github.com> Date: Thu, 11 Jan 2024 14:40:54 +0100 Subject: [PATCH] Add csgo RankType and correct enumeration (#441) * Add csgo RankType and correct enumeration * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Add try_value for rank_type * Update steam/ext/csgo/models.py --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: James Hilton-Balfe --- steam/ext/csgo/enums.py | 5 +++++ steam/ext/csgo/models.py | 9 +++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/steam/ext/csgo/enums.py b/steam/ext/csgo/enums.py index 76bbb5cd..570d4512 100644 --- a/steam/ext/csgo/enums.py +++ b/steam/ext/csgo/enums.py @@ -154,6 +154,11 @@ def DISPLAY_NAMES(cls: type[Self]) -> Mapping[Rank, str]: # type: ignore def display_name(self) -> str: return self.DISPLAY_NAMES[self] +class RankType(IntEnum): + Matchmaking = 6 + Wingman = 7 + CS2 = 10 + Dangerzone = 11 class EMsg(IntEnum): # ESOMsg diff --git a/steam/ext/csgo/models.py b/steam/ext/csgo/models.py index ce6407c0..50cdc65a 100644 --- a/steam/ext/csgo/models.py +++ b/steam/ext/csgo/models.py @@ -17,7 +17,7 @@ from ...types.id import ID32 from ...utils import DateTime from ..commands.converters import Converter, UserConverter -from .enums import Rank +from .enums import Rank, RankType from .protobufs import cstrike if TYPE_CHECKING: @@ -229,11 +229,12 @@ def name(self, levels: list[int] = list(LEVEL_MAP), names: list[str] = list(LEVE class Ranking: - __slots__ = ("rank", "id", "change", "wins", "tv_control") + __slots__ = ("rank", "id", "rank_type", "change", "wins", "tv_control") def __init__(self, proto: cstrike.PlayerRankingInfo) -> None: - self.rank = Rank(proto.rank_type_id) - self.id = proto.rank_id + self.rank = Rank.try_value(proto.rank_id) if proto.rank_type_id != 10 else proto.rank_id + self.id = proto.rank_type_id + self.rank_type = RankType.try_value(proto.rank_type_id) self.change = proto.rank_change self.wins = proto.wins self.tv_control = proto.tv_control