Files
wordsearch/models/game.py
T
Mathew Sir Guest the bestandClaude Opus 4.6 4d681a92ca docs: add Google-style docstrings and Sphinx autodoc setup
Add concise docstrings to all Python modules, classes, and public
functions. Configure Sphinx with napoleon extension for Google-style
docstring parsing and autodoc pages for each module.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-05-06 23:06:37 -06:00

57 lines
1.6 KiB
Python

"""Game session and placed word models."""
import uuid
from datetime import datetime, timezone
from sqlalchemy import (
Boolean,
Column,
DateTime,
ForeignKey,
Integer,
String,
)
from sqlalchemy.orm import relationship
from sqlalchemy.types import JSON
from models import Base
class Game(Base):
"""A single word search game session.
Stores the generated grid, tracks status, and links to placed words.
"""
__tablename__ = "games"
id = Column(String(36), primary_key=True, default=lambda: str(uuid.uuid4()))
category_id = Column(Integer, ForeignKey("categories.id"), nullable=False)
board_size = Column(Integer, nullable=False, default=10)
grid = Column(JSON, nullable=False)
status = Column(String(20), nullable=False, default="in_progress")
started_at = Column(
DateTime, nullable=False, default=lambda: datetime.now(timezone.utc)
)
completed_at = Column(DateTime, nullable=True)
category = relationship("Category")
words = relationship("Word", back_populates="game")
class Word(Base):
"""A word placed on a game board with its position and found status."""
__tablename__ = "words"
id = Column(Integer, primary_key=True, autoincrement=True)
game_id = Column(String(36), ForeignKey("games.id"), nullable=False)
text = Column(String(20), nullable=False)
start_row = Column(Integer, nullable=False)
start_col = Column(Integer, nullable=False)
direction = Column(String(2), nullable=False)
found = Column(Boolean, nullable=False, default=False)
found_at = Column(DateTime, nullable=True)
game = relationship("Game", back_populates="words")