Files

63 lines
1.8 KiB
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"""Волновая структура филвордов.
Волна = 10 уровней. Волны бесконечные.
Размер сетки:
- Волна 1: 5×5 (уровни 1–5), 6×6 (уровни 6–10).
- Волна 2: 6×6 (уровни 1–5), 7×7 (уровни 6–10).
- Волна 3+: 7×7 (уровни 1–5), 8×8 (уровни 6–10).
Позже (когда добавим режимы сложности):
- Easy: всегда 5×5 (1–5) + 6×6 (6–10).
- Hard: всегда 8×8.
"""
from __future__ import annotations
WAVE_SIZE = 10
HALF_WAVE = 5
def wave_for_level(global_level: int) -> int:
"""Какая волна содержит этот глобальный уровень (1-based)."""
if global_level < 1:
return 1
return (global_level - 1) // WAVE_SIZE + 1
def level_in_wave(global_level: int) -> int:
"""Позиция уровня внутри волны (1..10)."""
return ((global_level - 1) % WAVE_SIZE) + 1
def grid_size_for(global_level: int) -> int:
"""Размер сетки для глобального уровня."""
wave = wave_for_level(global_level)
pos = level_in_wave(global_level)
if wave == 1:
sizes = (5, 6)
elif wave == 2:
sizes = (6, 7)
else:
sizes = (7, 8)
return sizes[0] if pos <= HALF_WAVE else sizes[1]
def max_points_for_wave() -> int:
"""Максимум очков за волну: 10 уровней × 110 = 1100."""
return 10 * 110
def wave_medal(points: int, max_points: int) -> str:
"""Медаль за волну: gold ≥90%, silver ≥70%, bronze ≥50%, иначе none."""
pct = 100 * points / max_points if max_points > 0 else 0
if pct >= 90:
return "gold"
if pct >= 70:
return "silver"
if pct >= 50:
return "bronze"
return "none"