mirror of
https://code.lenaisten.de/Lenaisten/advent22.git
synced 2024-12-23 05:03:02 +00:00
implement cfg.puzzle.extra_days
This commit is contained in:
parent
082f50c66b
commit
090da8c679
6 changed files with 34 additions and 13 deletions
2
Ideen.md
2
Ideen.md
|
@ -1,6 +1,5 @@
|
|||
# MUSS
|
||||
|
||||
- api: Config-Liste von Extra-Türchen (kein Buchstabe, nur manuelles Bild)
|
||||
|
||||
# KANN
|
||||
|
||||
|
@ -21,3 +20,4 @@
|
|||
- api: admin Login case sensitivity (username "admin" == "AdMiN")
|
||||
- api: `config.solution` - whitespace="IGNORE"->"REMOVE" umbenennen, +Sonderzeichen
|
||||
- api: Config-Option "Überspringe leere Türchen" (standard ja)
|
||||
- api: Config-Liste von Extra-Türchen (kein Buchstabe, nur manuelles Bild)
|
||||
|
|
|
@ -34,9 +34,6 @@ class Site(BaseModel):
|
|||
|
||||
|
||||
class Puzzle(BaseModel):
|
||||
# Türchen ohne Buchstabe überspringen
|
||||
skip_empty: bool = True
|
||||
|
||||
# Tag, an dem der Kalender startet
|
||||
begin_day: int = 1
|
||||
|
||||
|
@ -46,6 +43,12 @@ class Puzzle(BaseModel):
|
|||
# Kalender so viele Tage nach der letzten Türöffnung schließen
|
||||
close_after: int = 90
|
||||
|
||||
# Tage, für die kein Buchstabe vorgesehen wird
|
||||
extra_days: set[int] = set()
|
||||
|
||||
# Türchen ohne Buchstabe überspringen
|
||||
skip_empty: bool = True
|
||||
|
||||
|
||||
class Image(BaseModel):
|
||||
# Quadrat, Seitenlänge in px
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
import re
|
||||
from collections import defaultdict
|
||||
from dataclasses import dataclass
|
||||
from datetime import date
|
||||
from io import BytesIO
|
||||
|
@ -42,6 +41,11 @@ async def get_all_parts(
|
|||
Lösung auf vorhandene Tage aufteilen
|
||||
"""
|
||||
|
||||
# noch keine Buchstaben verteilt
|
||||
result = {day: "" for day in days}
|
||||
# extra-Tage ausfiltern
|
||||
days = [day for day in days if day not in cfg.puzzle.extra_days]
|
||||
|
||||
solution_length = len(cfg.solution.clean)
|
||||
num_days = len(days)
|
||||
|
||||
|
@ -55,12 +59,9 @@ async def get_all_parts(
|
|||
*rnd.sample(days, solution_length % num_days),
|
||||
]
|
||||
|
||||
result: defaultdict[int, str] = defaultdict(str)
|
||||
for day, letter in zip(solution_days, cfg.solution.clean):
|
||||
result[day] += letter
|
||||
|
||||
result |= {missed_day: "" for missed_day in set(days) - set(result.keys())}
|
||||
|
||||
return result
|
||||
|
||||
|
||||
|
@ -74,7 +75,7 @@ async def get_all_event_dates(
|
|||
"""
|
||||
|
||||
if cfg.puzzle.skip_empty:
|
||||
days = [day for day in days if parts[day] != ""]
|
||||
days = [day for day in days if parts[day] != "" or day in cfg.puzzle.extra_days]
|
||||
|
||||
return EventDates(
|
||||
today=date.today(),
|
||||
|
|
|
@ -36,12 +36,13 @@ class AdminConfigModel(BaseModel):
|
|||
clean: str
|
||||
|
||||
class __Puzzle(BaseModel):
|
||||
skip_empty: bool
|
||||
first: date
|
||||
next: date | None
|
||||
last: date
|
||||
end: date
|
||||
seed: str
|
||||
extra_days: list[int]
|
||||
skip_empty: bool
|
||||
|
||||
class __Calendar(BaseModel):
|
||||
config_file: str
|
||||
|
@ -88,12 +89,13 @@ async def get_config_model(
|
|||
"clean": cfg.solution.clean,
|
||||
},
|
||||
"puzzle": {
|
||||
"skip_empty": cfg.puzzle.skip_empty,
|
||||
"first": event_dates.first,
|
||||
"next": event_dates.next,
|
||||
"last": event_dates.last,
|
||||
"end": event_dates.end,
|
||||
"seed": cfg.random_seed,
|
||||
"extra_days": sorted(cfg.puzzle.extra_days),
|
||||
"skip_empty": cfg.puzzle.skip_empty,
|
||||
},
|
||||
"calendar": {
|
||||
"config_file": cfg.calendar,
|
||||
|
|
|
@ -69,6 +69,19 @@
|
|||
"{{ admin_config_model.puzzle.seed }}"
|
||||
</dd>
|
||||
|
||||
<dt>Extra-Tage</dt>
|
||||
<dd>
|
||||
<template
|
||||
v-for="(day, index) in admin_config_model.puzzle.extra_days"
|
||||
:key="`extra_day-${index}`"
|
||||
>
|
||||
<span>
|
||||
<template v-if="index > 0">, </template>
|
||||
{{ day }}
|
||||
</span>
|
||||
</template>
|
||||
</dd>
|
||||
|
||||
<dt>Leere Türchen</dt>
|
||||
<dd v-if="admin_config_model.puzzle.skip_empty">Überspringen</dd>
|
||||
<dd v-else>Anzeigen</dd>
|
||||
|
@ -199,12 +212,13 @@ export default class extends Vue {
|
|||
clean: "ABCDEFGHIJKLMNOPQRSTUVWXYZ",
|
||||
},
|
||||
puzzle: {
|
||||
skip_empty: true,
|
||||
first: "2023-12-01",
|
||||
next: "2023-12-01",
|
||||
last: "2023-12-24",
|
||||
end: "2024-04-01",
|
||||
seed: "",
|
||||
extra_days: [],
|
||||
skip_empty: true,
|
||||
},
|
||||
calendar: {
|
||||
config_file: "lorem ipsum",
|
||||
|
|
|
@ -7,12 +7,13 @@ export interface AdminConfigModel {
|
|||
clean: string;
|
||||
};
|
||||
puzzle: {
|
||||
skip_empty: boolean;
|
||||
first: string;
|
||||
next: string | null;
|
||||
last: string;
|
||||
end: string;
|
||||
seed: string;
|
||||
extra_days: number[];
|
||||
skip_empty: boolean;
|
||||
};
|
||||
calendar: {
|
||||
config_file: string;
|
||||
|
|
Loading…
Reference in a new issue