cfg.puzzle.solution -> cfg.solution

This commit is contained in:
Jörn-Michael Miehe 2023-10-31 20:18:18 +01:00
parent b422913d7c
commit b74646994e
6 changed files with 65 additions and 15 deletions

View file

@ -78,9 +78,6 @@ class Puzzle(BaseModel):
# TODO penner neue Route GET /user/title
title: str
# Lösungswort
solution: TransformedString
# Tag, an dem der Kalender startet
# TODO penner
begin_day: int = 1
@ -117,7 +114,13 @@ class Image(BaseModel):
class Config(BaseModel):
# Login-Daten für Admin-Modus
admin: User
# Lösungswort
solution: TransformedString
# Weitere Einstellungen
puzzle: Puzzle
image: Image

View file

@ -46,7 +46,7 @@ async def get_all_parts(
Lösung auf vorhandene Tage aufteilen
"""
solution_length = len(cfg.puzzle.solution.clean)
solution_length = len(cfg.solution.clean)
num_days = len(days)
rnd = await Random.get()
@ -60,7 +60,7 @@ async def get_all_parts(
]
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] += letter

View file

@ -18,7 +18,7 @@ class Random(random.Random):
@classmethod
async def get(cls, bonus_salt: Any = "") -> Self:
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]:
return self.sample(population, k=len(population))

View file

@ -22,8 +22,13 @@ async def is_admin(
class ConfigModel(BaseModel):
class __Solution(BaseModel):
value: str
whitespace: str | None
case: str | None
clean: str
class __Puzzle(BaseModel):
solution: str
first: date
next: date | None
last: date
@ -39,6 +44,7 @@ class ConfigModel(BaseModel):
cache_ttl: int
config_file: str
solution: __Solution
puzzle: __Puzzle
calendar: __Calendar
image: Image
@ -58,8 +64,13 @@ async def get_config_model(
return ConfigModel.model_validate(
{
"solution": {
"value": cfg.solution.value,
"whitespace": cfg.solution.whitespace,
"case": cfg.solution.case,
"clean": cfg.solution.clean,
},
"puzzle": {
"solution": cfg.puzzle.solution.clean,
"first": event_dates.first,
"next": event_dates.next,
"last": event_dates.last,

View file

@ -4,17 +4,43 @@
<div class="columns">
<div class="column is-one-third">
<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>
<dl>
<dt>Titel</dt>
<!-- TODO -->
<dd>Advent22</dd>
<dt>Lösung</dt>
<dd class="is-family-monospace">
"{{ config_model.puzzle.solution }}"
</dd>
<dt>Offene Türchen</dt>
<dd>{{ num_user_doors }}</dd>
@ -143,8 +169,13 @@ import CountDown from "../CountDown.vue";
})
export default class extends Vue {
public config_model: ConfigModel = {
solution: {
value: "ABCDEFGHIJKLMNOPQRSTUVWXYZ",
whitespace: null,
case: null,
clean: "ABCDEFGHIJKLMNOPQRSTUVWXYZ",
},
puzzle: {
solution: "ABCDEFGHIJKLMNOPQRSTUVWXYZ",
first: "2023-12-01",
next: "2023-12-01",
last: "2023-12-24",

View file

@ -1,6 +1,11 @@
export interface ConfigModel {
solution: {
value: string;
whitespace: string | null;
case: string | null;
clean: string;
};
puzzle: {
solution: string;
first: string;
next: string | null;
last: string;