"""Pydantic schemas for game features."""
from pydantic import BaseModel, Field, ConfigDict
from typing import Optional, List
from datetime import datetime


class GameCreate(BaseModel):
    """Game creation request."""
    room_id: int
    game_type: Optional[str] = None
    description: Optional[str] = None
    password: Optional[str] = None


class GameResponse(BaseModel):
    """Game response payload."""
    id: int
    room_id: int
    game_type: Optional[str]
    description: Optional[str]
    with_password: bool
    max_players: int
    player_count: int
    started: bool
    creation_date: datetime
    
    model_config = ConfigDict(from_attributes=True)


class GameJoinRequest(BaseModel):
    """Game join request."""
    game_id: int


class GameLeaveRequest(BaseModel):
    """Game leave request."""
    game_id: int


class GameListResponse(BaseModel):
    """List of games."""
    games: List[GameResponse]
    total: int


class GamePlayerResponse(BaseModel):
    """Game player response."""
    user_id: int
    username: str
    deck_id: Optional[int] = None
    deck_name: Optional[str] = None


class GameStateResponse(BaseModel):
    """Game state response."""
    game_id: int
    state: str
    players: List[GamePlayerResponse]
    turn: Optional[int] = None
