# -*- coding: utf-8 -*-
# cython: language_level=3
# Copyright (c) 2022 Crisp Crow
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
"""Entities that are used to describe users on WotBlitz."""
from __future__ import annotations
__all__: typing.Sequence[str] = ('BaseUser', 'User', 'ClanMember', 'UserRating', 'UserPrivate', 'MemberClanRole')
import abc
import typing
import enum
import attr
if typing.TYPE_CHECKING:
from onewot.internal import unix
from onewot import clans
from onewot import snowflakes
[docs]@attr.define(slots=True, frozen=True)
class BaseUser(abc.ABC):
"""Basic interface of user information."""
id: snowflakes.Snowflake = attr.field()
[docs]@attr.define(slots=True, frozen=True)
class ClanMember(BaseUser):
"""Interface of clan member information."""
clan_id: snowflakes.Snowflake = attr.field()
joined_at: unix.UnixTime = attr.field()
role: MemberClanRole = attr.field()
clan: clans.BaseClan = attr.field()
[docs]class MemberClanRole(enum.Enum):
"""Member clan roles interface.
Value can be **executive officer**, **private** or **commander**.
"""
EXECUTIVE_OFFICER: typing.Final[str] = 'executive officer'
PRIVATE: typing.Final[str] = 'private'
COMMANDER: typing.Final[str] = 'commander'
def __repr__(self) -> str:
return self.value
[docs]@attr.define(slots=True, frozen=True)
class User(BaseUser):
"""Interface of user information."""
nickname: str = attr.field()
created_at: unix.UnixTime = attr.field()
last_battle_time: typing.Optional[unix.UnixTime] = attr.field()
updated_at: unix.UnixTime = attr.field()
spotted: int = attr.field()
max_frags_tank_id: int = attr.field()
hits: int = attr.field()
frags: int = attr.field()
max_xp: int = attr.field()
max_xp_tank_id: int = attr.field()
wins: int = attr.field()
losses: int = attr.field()
capture_points: int = attr.field()
battles: int = attr.field()
damage_dealt: int = attr.field()
damage_received: int = attr.field()
max_frags: int = attr.field()
shots: int = attr.field()
frags8p: int = attr.field()
xp: int = attr.field()
win_and_survived: int = attr.field()
survived_battles: int = attr.field()
dropped_capture_points: int = attr.field()
win_percent: float = attr.field()
achievements: typing.Type[object] = attr.field()
rating: UserRating = attr.field()
private: typing.Optional[UserPrivate] = attr.field()
[docs]@attr.define(slots=True, frozen=True)
class UserRating:
"""Interface of user rating information."""
battles: int = attr.field()
calibration_battles_left: int = attr.field()
capture_points: int = attr.field()
current_season: int = attr.field()
damage_dealt: int = attr.field()
damage_received: int = attr.field()
dropped_capture_points: int = attr.field()
frags: int = attr.field()
frags8p: int = attr.field()
hits: int = attr.field()
is_recalibration: bool = attr.field()
losses: int = attr.field()
mm_rating: float = attr.field()
recalibration_start_time: unix.UnixTime = attr.field()
shots: int = attr.field()
spotted: int = attr.field()
survived_battles: int = attr.field()
win_and_survived: int = attr.field()
wins: int = attr.field()
xp: int = attr.field()
[docs]@attr.define(slots=True, frozen=True)
class UserPrivate:
"""Interface of user private information."""
ban_info: str = attr.field()
ban_time: unix.UnixTime = attr.field()
chat_ban_time: unix.UnixTime = attr.field()
battle_life_time: int = attr.field()
credits: int = attr.field()
free_xp: int = attr.field()
gold: int = attr.field()
is_premium: bool = attr.field()
premium_expires_at: unix.UnixTime = attr.field()