- 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>
28 lines
1.1 KiB
Python
28 lines
1.1 KiB
Python
from sqlalchemy import Column, Integer, String, Text, Boolean, DateTime, ForeignKey
|
|
from sqlalchemy.orm import relationship
|
|
from sqlalchemy.sql import func
|
|
from app.models.base import Base
|
|
|
|
|
|
class GameEvent(Base):
|
|
__tablename__ = "game_events"
|
|
|
|
id = Column(Integer, primary_key=True, index=True)
|
|
session_id = Column(Integer, ForeignKey("game_sessions.id"), nullable=False)
|
|
event_type = Column(String(50), nullable=False) # question_selected, answer_submitted, steal_attempted, etc.
|
|
player_name = Column(String(100))
|
|
team = Column(String(1)) # 'A' or 'B'
|
|
question_id = Column(Integer, ForeignKey("questions.id"))
|
|
answer_given = Column(Text)
|
|
was_correct = Column(Boolean)
|
|
was_steal = Column(Boolean, default=False)
|
|
points_earned = Column(Integer)
|
|
timestamp = Column(DateTime(timezone=True), server_default=func.now())
|
|
|
|
# Relationships
|
|
session = relationship("GameSession", back_populates="events")
|
|
question = relationship("Question", back_populates="game_events")
|
|
|
|
def __repr__(self):
|
|
return f"<GameEvent(id={self.id}, type='{self.event_type}', player='{self.player_name}')>"
|