- Move word data from hardcoded seed.py to data/words.json - Expand from 210 words across 7 categories to 1014 words across 14 categories (animals, food, colors, sports, space, nature, music, science, countries, occupations, ocean, weather, mythology, technology) - Word list sidebar now shows title case (Tiger) while grid stays uppercase; text input remains case-insensitive - Add Ocean theme (light, blue accents) and Forest theme (dark, amber accents on deep green) - Replace hardcoded rgba values with --coral-bg CSS variable so selection highlighting adapts per theme Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
60 lines
1.8 KiB
Python
60 lines
1.8 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)
|
|
player_name = Column(
|
|
String(20), nullable=False, default="Anonymous", server_default="Anonymous"
|
|
)
|
|
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")
|