Files
game-marathon/backend/app/schemas/assignment.py

125 lines
3.8 KiB
Python
Raw Normal View History

2025-12-14 02:38:35 +07:00
from datetime import datetime
from pydantic import BaseModel
from app.schemas.game import GameResponse, GameShort, PlaythroughInfo
2025-12-14 02:38:35 +07:00
from app.schemas.challenge import ChallengeResponse
2026-01-03 00:12:07 +07:00
class ProofFileResponse(BaseModel):
"""Информация о файле-доказательстве"""
id: int
file_type: str # image или video
order_index: int
created_at: datetime
class Config:
from_attributes = True
2025-12-14 02:38:35 +07:00
class AssignmentBase(BaseModel):
pass
class CompleteAssignment(BaseModel):
proof_url: str | None = None
comment: str | None = None
class BonusAssignmentResponse(BaseModel):
"""Ответ с информацией о бонусном челлендже"""
2025-12-14 02:38:35 +07:00
id: int
challenge: ChallengeResponse
status: str # pending, completed
proof_url: str | None = None
2026-01-03 00:12:07 +07:00
proof_image_url: str | None = None # Legacy, for backward compatibility
proof_files: list[ProofFileResponse] = [] # Multiple uploaded files
proof_comment: str | None = None
points_earned: int = 0
completed_at: datetime | None = None
class Config:
from_attributes = True
class AssignmentResponse(BaseModel):
id: int
challenge: ChallengeResponse | None # None для playthrough
game: GameShort | None = None # Заполняется для playthrough
is_playthrough: bool = False
playthrough_info: PlaythroughInfo | None = None # Заполняется для playthrough
2025-12-14 02:38:35 +07:00
status: str
proof_url: str | None = None
proof_comment: str | None = None
points_earned: int
streak_at_completion: int | None = None
2026-01-10 08:24:55 +07:00
tracked_time_minutes: int = 0 # Time tracked by desktop app
2025-12-14 02:38:35 +07:00
started_at: datetime
completed_at: datetime | None = None
2025-12-16 02:22:12 +07:00
drop_penalty: int = 0 # Calculated penalty if dropped
bonus_challenges: list[BonusAssignmentResponse] = [] # Для playthrough
2026-01-05 23:41:22 +07:00
event_type: str | None = None # Event type if assignment was created during event
2025-12-14 02:38:35 +07:00
class Config:
from_attributes = True
2026-01-10 08:24:55 +07:00
class TrackTimeRequest(BaseModel):
"""Request to update tracked time for an assignment"""
minutes: int # Total minutes tracked (replaces previous value)
2025-12-14 02:38:35 +07:00
class SpinResult(BaseModel):
assignment_id: int
game: GameResponse
challenge: ChallengeResponse | None # None для playthrough
is_playthrough: bool = False
playthrough_info: PlaythroughInfo | None = None # Заполняется для playthrough
bonus_challenges: list[ChallengeResponse] = [] # Для playthrough - список доступных бонусных челленджей
2025-12-14 02:38:35 +07:00
can_drop: bool
drop_penalty: int
2026-01-05 23:41:22 +07:00
event_type: str | None = None # Event type if active during spin
2025-12-14 02:38:35 +07:00
class CompleteResult(BaseModel):
points_earned: int
streak_bonus: int
total_points: int
new_streak: int
2026-01-05 07:15:50 +07:00
coins_earned: int = 0 # Coins earned (only in certified marathons)
2025-12-14 02:38:35 +07:00
class DropResult(BaseModel):
penalty: int
total_points: int
new_drop_count: int
2025-12-15 23:03:59 +07:00
class EventAssignmentResponse(BaseModel):
"""Response for event-specific assignment (Common Enemy)"""
assignment: AssignmentResponse | None
event_id: int | None
challenge_id: int | None
is_completed: bool
class Config:
from_attributes = True
class CompleteBonusAssignment(BaseModel):
"""Запрос на завершение бонусного челленджа"""
proof_url: str | None = None
comment: str | None = None
class BonusCompleteResult(BaseModel):
"""Результат завершения бонусного челленджа"""
bonus_assignment_id: int
points_earned: int
total_bonus_points: int # Сумма очков за все бонусные челленджи
class AvailableGamesCount(BaseModel):
"""Количество доступных игр для спина"""
available: int
total: int