26 lines
1.2 KiB
Python
26 lines
1.2 KiB
Python
from pydantic import BaseModel, Field
|
|
from datetime import date
|
|
from typing import Optional, Literal
|
|
|
|
GameChoice = Literal["rock", "scissors", "paper"]
|
|
|
|
class User(BaseModel):
|
|
id: Optional[int] = Field(default=None, description="Primary key")
|
|
telegram_id: int = Field(description="Telegram User ID")
|
|
username: Optional[str] = Field(default=None, description="Telegram Username")
|
|
|
|
class Game(BaseModel):
|
|
id: Optional[int] = Field(default=None, description="Primary key")
|
|
game_date: date = Field(description="Date of the game")
|
|
player1_id: int = Field(description="Foreign key to users table")
|
|
player1_choice: Optional[GameChoice] = Field(default=None)
|
|
player2_id: int = Field(description="Foreign key to users table")
|
|
player2_choice: Optional[GameChoice] = Field(default=None)
|
|
winner_id: Optional[int] = Field(default=None, description="Foreign key to users table, NULL if draw")
|
|
is_finished: bool = Field(default=False)
|
|
|
|
class Streak(BaseModel):
|
|
id: Optional[int] = Field(default=None, description="Primary key")
|
|
user_id: int = Field(description="Foreign key to users table")
|
|
current_streak: int = Field(default=0)
|
|
max_streak: int = Field(default=0) |