- Backend: FastAPI + Python-SocketIO + SQLAlchemy - Models for categories, questions, game sessions, events - AI services for answer validation and question generation (Claude) - Room management with Redis - Game logic with stealing mechanics - Admin API for question management - Frontend: React + Vite + TypeScript + Tailwind - 5 visual themes (DRRR, Retro, Minimal, RGB, Anime 90s) - Real-time game with Socket.IO - Achievement system - Replay functionality - Sound effects per theme - Docker Compose for deployment - Design documentation Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
71 lines
1.4 KiB
Python
71 lines
1.4 KiB
Python
from pydantic import BaseModel
|
|
from typing import Optional, List, Dict
|
|
from datetime import datetime
|
|
|
|
|
|
class PlayerInfo(BaseModel):
|
|
name: str
|
|
team: str # 'A' or 'B'
|
|
position: int
|
|
socket_id: Optional[str] = None
|
|
|
|
|
|
class RoomCreate(BaseModel):
|
|
player_name: str
|
|
|
|
|
|
class RoomJoin(BaseModel):
|
|
room_code: str
|
|
player_name: str
|
|
team: str # 'A' or 'B'
|
|
|
|
|
|
class TeamState(BaseModel):
|
|
players: List[PlayerInfo]
|
|
score: int
|
|
current_player_index: int
|
|
|
|
|
|
class QuestionState(BaseModel):
|
|
id: int
|
|
category_id: int
|
|
difficulty: int
|
|
points: int
|
|
answered: bool = False
|
|
|
|
|
|
class GameState(BaseModel):
|
|
room_code: str
|
|
status: str # waiting, playing, finished
|
|
team_a: TeamState
|
|
team_b: TeamState
|
|
current_team: Optional[str] = None
|
|
current_question: Optional[int] = None
|
|
can_steal: bool = False
|
|
board: Dict[int, List[QuestionState]] # category_id -> questions
|
|
timer_end: Optional[datetime] = None
|
|
|
|
|
|
class AnswerSubmit(BaseModel):
|
|
question_id: int
|
|
answer: str
|
|
|
|
|
|
class StealAttempt(BaseModel):
|
|
question_id: int
|
|
attempt: bool # True = try to steal, False = pass
|
|
answer: Optional[str] = None
|
|
|
|
|
|
class ChatMessage(BaseModel):
|
|
player_name: str
|
|
team: str
|
|
message: str
|
|
timestamp: datetime
|
|
|
|
|
|
class EmojiReaction(BaseModel):
|
|
player_name: str
|
|
team: str
|
|
emoji: str # One of: 👏 😮 😂 🔥 💀 🎉 😭 🤔
|