mirror of
https://code.lenaisten.de/Lenaisten/advent22.git
synced 2024-11-23 00:03:07 +00:00
Config Abschnitt "Puzzle"
This commit is contained in:
parent
e9232fdcac
commit
9f81895600
3 changed files with 10 additions and 6 deletions
|
@ -10,9 +10,13 @@ class User(BaseModel):
|
|||
password: str
|
||||
|
||||
|
||||
class Puzzle(BaseModel):
|
||||
solution: str
|
||||
|
||||
|
||||
class Config(BaseModel):
|
||||
admin: User
|
||||
solution: str
|
||||
puzzle: Puzzle
|
||||
|
||||
|
||||
async def get_config() -> Config:
|
||||
|
|
|
@ -17,7 +17,7 @@ from ._image import AdventImage
|
|||
|
||||
async def get_rnd(bonus_salt: Any = "") -> random.Random:
|
||||
cfg = await get_config()
|
||||
return random.Random(f"{cfg.solution}{bonus_salt}")
|
||||
return random.Random(f"{cfg.puzzle.solution}{bonus_salt}")
|
||||
|
||||
|
||||
async def set_length(seq: Sequence, length: int) -> list:
|
||||
|
@ -44,7 +44,7 @@ async def get_letter(
|
|||
index: int,
|
||||
cfg: Config = Depends(get_config),
|
||||
) -> str:
|
||||
return (await shuffle(cfg.solution))[index]
|
||||
return (await shuffle(cfg.puzzle.solution))[index]
|
||||
|
||||
|
||||
_RE_IMAGE_FILE = re.compile(
|
||||
|
|
|
@ -15,8 +15,8 @@ router = APIRouter(prefix="/days", tags=["days"])
|
|||
@router.on_event("startup")
|
||||
async def startup() -> None:
|
||||
cfg = await get_config()
|
||||
print(cfg.solution)
|
||||
print("".join(await shuffle(cfg.solution)))
|
||||
print(cfg.puzzle.solution)
|
||||
print("".join(await shuffle(cfg.puzzle.solution)))
|
||||
|
||||
|
||||
@router.get("/letter/{index}")
|
||||
|
@ -24,7 +24,7 @@ async def get_letter(
|
|||
index: int,
|
||||
cfg: Config = Depends(get_config),
|
||||
) -> str:
|
||||
return (await shuffle(cfg.solution))[index]
|
||||
return (await shuffle(cfg.puzzle.solution))[index]
|
||||
|
||||
|
||||
@router.get("/date")
|
||||
|
|
Loading…
Reference in a new issue