Files
mtgonline/backend/app/schemas/game_schemas.py
T
akadmin bea91db64d Phase 3: Schema Layer - Pydantic v2 migration, deduplication, and missing schemas
- Migrated all schemas to Pydantic v2 syntax (model_config, ConfigDict)
- Fixed mutable default in ProtoMessageBase using Field(default_factory=datetime.now)
- Consolidated CardCollection and Wishlist schemas in user_card_collection.py
- Created game_schemas.py with GameCreate, GameResponse, GameJoinRequest, etc.
- Created mtg_card_schemas.py with MtgCardResponse, MtgCardSearchRequest, etc.
- Added CardImportBatchCreate, CardImportBatchResponse, UserCardImportCreate/Response schemas
- Fixed duplicate UserCardImportRecord class between card_import_batch.py and user_card_import_record.py
- Updated __init__.py with comprehensive schema exports
- Created verify_schemas.py for schema-model matching verification
2026-08-16 05:22:17 +00:00

65 lines
1.4 KiB
Python

"""Pydantic schemas for game features."""
from pydantic import BaseModel, Field, ConfigDict
from typing import Optional, List, Dict, Any
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
max_players: int = Field(4, ge=2, le=8)
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
password: Optional[str] = None
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
is_ready: bool = False
is_host: bool = False
class GameStateResponse(BaseModel):
"""Game state response."""
game_id: int
players: List[GamePlayerResponse]
turn: int
phase: str
zones: Dict[str, Any]
updated_at: datetime