"""Schwierigkeitsstufen: wie schnell die Koffer einlaufen. Referenz: der Altstand lief mit 6 bzw. 2 Pixeln pro Frame bei 120 fps, also 720 bzw. 240 Pixel pro Sekunde. Das ist die Basis, von der aus skaliert wird: * **Easy** – 0,58× so schnell wie der Altstand (zum Einsteigen) * **Normal** – 1,3× so schnell wie der Altstand * **Hard** – 1,5× so schnell wie der Altstand Das Zeitfenster für die Befehle (Einrasten/Drehen/Stapeln) steht in ``config.SNAP_WINDOW`` und ist für alle Stufen gleich gross. """ from __future__ import annotations from dataclasses import dataclass @dataclass(frozen=True) class Difficulty: """Eine Stufe. ``speed_fast`` gilt bis kurz vor der Barriere, dann ``speed_slow``.""" key: str label: str speed_fast: float speed_slow: float def __str__(self) -> str: return self.label DIFFICULTIES: tuple[Difficulty, ...] = ( Difficulty("easy", "Easy", speed_fast=420.0, speed_slow=140.0), Difficulty("normal", "Normal", speed_fast=740.0, speed_slow=250.0), Difficulty("hard", "Hard", speed_fast=1080.0, speed_slow=360.0), ) DEFAULT_DIFFICULTY: Difficulty = DIFFICULTIES[1] def by_key(key: str) -> Difficulty: for difficulty in DIFFICULTIES: if difficulty.key == key: return difficulty return DEFAULT_DIFFICULTY