Skip to content

Commit

Permalink
use pre-defined constants in common
Browse files Browse the repository at this point in the history
  • Loading branch information
Anupya committed Nov 1, 2023
1 parent 0faf9e3 commit 6f5cabc
Showing 1 changed file with 14 additions and 68 deletions.
82 changes: 14 additions & 68 deletions berserk/types/challenges.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
from __future__ import annotations

from typing_extensions import TypedDict, NotRequired, TypeAlias, Literal

from common import Color, Title, Variant
from opening_explorer import Speed

Status: TypeAlias = Literal[
"created",
Expand All @@ -11,73 +12,6 @@
"accepted",
]


Title: TypeAlias = Literal[
"GM",
"WGM",
"IM",
"WIM",
"FM",
"WFM",
"NM",
"CM",
"WCM",
"WNM",
"LM",
"BOT",
]


class User(TypedDict):
"""Challenge User"""

rating: NotRequired[float]
provisional: NotRequired[bool]
online: NotRequired[bool]
id: str
name: str
title: NotRequired[Title]
patron: NotRequired[bool]


VariantKey: TypeAlias = Literal[
"standard",
"chess960",
"crazyhouse",
"antichess",
"atomic",
"horde",
"kingOfTheHill",
"racingKings",
"threeCheck",
"fromPosition",
]


class Variant(TypedDict):
"""Information about a challenge variant."""

key: NotRequired[VariantKey]
name: NotRequired[str]
short: NotRequired[str]


Speed: TypeAlias = Literal[
"ultraBullet",
"bullet",
"blitz",
"rapid",
"classical",
"correspondence",
]


Color: TypeAlias = Literal[
"white",
"black",
"random",
]

Direction: TypeAlias = Literal[
"in",
"out",
Expand All @@ -99,6 +33,18 @@ class Variant(TypedDict):
]


class User(TypedDict):
"""Challenge User"""

rating: NotRequired[float]
provisional: NotRequired[bool]
online: NotRequired[bool]
id: str
name: str
title: NotRequired[Title]
patron: NotRequired[bool]


class Challenge(TypedDict):
"""Information about a challenge."""

Expand Down

0 comments on commit 6f5cabc

Please sign in to comment.