initial
This commit is contained in:
53
backend/app/models/challenge.py
Normal file
53
backend/app/models/challenge.py
Normal file
@@ -0,0 +1,53 @@
|
||||
from datetime import datetime
|
||||
from enum import Enum
|
||||
from sqlalchemy import String, Text, DateTime, ForeignKey, Integer, Boolean
|
||||
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
||||
|
||||
from app.core.database import Base
|
||||
|
||||
|
||||
class ChallengeType(str, Enum):
|
||||
COMPLETION = "completion"
|
||||
NO_DEATH = "no_death"
|
||||
SPEEDRUN = "speedrun"
|
||||
COLLECTION = "collection"
|
||||
ACHIEVEMENT = "achievement"
|
||||
CHALLENGE_RUN = "challenge_run"
|
||||
SCORE_ATTACK = "score_attack"
|
||||
TIME_TRIAL = "time_trial"
|
||||
|
||||
|
||||
class Difficulty(str, Enum):
|
||||
EASY = "easy"
|
||||
MEDIUM = "medium"
|
||||
HARD = "hard"
|
||||
|
||||
|
||||
class ProofType(str, Enum):
|
||||
SCREENSHOT = "screenshot"
|
||||
VIDEO = "video"
|
||||
STEAM = "steam"
|
||||
|
||||
|
||||
class Challenge(Base):
|
||||
__tablename__ = "challenges"
|
||||
|
||||
id: Mapped[int] = mapped_column(primary_key=True)
|
||||
game_id: Mapped[int] = mapped_column(ForeignKey("games.id", ondelete="CASCADE"), index=True)
|
||||
title: Mapped[str] = mapped_column(String(100), nullable=False)
|
||||
description: Mapped[str] = mapped_column(Text, nullable=False)
|
||||
type: Mapped[str] = mapped_column(String(30), nullable=False)
|
||||
difficulty: Mapped[str] = mapped_column(String(10), nullable=False)
|
||||
points: Mapped[int] = mapped_column(Integer, nullable=False)
|
||||
estimated_time: Mapped[int | None] = mapped_column(Integer, nullable=True) # in minutes
|
||||
proof_type: Mapped[str] = mapped_column(String(20), nullable=False)
|
||||
proof_hint: Mapped[str | None] = mapped_column(Text, nullable=True)
|
||||
is_generated: Mapped[bool] = mapped_column(Boolean, default=True)
|
||||
created_at: Mapped[datetime] = mapped_column(DateTime, default=datetime.utcnow)
|
||||
|
||||
# Relationships
|
||||
game: Mapped["Game"] = relationship("Game", back_populates="challenges")
|
||||
assignments: Mapped[list["Assignment"]] = relationship(
|
||||
"Assignment",
|
||||
back_populates="challenge"
|
||||
)
|
||||
Reference in New Issue
Block a user