2025-12-14 02:38:35 +07:00
|
|
|
from datetime import datetime
|
|
|
|
|
from pydantic import BaseModel, Field
|
|
|
|
|
|
|
|
|
|
from app.models.challenge import ChallengeType, Difficulty, ProofType
|
|
|
|
|
from app.schemas.game import GameShort
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class ChallengeBase(BaseModel):
|
|
|
|
|
title: str = Field(..., min_length=1, max_length=100)
|
|
|
|
|
description: str = Field(..., min_length=1)
|
|
|
|
|
type: ChallengeType
|
|
|
|
|
difficulty: Difficulty
|
|
|
|
|
points: int = Field(..., ge=1, le=500)
|
|
|
|
|
estimated_time: int | None = Field(None, ge=1) # minutes
|
|
|
|
|
proof_type: ProofType
|
|
|
|
|
proof_hint: str | None = None
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class ChallengeCreate(ChallengeBase):
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class ChallengeUpdate(BaseModel):
|
|
|
|
|
title: str | None = Field(None, min_length=1, max_length=100)
|
|
|
|
|
description: str | None = None
|
|
|
|
|
type: ChallengeType | None = None
|
|
|
|
|
difficulty: Difficulty | None = None
|
|
|
|
|
points: int | None = Field(None, ge=1, le=500)
|
|
|
|
|
estimated_time: int | None = None
|
|
|
|
|
proof_type: ProofType | None = None
|
|
|
|
|
proof_hint: str | None = None
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class ChallengeResponse(ChallengeBase):
|
|
|
|
|
id: int
|
|
|
|
|
game: GameShort
|
|
|
|
|
is_generated: bool
|
|
|
|
|
created_at: datetime
|
|
|
|
|
|
|
|
|
|
class Config:
|
|
|
|
|
from_attributes = True
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class ChallengeGenerated(BaseModel):
|
|
|
|
|
"""Schema for GPT-generated challenges"""
|
|
|
|
|
title: str
|
|
|
|
|
description: str
|
|
|
|
|
type: str
|
|
|
|
|
difficulty: str
|
|
|
|
|
points: int
|
|
|
|
|
estimated_time: int | None = None
|
|
|
|
|
proof_type: str
|
|
|
|
|
proof_hint: str | None = None
|
2025-12-14 03:23:50 +07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
class ChallengePreview(BaseModel):
|
|
|
|
|
"""Schema for challenge preview (with game info)"""
|
|
|
|
|
game_id: int
|
|
|
|
|
game_title: str
|
|
|
|
|
title: str
|
|
|
|
|
description: str
|
|
|
|
|
type: str
|
|
|
|
|
difficulty: str
|
|
|
|
|
points: int
|
|
|
|
|
estimated_time: int | None = None
|
|
|
|
|
proof_type: str
|
|
|
|
|
proof_hint: str | None = None
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class ChallengesPreviewResponse(BaseModel):
|
|
|
|
|
"""Response with generated challenges for preview"""
|
|
|
|
|
challenges: list[ChallengePreview]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class ChallengeSaveItem(BaseModel):
|
|
|
|
|
"""Single challenge to save"""
|
|
|
|
|
game_id: int
|
|
|
|
|
title: str
|
|
|
|
|
description: str
|
|
|
|
|
type: str
|
|
|
|
|
difficulty: str
|
|
|
|
|
points: int
|
|
|
|
|
estimated_time: int | None = None
|
|
|
|
|
proof_type: str
|
|
|
|
|
proof_hint: str | None = None
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class ChallengesSaveRequest(BaseModel):
|
|
|
|
|
"""Request to save previewed challenges"""
|
|
|
|
|
challenges: list[ChallengeSaveItem]
|