From 3dcc61c92f0d8eef50f03ca1bb859321d25a097e Mon Sep 17 00:00:00 2001 From: Drobysh Date: Mon, 2 Nov 2026 09:47:30 +0000 Subject: [PATCH 1/4] =?UTF-8?q?[Eva]=20=D0=94=D0=BE=D0=B1=D0=B0=D0=B2?= =?UTF-8?q?=D0=BB=D0=B5=D0=BD=D0=B0=20=D0=BA=D0=BE=D0=BB=D0=BE=D0=BD=D0=BA?= =?UTF-8?q?=D0=B0=20found=5Fwords=20=D0=B2=20user=5Fprogress?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- database.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/database.py b/database.py index dad15c5..14ec2ae 100644 --- a/database.py +++ b/database.py @@ -244,6 +244,21 @@ async def init_db(): """) logger.info("Added wave column to user_progress") + # ============ Авто-миграция: добавляем found_words в user_progress ============ + # 🔧 НОВОЕ (02.11.2026): found_words — список уже найденных слов уровня. + # Нужен, чтобы (1) повторный свайп найденного слова не накручивал + # серию и (2) complete-level мог проверить, что все слова найдены. + col_exists = await conn.fetchval(""" + SELECT 1 FROM information_schema.columns + WHERE table_name = 'user_progress' AND column_name = 'found_words' + """) + if not col_exists: + await conn.execute(""" + ALTER TABLE user_progress + ADD COLUMN found_words TEXT[] DEFAULT '{}' + """) + logger.info("Added found_words column to user_progress") + # ============ sentences ============ await conn.execute(""" CREATE TABLE IF NOT EXISTS sentences ( From eb26ba9a25a71ccafa42954414e530447b34dfe3 Mon Sep 17 00:00:00 2001 From: Drobysh Date: Mon, 2 Nov 2026 09:47:39 +0000 Subject: [PATCH 2/4] =?UTF-8?q?[Eva]=20=D0=9F=D0=BE=D0=B2=D1=82=D0=BE?= =?UTF-8?q?=D1=80=D0=BD=D1=8B=D0=B9=20=D1=81=D0=B2=D0=B0=D0=B9=D0=BF=20?= =?UTF-8?q?=D0=BD=D0=B0=D0=B9=D0=B4=D0=B5=D0=BD=D0=BD=D0=BE=D0=B3=D0=BE=20?= =?UTF-8?q?=D1=81=D0=BB=D0=BE=D0=B2=D0=B0=20=D0=B1=D0=BE=D0=BB=D1=8C=D1=88?= =?UTF-8?q?=D0=B5=20=D0=BD=D0=B5=20=D0=BD=D0=B0=D0=BA=D1=80=D1=83=D1=87?= =?UTF-8?q?=D0=B8=D0=B2=D0=B0=D0=B5=D1=82=20=D1=81=D0=B5=D1=80=D0=B8=D1=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- routers/game.py | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/routers/game.py b/routers/game.py index 691b71a..fdb2f2e 100644 --- a/routers/game.py +++ b/routers/game.py @@ -275,14 +275,33 @@ async def check_word(request: Request): ) current_streak = current_streak_row or 0 + # 🔧 НОВОЕ (02.11.2026): found_words — какие слова уже найдены. + # Повторный свайп уже найденного слова не должен накручивать серию. + found_words_row = await conn.fetchval( + "SELECT found_words FROM user_progress WHERE user_id = $1 AND level_id = $2", + telegram_id, level_id + ) + found_words = list(found_words_row or []) + if found_word: + if found_word in found_words: + # Слово уже найдено — не накручиваем серию. + return { + "status": "ok", + "found": True, + "word": found_word, + "server_streak": current_streak, + "already_found": True, + "new_achievements": [] + } server_streak = current_streak + 1 + found_words.append(found_word) await conn.execute(""" - INSERT INTO user_progress (user_id, level_id, current_streak, level) - VALUES ($1, $2, $3, $4) + INSERT INTO user_progress (user_id, level_id, current_streak, level, found_words) + VALUES ($1, $2, $3, $4, $5) ON CONFLICT (user_id, level_id) DO UPDATE - SET current_streak = $3 - """, telegram_id, level_id, server_streak, level_name) + SET current_streak = $3, found_words = $5 + """, telegram_id, level_id, server_streak, level_name, found_words) else: if current_streak > 0: await conn.execute(""" From 4ba1d90f0789c385969c1f4624f962f953d8873c Mon Sep 17 00:00:00 2001 From: Drobysh Date: Mon, 2 Nov 2026 09:47:49 +0000 Subject: [PATCH 3/4] =?UTF-8?q?[Eva]=20complete-level=20=D0=BF=D1=80=D0=BE?= =?UTF-8?q?=D0=B2=D0=B5=D1=80=D1=8F=D0=B5=D1=82,=20=D1=87=D1=82=D0=BE=20?= =?UTF-8?q?=D0=B2=D1=81=D0=B5=20=D1=81=D0=BB=D0=BE=D0=B2=D0=B0=20=D0=BD?= =?UTF-8?q?=D0=B0=D0=B9=D0=B4=D0=B5=D0=BD=D1=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- routers/game.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/routers/game.py b/routers/game.py index fdb2f2e..0a9b523 100644 --- a/routers/game.py +++ b/routers/game.py @@ -444,6 +444,19 @@ async def complete_level(request: Request): ) or 0 hints_used = min(max(0, hints_used), 3) + # 🔧 НОВОЕ (02.11.2026): проверяем, что все слова найдены. + # Раньше можно было вызвать complete-level напрямую, не найдя + # ни одного слова, и получить очки. + found_words = await conn.fetchval( + "SELECT found_words FROM user_progress WHERE user_id = $1 AND level_id = $2", + telegram_id, level_id + ) or [] + total_words = await conn.fetchval( + "SELECT COUNT(*) FROM level_words WHERE level_id = $1", level_id + ) or 0 + if len(found_words) < total_words: + raise HTTPException(400, "Not all words found") + # 🆕 Штрафы (филворд): # -20 за открытие списка слов (один раз за уровень) # -20 за каждую подсказку From 790eabbbef6cb99cab54d53bf2bd6f58037eadbb Mon Sep 17 00:00:00 2001 From: Drobysh Date: Mon, 2 Nov 2026 09:47:56 +0000 Subject: [PATCH 4/4] =?UTF-8?q?[Eva]=20Hard=20=D0=B2=20=D1=84=D0=B8=D0=BB?= =?UTF-8?q?=D0=B2=D0=BE=D1=80=D0=B4=D0=B5:=20110=20=E2=86=92=20150=20?= =?UTF-8?q?=D0=BE=D1=87=D0=BA=D0=BE=D0=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- routers/game.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/routers/game.py b/routers/game.py index 0a9b523..97e92ea 100644 --- a/routers/game.py +++ b/routers/game.py @@ -471,8 +471,8 @@ async def complete_level(request: Request): # Очки в зависимости от сложности if difficulty == "hard": - # Hard: фикс 110 (без подсказок и списка) - points = 110 + # Hard: фикс 150 (без подсказок и списка) + points = 150 else: # Easy / Medium bonus = 10 if hints_used == 0 else 0