Compare commits
8
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
707837b109 | ||
|
|
4e444499d4 | ||
|
|
06cb1ecbb0 | ||
|
|
4786a73c22 | ||
|
|
1a8d85a51d | ||
|
|
bbca26826d | ||
|
|
5fd4988985 | ||
|
|
4598289f06 |
+5
-12
@@ -1,5 +1,4 @@
|
|||||||
import random
|
import random
|
||||||
import hashlib # 🔧 НОВОЕ: импорт hashlib для стабильного хэширования
|
|
||||||
import json
|
import json
|
||||||
from fastapi import APIRouter, Request, HTTPException
|
from fastapi import APIRouter, Request, HTTPException
|
||||||
from auth import require_auth
|
from auth import require_auth
|
||||||
@@ -82,15 +81,9 @@ def split_word_into_parts(word: str, forbidden_parts: set = None) -> list:
|
|||||||
attempts += 1
|
attempts += 1
|
||||||
|
|
||||||
# Если за 50 попыток не нашли уникальное разбиение —
|
# Если за 50 попыток не нашли уникальное разбиение —
|
||||||
# разбиваем слово ПО БУКВАМ и добавляем суффикс с хешем слова
|
# разбиваем слово ПО БУКВАМ (каждая буква — отдельный пузырь).
|
||||||
# Такой суффикс гарантированно уникален для каждого слова
|
# Без суффиксов: части остаются чистыми, игрок видит обычные буквы.
|
||||||
# 🔧 ИСПРАВЛЕНО: заменён hash() на hashlib.md5 для стабильности между запусками
|
return [letter for letter in word]
|
||||||
word_hash = hashlib.md5(word.encode('utf-8')).hexdigest()[:4] # Берём первые 4 символа MD5
|
|
||||||
unique_parts = []
|
|
||||||
for idx, letter in enumerate(word):
|
|
||||||
unique_parts.append(f"{letter}.{word_hash}.{idx}")
|
|
||||||
|
|
||||||
return unique_parts
|
|
||||||
|
|
||||||
|
|
||||||
@router.get("/next")
|
@router.get("/next")
|
||||||
@@ -370,14 +363,14 @@ async def complete_bubble_level(request: Request):
|
|||||||
list_opened = (progress["current_list_opened"] if progress else 0) or 0
|
list_opened = (progress["current_list_opened"] if progress else 0) or 0
|
||||||
|
|
||||||
# 🔧 НОВОЕ (14.10.2026): очки по формуле филворда.
|
# 🔧 НОВОЕ (14.10.2026): очки по формуле филворда.
|
||||||
# Hard — фикс 110. Easy/Medium — 100 − 20×hints − 20×list + bonus.
|
# Hard — фикс 150. Easy/Medium — 100 − 20×hints − 20×list + bonus.
|
||||||
if difficulty == "hard":
|
if difficulty == "hard":
|
||||||
if hints_used > 0 or list_opened:
|
if hints_used > 0 or list_opened:
|
||||||
raise HTTPException(
|
raise HTTPException(
|
||||||
status_code=400,
|
status_code=400,
|
||||||
detail="Hints and word list are disabled on Hard difficulty"
|
detail="Hints and word list are disabled on Hard difficulty"
|
||||||
)
|
)
|
||||||
points = 110
|
points = 150
|
||||||
else:
|
else:
|
||||||
bonus = 10 if hints_used == 0 else 0
|
bonus = 10 if hints_used == 0 else 0
|
||||||
penalty_hints = 20 * hints_used
|
penalty_hints = 20 * hints_used
|
||||||
|
|||||||
Reference in New Issue
Block a user