From 437921d9dda3766b99af38b42777f98df8a287e5 Mon Sep 17 00:00:00 2001 From: Drobysh Date: Tue, 13 Oct 2026 11:19:08 +0000 Subject: [PATCH 1/7] =?UTF-8?q?[Eva]=20=D0=A3=D0=B1=D1=80=D0=B0=D1=82?= =?UTF-8?q?=D1=8C=20=D0=BA=D0=BE=D0=BD=D1=81=D1=82=D0=B0=D0=BD=D1=82=D1=8B?= =?UTF-8?q?=20=D0=B7=D0=B2=D1=91=D0=B7=D0=B4=20(POINTS=5FPER=5FSTAR,=20MAX?= =?UTF-8?q?=5FSTARS,=20MIN=5FSTARS)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- services/xp.py | 9 --------- 1 file changed, 9 deletions(-) diff --git a/services/xp.py b/services/xp.py index 8073165..894fd32 100644 --- a/services/xp.py +++ b/services/xp.py @@ -35,15 +35,6 @@ GAMES = ["wordsearch", "choose", "sentence", "bubbles"] # Множитель игры дня FEATURED_MULTIPLIER = 1.5 -# Базовая ставка: 1 звезда = 20 XP -POINTS_PER_STAR = 20 - -# Максимум звёзд за уровень -MAX_STARS = 5 - -# Минимум звёзд за пройденный уровень -MIN_STARS = 1 - # Коэффициенты баланса (настроить после первых 1000 сессий) # Применяются к base_points ДО множителя игры дня. GAME_XP_COEF: dict[str, float] = { -- 2.54.0 From df3d32ecd51f5f522932557ac5024ce1413cd1c1 Mon Sep 17 00:00:00 2001 From: Drobysh Date: Tue, 13 Oct 2026 11:20:29 +0000 Subject: [PATCH 2/7] =?UTF-8?q?[Eva]=20=D0=A1=D0=B8=D0=B3=D0=BD=D0=B0?= =?UTF-8?q?=D1=82=D1=83=D1=80=D0=B0=20award=5Fxp:=20stars=20=E2=86=92=20po?= =?UTF-8?q?ints?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- services/xp.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/services/xp.py b/services/xp.py index 894fd32..124dd7a 100644 --- a/services/xp.py +++ b/services/xp.py @@ -183,7 +183,7 @@ async def award_xp( conn, user_id: int, game: str, - stars: int, + points: int, ) -> dict: """ Единая функция начисления опыта. @@ -192,11 +192,10 @@ async def award_xp( conn: asyncpg connection (уже acquired) user_id: telegram_id (может быть отрицательным для Pleily) game: 'wordsearch' | 'choose' | 'sentence' | 'bubbles' - stars: 1..5 + points: готовые очки за уровень (20–110), формула считается до вызова Returns: { - "stars": int, "base_points": int, "multiplier": float, "points": int, -- 2.54.0 From 9c975dde7908133fba35bad673a28b7f3f3ccada Mon Sep 17 00:00:00 2001 From: Drobysh Date: Tue, 13 Oct 2026 11:20:37 +0000 Subject: [PATCH 3/7] =?UTF-8?q?[Eva]=20=D0=A0=D0=B0=D1=81=D1=87=D1=91?= =?UTF-8?q?=D1=82=20=D0=BE=D1=87=D0=BA=D0=BE=D0=B2:=20base=5Fpoints=20?= =?UTF-8?q?=D0=B8=D0=B7=20points,=20final=5Fpoints=20=D1=81=20=D0=BC=D0=BD?= =?UTF-8?q?=D0=BE=D0=B6=D0=B8=D1=82=D0=B5=D0=BB=D0=B5=D0=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- services/xp.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/services/xp.py b/services/xp.py index 124dd7a..f675f86 100644 --- a/services/xp.py +++ b/services/xp.py @@ -209,18 +209,16 @@ async def award_xp( } """ # 1. Валидация - stars = max(MIN_STARS, min(MAX_STARS, int(stars))) if game not in GAME_XP_COEF: raise ValueError(f"Unknown game: {game}") - # 2. База - base = stars * POINTS_PER_STAR - base = int(round(base * GAME_XP_COEF.get(game, 1.0))) + # 2. База с коэффициентом игры (для баланса) + base_points = int(round(points * GAME_XP_COEF.get(game, 1.0))) # 3. Множитель игры дня is_featured = (game == featured_game()) multiplier = FEATURED_MULTIPLIER if is_featured else 1.0 - points = int(round(base * multiplier)) + final_points = int(round(base_points * multiplier)) # 4. Читаем текущий total_xp row = await conn.fetchrow( -- 2.54.0 From 981e65e57cc4e5de309fe3d3021b55bb9a8c88cc Mon Sep 17 00:00:00 2001 From: Drobysh Date: Tue, 13 Oct 2026 11:20:49 +0000 Subject: [PATCH 4/7] [Eva] xp_log: stars=0, base_points, final_points --- services/xp.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/xp.py b/services/xp.py index f675f86..06d77b4 100644 --- a/services/xp.py +++ b/services/xp.py @@ -247,7 +247,7 @@ async def award_xp( INSERT INTO xp_log (user_id, game, stars, base_points, multiplier, points) VALUES ($1, $2, $3, $4, $5, $6) """, - user_id, game, stars, base, multiplier, points, + user_id, game, 0, base_points, multiplier, final_points, ) # 6. Обновляем user_profile -- 2.54.0 From 6f341a7f3334c44b908815d2daf803190908c381 Mon Sep 17 00:00:00 2001 From: Drobysh Date: Tue, 13 Oct 2026 11:20:55 +0000 Subject: [PATCH 5/7] =?UTF-8?q?[Eva]=20user=5Fprofile:=20=D0=BD=D0=B0?= =?UTF-8?q?=D1=87=D0=B8=D1=81=D0=BB=D0=B5=D0=BD=D0=B8=D0=B5=20final=5Fpoin?= =?UTF-8?q?ts?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- services/xp.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/services/xp.py b/services/xp.py index 06d77b4..eeea781 100644 --- a/services/xp.py +++ b/services/xp.py @@ -251,7 +251,7 @@ async def award_xp( ) # 6. Обновляем user_profile - new_total = old_total + points + new_total = old_total + final_points await conn.execute( """ UPDATE user_profile @@ -260,7 +260,7 @@ async def award_xp( updated_at = NOW() WHERE user_id = $1 """, - user_id, points, + user_id, final_points, ) # 7. Считаем новый уровень -- 2.54.0 From b62311d3ed67b04ec3d92b05cafa9f9c8fc2e203 Mon Sep 17 00:00:00 2001 From: Drobysh Date: Tue, 13 Oct 2026 11:21:01 +0000 Subject: [PATCH 6/7] =?UTF-8?q?[Eva]=20=D0=9B=D0=BE=D0=B3=20level=5Fup:=20?= =?UTF-8?q?final=5Fpoints?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- services/xp.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/xp.py b/services/xp.py index eeea781..149d549 100644 --- a/services/xp.py +++ b/services/xp.py @@ -275,7 +275,7 @@ async def award_xp( } logger.info( "[xp] user=%s level_up %s → %s (%s), +%s xp", - user_id, old_level, new_level, rank_key, points, + user_id, old_level, new_level, rank_key, final_points, ) return { -- 2.54.0 From da7182fb6b1ebdc2d213f32424677b1f96dd7f69 Mon Sep 17 00:00:00 2001 From: Drobysh Date: Tue, 13 Oct 2026 11:21:07 +0000 Subject: [PATCH 7/7] =?UTF-8?q?[Eva]=20=D0=92=D0=BE=D0=B7=D0=B2=D1=80?= =?UTF-8?q?=D0=B0=D1=82=20award=5Fxp=20=D0=B1=D0=B5=D0=B7=20=D0=BA=D0=BB?= =?UTF-8?q?=D1=8E=D1=87=D0=B0=20stars?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- services/xp.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/services/xp.py b/services/xp.py index 149d549..6ee81b4 100644 --- a/services/xp.py +++ b/services/xp.py @@ -279,10 +279,9 @@ async def award_xp( ) return { - "stars": stars, - "base_points": base, + "base_points": base_points, "multiplier": multiplier, - "points": points, + "points": final_points, "featured": is_featured, "level_up": level_up, "total_xp": new_total, -- 2.54.0