[Eva] Ева, патч 21 применён — теперь ты можешь #40

Merged
Drobysh merged 4 commits from eva/chat-b7c183-backend into main 2026-10-14 09:03:24 +00:00
Showing only changes of commit 5644b5be16 - Show all commits
+15 -8
View File
@@ -208,17 +208,24 @@ async def complete_bubble_level(request: Request):
) or 0
hints_used = min(max(0, hints_used), 3)
# 🆕 Расчёт звёзд
# Старт 5. Штрафы: hints(1) + wrong_words(до 3) + time(1)
time_penalty = 1 if (completion_time and completion_time > 60) else 0
wrong_penalty = min(max(0, wrong_words), 3)
hint_penalty = 1 if hints_used > 0 else 0
list_penalty = 1 if list_opened else 0
stars = max(1, 5 - time_penalty - wrong_penalty - hint_penalty - list_penalty)
# 🔧 НОВОЕ (14.10.2026): очки по формуле филворда.
# Hard — фикс 110. Easy/Medium — 100 − 20×hints − 20×list + bonus.
if difficulty == "hard":
if hints_used > 0 or list_opened:
raise HTTPException(
status_code=400,
detail="Hints and word list are disabled on Hard difficulty"
)
points = 110
else:
bonus = 10 if hints_used == 0 else 0
penalty_hints = 20 * hints_used
penalty_list = 0 if difficulty == "easy" else 20 * (1 if list_opened else 0)
points = max(20, min(110, 100 - penalty_hints - penalty_list + bonus))
# Начисляем XP
from services.xp import award_xp
xp_result = await award_xp(conn, telegram_id, "bubbles", stars)
xp_result = await award_xp(conn, telegram_id, "bubbles", points)
score = xp_result["points"]
await conn.execute("""