case0 / src /case_zero /api /dto.py
aliabdelwahab's picture
Per-case visuals, incident vignettes, guided play, no-repeat dealing, four new crime kinds
aabd7c7 verified
Raw
History Blame
1.21 kB
"""Wire DTOs for the public game API.
These are the exact shapes the Preact client exchanges with the server. The client
speaks camelCase; pydantic aliases map that to snake_case internally. The sealed
``CaseFile``/``Solution`` never appears here - only the public ``PlayerCaseView``
projection is ever returned before the verdict.
"""
from __future__ import annotations
from pydantic import BaseModel, ConfigDict, Field
from .public_view import PublicCase
class _CamelModel(BaseModel):
"""Base: accept snake_case or camelCase on input, emit camelCase on output."""
model_config = ConfigDict(populate_by_name=True)
class NewCaseRequest(_CamelModel):
seed: int | None = None
case_id: str | None = Field(default=None, alias="caseId")
difficulty: str | None = None
# Case ids this player already started, oldest first. New Case never re-deals
# these (explicit ?case=/caseId loads bypass the filter so share links work).
exclude_case_ids: list[str] = Field(default_factory=list, alias="excludeCaseIds")
class CaseResponse(_CamelModel):
case_id: str = Field(alias="caseId")
run_id: str = Field(alias="runId")
case: PublicCase