Skip to content

Commit

Permalink
Fix passing list to Enum constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
Gobot1234 committed Dec 22, 2023
1 parent 573d8cc commit b252796
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions steam/ext/csgo/models.py
Expand Up @@ -167,11 +167,11 @@ async def recent_matches(self) -> Matches:
return Matches([Match(self._state, match, players) for match in msg.matches], msg.streams, msg.tournamentinfo)


class User(PartialUser, user.User):
class User(PartialUser, user.User): # type: ignore
__slots__ = ()


class ClientUser(PartialUser, ClientUser_):
class ClientUser(PartialUser, ClientUser_): # type: ignore
__slots__ = ("_profile_info_msg",)

if TYPE_CHECKING:
Expand All @@ -187,11 +187,12 @@ async def inventory(self, app: App, *, language: Language | None = None) -> Inve
async def csgo_profile(self) -> ProfileInfo[Self]:
return ProfileInfo(self, self._profile_info_msg)

@utils.todo
async def live_games(self) -> ...:
...


class MatchPlayer(PartialUser, user.WrapsUser):
class MatchPlayer(PartialUser, user.WrapsUser): # type: ignore
kills: int
assists: int
deaths: int
Expand Down Expand Up @@ -227,6 +228,17 @@ def name(self, levels: list[int] = list(LEVEL_MAP), names: list[str] = list(LEVE
return names[bisect.bisect_left(levels, self)]


class Ranking:
__slots__ = ("rank", "id", "change", "wins", "tv_control")

def __init__(self, proto: cstrike.PlayerRankingInfo) -> None:
self.rank = Rank(proto.rank_type_id)
self.id = proto.rank_id
self.change = proto.rank_change
self.wins = proto.wins
self.tv_control = proto.tv_control


class ProfileInfo(Generic[UserT]):
def __init__(self, user: UserT, proto: cstrike.MatchmakingClientHello | cstrike.PlayersProfileProfile):
self.user = user
Expand All @@ -235,7 +247,7 @@ def __init__(self, user: UserT, proto: cstrike.MatchmakingClientHello | cstrike.
self.penalty_seconds = proto.penalty_seconds
self.penalty_reason = proto.penalty_reason
self.vac_banned = proto.vac_banned
self.ranking = proto.ranking
self.ranking = Ranking(proto.ranking)
self.commendation = proto.commendation
self.medals = proto.medals
self.current_event = proto.my_current_event
Expand All @@ -247,7 +259,7 @@ def __init__(self, user: UserT, proto: cstrike.MatchmakingClientHello | cstrike.
self.current_xp = proto.player_cur_xp
self.level = Level(proto.player_level)
self.xp_bonus_flags = proto.player_xp_bonus_flags
self.rankings = Rank(proto.rankings)
self.rankings = [Ranking(ranking) for ranking in proto.rankings]

@property
def percentage_of_current_level(self) -> int:
Expand Down

0 comments on commit b252796

Please sign in to comment.