mirror of
https://code.lenaisten.de/Lenaisten/advent22.git
synced 2024-11-23 00:03:07 +00:00
cfg.puzzle.solution -> cfg.solution
This commit is contained in:
parent
b422913d7c
commit
b74646994e
6 changed files with 65 additions and 15 deletions
|
@ -78,9 +78,6 @@ class Puzzle(BaseModel):
|
||||||
# TODO penner neue Route GET /user/title
|
# TODO penner neue Route GET /user/title
|
||||||
title: str
|
title: str
|
||||||
|
|
||||||
# Lösungswort
|
|
||||||
solution: TransformedString
|
|
||||||
|
|
||||||
# Tag, an dem der Kalender startet
|
# Tag, an dem der Kalender startet
|
||||||
# TODO penner
|
# TODO penner
|
||||||
begin_day: int = 1
|
begin_day: int = 1
|
||||||
|
@ -117,7 +114,13 @@ class Image(BaseModel):
|
||||||
|
|
||||||
|
|
||||||
class Config(BaseModel):
|
class Config(BaseModel):
|
||||||
|
# Login-Daten für Admin-Modus
|
||||||
admin: User
|
admin: User
|
||||||
|
|
||||||
|
# Lösungswort
|
||||||
|
solution: TransformedString
|
||||||
|
|
||||||
|
# Weitere Einstellungen
|
||||||
puzzle: Puzzle
|
puzzle: Puzzle
|
||||||
image: Image
|
image: Image
|
||||||
|
|
||||||
|
|
|
@ -46,7 +46,7 @@ async def get_all_parts(
|
||||||
Lösung auf vorhandene Tage aufteilen
|
Lösung auf vorhandene Tage aufteilen
|
||||||
"""
|
"""
|
||||||
|
|
||||||
solution_length = len(cfg.puzzle.solution.clean)
|
solution_length = len(cfg.solution.clean)
|
||||||
num_days = len(days)
|
num_days = len(days)
|
||||||
|
|
||||||
rnd = await Random.get()
|
rnd = await Random.get()
|
||||||
|
@ -60,7 +60,7 @@ async def get_all_parts(
|
||||||
]
|
]
|
||||||
|
|
||||||
result: dict[int, str] = {}
|
result: dict[int, str] = {}
|
||||||
for day, letter in zip(solution_days, cfg.puzzle.solution.clean):
|
for day, letter in zip(solution_days, cfg.solution.clean):
|
||||||
result[day] = result.get(day, "")
|
result[day] = result.get(day, "")
|
||||||
result[day] += letter
|
result[day] += letter
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,7 @@ class Random(random.Random):
|
||||||
@classmethod
|
@classmethod
|
||||||
async def get(cls, bonus_salt: Any = "") -> Self:
|
async def get(cls, bonus_salt: Any = "") -> Self:
|
||||||
cfg = await get_config()
|
cfg = await get_config()
|
||||||
return cls(f"{cfg.puzzle.solution.clean}{cfg.random_seed}{bonus_salt}")
|
return cls(f"{cfg.solution.clean}{cfg.random_seed}{bonus_salt}")
|
||||||
|
|
||||||
def shuffled(self, population: Sequence[T]) -> Sequence[T]:
|
def shuffled(self, population: Sequence[T]) -> Sequence[T]:
|
||||||
return self.sample(population, k=len(population))
|
return self.sample(population, k=len(population))
|
||||||
|
|
|
@ -22,8 +22,13 @@ async def is_admin(
|
||||||
|
|
||||||
|
|
||||||
class ConfigModel(BaseModel):
|
class ConfigModel(BaseModel):
|
||||||
|
class __Solution(BaseModel):
|
||||||
|
value: str
|
||||||
|
whitespace: str | None
|
||||||
|
case: str | None
|
||||||
|
clean: str
|
||||||
|
|
||||||
class __Puzzle(BaseModel):
|
class __Puzzle(BaseModel):
|
||||||
solution: str
|
|
||||||
first: date
|
first: date
|
||||||
next: date | None
|
next: date | None
|
||||||
last: date
|
last: date
|
||||||
|
@ -39,6 +44,7 @@ class ConfigModel(BaseModel):
|
||||||
cache_ttl: int
|
cache_ttl: int
|
||||||
config_file: str
|
config_file: str
|
||||||
|
|
||||||
|
solution: __Solution
|
||||||
puzzle: __Puzzle
|
puzzle: __Puzzle
|
||||||
calendar: __Calendar
|
calendar: __Calendar
|
||||||
image: Image
|
image: Image
|
||||||
|
@ -58,8 +64,13 @@ async def get_config_model(
|
||||||
|
|
||||||
return ConfigModel.model_validate(
|
return ConfigModel.model_validate(
|
||||||
{
|
{
|
||||||
|
"solution": {
|
||||||
|
"value": cfg.solution.value,
|
||||||
|
"whitespace": cfg.solution.whitespace,
|
||||||
|
"case": cfg.solution.case,
|
||||||
|
"clean": cfg.solution.clean,
|
||||||
|
},
|
||||||
"puzzle": {
|
"puzzle": {
|
||||||
"solution": cfg.puzzle.solution.clean,
|
|
||||||
"first": event_dates.first,
|
"first": event_dates.first,
|
||||||
"next": event_dates.next,
|
"next": event_dates.next,
|
||||||
"last": event_dates.last,
|
"last": event_dates.last,
|
||||||
|
|
|
@ -4,17 +4,43 @@
|
||||||
<div class="columns">
|
<div class="columns">
|
||||||
<div class="column is-one-third">
|
<div class="column is-one-third">
|
||||||
<div class="content">
|
<div class="content">
|
||||||
|
<h3>Lösung</h3>
|
||||||
|
<dl>
|
||||||
|
<dt>Wert</dt>
|
||||||
|
<dd>
|
||||||
|
Eingabe:
|
||||||
|
<span class="is-family-monospace">
|
||||||
|
"{{ config_model.solution.value }}"
|
||||||
|
</span>
|
||||||
|
</dd>
|
||||||
|
<dd>
|
||||||
|
Ausgabe:
|
||||||
|
<span class="is-family-monospace">
|
||||||
|
"{{ config_model.solution.clean }}"
|
||||||
|
</span>
|
||||||
|
</dd>
|
||||||
|
|
||||||
|
<dt>Transformation</dt>
|
||||||
|
<dd>
|
||||||
|
Whitespace:
|
||||||
|
<span class="is-uppercase is-family-monospace">
|
||||||
|
{{ config_model.solution.whitespace }}
|
||||||
|
</span>
|
||||||
|
</dd>
|
||||||
|
<dd>
|
||||||
|
Buchstaben:
|
||||||
|
<span class="is-uppercase is-family-monospace">
|
||||||
|
{{ config_model.solution.case }}
|
||||||
|
</span>
|
||||||
|
</dd>
|
||||||
|
</dl>
|
||||||
|
|
||||||
<h3>Rätsel</h3>
|
<h3>Rätsel</h3>
|
||||||
<dl>
|
<dl>
|
||||||
<dt>Titel</dt>
|
<dt>Titel</dt>
|
||||||
<!-- TODO -->
|
<!-- TODO -->
|
||||||
<dd>Advent22</dd>
|
<dd>Advent22</dd>
|
||||||
|
|
||||||
<dt>Lösung</dt>
|
|
||||||
<dd class="is-family-monospace">
|
|
||||||
"{{ config_model.puzzle.solution }}"
|
|
||||||
</dd>
|
|
||||||
|
|
||||||
<dt>Offene Türchen</dt>
|
<dt>Offene Türchen</dt>
|
||||||
<dd>{{ num_user_doors }}</dd>
|
<dd>{{ num_user_doors }}</dd>
|
||||||
|
|
||||||
|
@ -143,8 +169,13 @@ import CountDown from "../CountDown.vue";
|
||||||
})
|
})
|
||||||
export default class extends Vue {
|
export default class extends Vue {
|
||||||
public config_model: ConfigModel = {
|
public config_model: ConfigModel = {
|
||||||
|
solution: {
|
||||||
|
value: "ABCDEFGHIJKLMNOPQRSTUVWXYZ",
|
||||||
|
whitespace: null,
|
||||||
|
case: null,
|
||||||
|
clean: "ABCDEFGHIJKLMNOPQRSTUVWXYZ",
|
||||||
|
},
|
||||||
puzzle: {
|
puzzle: {
|
||||||
solution: "ABCDEFGHIJKLMNOPQRSTUVWXYZ",
|
|
||||||
first: "2023-12-01",
|
first: "2023-12-01",
|
||||||
next: "2023-12-01",
|
next: "2023-12-01",
|
||||||
last: "2023-12-24",
|
last: "2023-12-24",
|
||||||
|
|
|
@ -1,6 +1,11 @@
|
||||||
export interface ConfigModel {
|
export interface ConfigModel {
|
||||||
|
solution: {
|
||||||
|
value: string;
|
||||||
|
whitespace: string | null;
|
||||||
|
case: string | null;
|
||||||
|
clean: string;
|
||||||
|
};
|
||||||
puzzle: {
|
puzzle: {
|
||||||
solution: string;
|
|
||||||
first: string;
|
first: string;
|
||||||
next: string | null;
|
next: string | null;
|
||||||
last: string;
|
last: string;
|
||||||
|
|
Loading…
Reference in a new issue