🌊 Волна 10: backend client-controlled + лимиты (5 багов)
- client_controlled_hints_game: hints_used из user_progress (game.py + database.py) - client_controlled_hints_bubblewords: current_hints_used из bubble_words_progress (bubblewords.py + database.py) - client_controlled_mistakes_wordquiz: current_mistakes из word_quiz_progress (wordquiz.py + database.py) - sentence_hint_no_limit: таблица sentence_hints_used + лимит 1 раз (sentences.py + database.py) - typing_hint_no_limit: таблица typing_hints_used + лимит 1 раз (typing.py + database.py) Аудит v2: Issue #5, backend 5/10 задач
This commit is contained in:
+15
-7
@@ -176,12 +176,10 @@ async def complete_bubble_level(request: Request):
|
||||
"""Завершение уровня пузырей, начисление очков и проверка достижений"""
|
||||
telegram_id, _ = await require_auth(request)
|
||||
body = await request.json()
|
||||
hints_used = body.get("hints_used", 0)
|
||||
words_count = body.get("words_count", 3)
|
||||
completion_time = body.get("completion_time")
|
||||
|
||||
hints_used = min(max(0, hints_used), 3)
|
||||
score = max(10, 100 - hints_used * 10)
|
||||
# 🔧 ФИКС (24.09.2026): client_controlled_hints_bubblewords —
|
||||
# hints_used больше НЕ берём от клиента. Читаем из bubble_words_progress.current_hints_used.
|
||||
|
||||
pool = await get_pool()
|
||||
async with pool.acquire() as conn:
|
||||
@@ -196,13 +194,23 @@ async def complete_bubble_level(request: Request):
|
||||
"SELECT current_level FROM users WHERE telegram_id = $1", telegram_id
|
||||
) or "A1"
|
||||
|
||||
# 🔧 ФИКС (24.09.2026): client_controlled_hints_bubblewords —
|
||||
# читаем серверный hints_used.
|
||||
hints_used = await conn.fetchval(
|
||||
"SELECT current_hints_used FROM bubble_words_progress WHERE user_id = $1",
|
||||
telegram_id
|
||||
) or 0
|
||||
hints_used = min(max(0, hints_used), 3)
|
||||
score = max(10, 100 - hints_used * 10)
|
||||
|
||||
await conn.execute("""
|
||||
INSERT INTO bubble_words_progress (user_id, levels_completed, total_score, level)
|
||||
VALUES ($1, 1, $2, $3)
|
||||
INSERT INTO bubble_words_progress (user_id, levels_completed, total_score, level, current_hints_used)
|
||||
VALUES ($1, 1, $2, $3, 0)
|
||||
ON CONFLICT (user_id) DO UPDATE
|
||||
SET levels_completed = bubble_words_progress.levels_completed + 1,
|
||||
total_score = bubble_words_progress.total_score + $2,
|
||||
level = $3
|
||||
level = $3,
|
||||
current_hints_used = 0
|
||||
""", telegram_id, score, current_level)
|
||||
|
||||
# 🔧 ФИКС (23.09.2026): achievements_nested_pool_acquire_bubblewords —
|
||||
|
||||
Reference in New Issue
Block a user