diff --git a/routers/hints.py b/routers/hints.py index a1481aa..544541f 100644 --- a/routers/hints.py +++ b/routers/hints.py @@ -1,3 +1,5 @@ +import random + from fastapi import APIRouter, Request, HTTPException from auth import require_auth from database import get_pool @@ -6,7 +8,7 @@ router = APIRouter(prefix="/hints", tags=["hints"]) @router.get("/first-letter/{level_id}") -async def get_first_letter_hint(request: Request, level_id: int): +async def get_first_letter_hint(request: Request, level_id: int, found: str = ""): """Подсказка: показывает первую букву случайного ненайденного слова""" telegram_id, _ = await require_auth(request) @@ -63,13 +65,21 @@ async def get_first_letter_hint(request: Request, level_id: int): if not words_with_paths: raise HTTPException(404, "No word paths found for this level") + # 🔧 ФИКС (12.10.2026): hint_shows_found_word — + # подсказка показывала уже найденное слово. Теперь фронт передаёт + # найденные слова в query-параметре found (через запятую), и мы + # исключаем их из кандидатов. + found_words = {w.strip() for w in found.split(",") if w.strip()} + remaining_words = [w for w in words_with_paths if w not in found_words] + + if not remaining_words: + raise HTTPException(404, "All words found") + # 🔧 ФИКС (11.10.2026): hint_always_first_word — # раньше всегда возвращалось первое слово списка, поэтому # повторные нажатия давали одну и ту же букву. Теперь слово - # выбирается по индексу уже использованных подсказок: - # 1-я подсказка → слово 0, 2-я → слово 1, 3-я → слово 2. - hint_index = hints_already_used % len(words_with_paths) - found_word = words_with_paths[hint_index] + # выбирается случайно из ещё не найденных. + found_word = random.choice(remaining_words) first_cell = word_paths[found_word][0] # 🔧 ФИКС (25.09.2026): hint_consumed_before_word_paths_check —