Skip to content

Commit

Permalink
Add csgo RankType and correct enumeration (#441)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
  • Loading branch information
3 people committed Jan 11, 2024
1 parent cc1c6c4 commit de3ede3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
5 changes: 5 additions & 0 deletions steam/ext/csgo/enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 5 additions & 4 deletions steam/ext/csgo/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit de3ede3

Please sign in to comment.