Source code for onewot.tournaments

# -*- 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 tournaments on WotBlitz."""

from __future__ import annotations

__all__: typing.Sequence[str] = (
    'Tournament',
    'TournamentEconomy',
    'TournamentAward',
    'TournamentFee',
    'TournamentWinnerAward',
    'TournamentLogo',
    'TournamentStatus',
    'CurrencyType'
)

import typing
import enum

import attr

if typing.TYPE_CHECKING:
    from onewot.internal import unix
    from onewot import snowflakes


[docs]@attr.define(slots=True, frozen=True) class Tournament: """Interface of tournament information.""" id: snowflakes.Snowflake = attr.field() description: str = attr.field() end_at: unix.UnixTime = attr.field() matches_start_at: unix.UnixTime = attr.field() registration_end_at: unix.UnixTime = attr.field() registration_start_at: unix.UnixTime = attr.field() start_at: unix.UnixTime = attr.field() status: TournamentStatus = attr.field() title: str = attr.field() award: TournamentAward = attr.field() fee: TournamentFee = attr.field() logo: TournamentLogo = attr.field() winner_award: TournamentWinnerAward = attr.field()
[docs]@attr.define(slots=True, frozen=True) class TournamentEconomy: """Interface of tournament economy information.""" amount: int = attr.field() currency: CurrencyType = attr.field()
[docs]@attr.define(slots=True, frozen=True) class TournamentAward(TournamentEconomy): """Interface of tournament award information."""
[docs]@attr.define(slots=True, frozen=True) class TournamentFee(TournamentEconomy): """Interface of tournament fee information."""
[docs]@attr.define(slots=True, frozen=True) class TournamentWinnerAward(TournamentEconomy): """Interface of tournament winner award information."""
[docs]class TournamentStatus(enum.Enum): """Interface of tournament status information. Value can be **upcoming**, **finished**, **running** or **registration started**. """ UPCOMING: typing.Final[str] = 'upcoming' FINISHED: typing.Final[str] = 'finished' RUNNING: typing.Final[str] = 'running' REGISTRATION_STARTED: typing.Final[str] = 'registration started' def __repr__(self) -> str: return self.value
[docs]class CurrencyType(enum.Enum): """Interface of tournament currency type information. Value can be **gold**, **credits** or **free experience**. """ GOLD: typing.Final[str] = 'gold' CREDITS: typing.Final[str] = 'credits' FREE_EXPERIENCE: typing.Final[str] = 'free experience' def __repr__(self) -> str: return self.value