feat(phase2): Add achievements and replay systems
Achievement System:
- Add Achievement model with condition types (streak, steal, specialist, etc.)
- Add AchievementManager service for tracking and awarding achievements
- Add Pydantic schemas for achievements (AchievementResponse, PlayerStats, etc.)
- Seed 18 achievements from design doc
- Add GET /api/game/achievements endpoint
Replay System:
- Add ReplayManager service for saving/loading game replays
- Add GET /api/replay/{code} and /api/replay/session/{id} endpoints
- Format replays for frontend consumption
Phase 2 tasks completed:
- F2.1: Achievement model and migration
- F2.2: Pydantic schemas
- F2.3: AchievementManager service
- F2.4: ReplayManager service
- F2.5: API endpoints
- F2.6: Seed 18 achievements data
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -3,5 +3,6 @@ from app.models.question import Question
|
||||
from app.models.game_session import GameSession
|
||||
from app.models.game_event import GameEvent
|
||||
from app.models.admin import Admin
|
||||
from app.models.achievement import Achievement
|
||||
|
||||
__all__ = ["Category", "Question", "GameSession", "GameEvent", "Admin"]
|
||||
__all__ = ["Category", "Question", "GameSession", "GameEvent", "Admin", "Achievement"]
|
||||
|
||||
22
backend/app/models/achievement.py
Normal file
22
backend/app/models/achievement.py
Normal file
@@ -0,0 +1,22 @@
|
||||
from sqlalchemy import Column, Integer, String, Text, DateTime, ForeignKey, func
|
||||
from sqlalchemy.orm import relationship
|
||||
from app.models.base import Base
|
||||
|
||||
|
||||
class Achievement(Base):
|
||||
__tablename__ = "achievements"
|
||||
|
||||
id = Column(Integer, primary_key=True, index=True)
|
||||
name = Column(String(100), nullable=False, unique=True)
|
||||
description = Column(Text, nullable=False)
|
||||
icon = Column(String(10), nullable=False)
|
||||
condition_type = Column(String(50), nullable=False)
|
||||
condition_value = Column(Integer, default=1)
|
||||
category_id = Column(Integer, ForeignKey("categories.id"), nullable=True)
|
||||
created_at = Column(DateTime, server_default=func.now())
|
||||
|
||||
# Relationships
|
||||
category = relationship("Category")
|
||||
|
||||
def __repr__(self):
|
||||
return f"<Achievement(id={self.id}, name='{self.name}')>"
|
||||
Reference in New Issue
Block a user