mirror of
https://code.lenaisten.de/Lenaisten/advent22.git
synced 2024-11-23 08:13:01 +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
|
password: str
|
||||||
|
|
||||||
|
|
||||||
|
class Puzzle(BaseModel):
|
||||||
|
solution: str
|
||||||
|
|
||||||
|
|
||||||
class Config(BaseModel):
|
class Config(BaseModel):
|
||||||
admin: User
|
admin: User
|
||||||
solution: str
|
puzzle: Puzzle
|
||||||
|
|
||||||
|
|
||||||
async def get_config() -> Config:
|
async def get_config() -> Config:
|
||||||
|
|
|
@ -17,7 +17,7 @@ from ._image import AdventImage
|
||||||
|
|
||||||
async def get_rnd(bonus_salt: Any = "") -> random.Random:
|
async def get_rnd(bonus_salt: Any = "") -> random.Random:
|
||||||
cfg = await get_config()
|
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:
|
async def set_length(seq: Sequence, length: int) -> list:
|
||||||
|
@ -44,7 +44,7 @@ async def get_letter(
|
||||||
index: int,
|
index: int,
|
||||||
cfg: Config = Depends(get_config),
|
cfg: Config = Depends(get_config),
|
||||||
) -> str:
|
) -> str:
|
||||||
return (await shuffle(cfg.solution))[index]
|
return (await shuffle(cfg.puzzle.solution))[index]
|
||||||
|
|
||||||
|
|
||||||
_RE_IMAGE_FILE = re.compile(
|
_RE_IMAGE_FILE = re.compile(
|
||||||
|
|
|
@ -15,8 +15,8 @@ router = APIRouter(prefix="/days", tags=["days"])
|
||||||
@router.on_event("startup")
|
@router.on_event("startup")
|
||||||
async def startup() -> None:
|
async def startup() -> None:
|
||||||
cfg = await get_config()
|
cfg = await get_config()
|
||||||
print(cfg.solution)
|
print(cfg.puzzle.solution)
|
||||||
print("".join(await shuffle(cfg.solution)))
|
print("".join(await shuffle(cfg.puzzle.solution)))
|
||||||
|
|
||||||
|
|
||||||
@router.get("/letter/{index}")
|
@router.get("/letter/{index}")
|
||||||
|
@ -24,7 +24,7 @@ async def get_letter(
|
||||||
index: int,
|
index: int,
|
||||||
cfg: Config = Depends(get_config),
|
cfg: Config = Depends(get_config),
|
||||||
) -> str:
|
) -> str:
|
||||||
return (await shuffle(cfg.solution))[index]
|
return (await shuffle(cfg.puzzle.solution))[index]
|
||||||
|
|
||||||
|
|
||||||
@router.get("/date")
|
@router.get("/date")
|
||||||
|
|
Loading…
Reference in a new issue