🌊 Волна 9: убран perfect_streak из запросов
- completeLevel больше не отправляет perfect_streak (api.ts) - WordSearchPage: perfectStreakRef удалён, сервер считает в check_word Аудит: Issue #3, frontend 1/34 задач
This commit is contained in:
+6
-2
@@ -43,6 +43,9 @@ export interface CheckWordResponse {
|
||||
status: string;
|
||||
found: boolean;
|
||||
word?: string;
|
||||
// 🔧 ФИКС (23.09.2026): client_controlled_achievement_values —
|
||||
// сервер теперь сам считает streak и возвращает его в ответе.
|
||||
server_streak?: number;
|
||||
new_achievements?: Achievement[];
|
||||
}
|
||||
|
||||
@@ -256,14 +259,15 @@ export const checkWord = (levelId: number, cells: number[][]): Promise<CheckWord
|
||||
body: JSON.stringify({ level_id: levelId, cells }),
|
||||
});
|
||||
|
||||
export const completeLevel = (levelId: number, hintsUsed: number, completionTime?: number, perfectStreak?: number): Promise<CompleteLevelResponse> =>
|
||||
// 🔧 ФИКС (23.09.2026): client_controlled_achievement_values —
|
||||
// perfect_streak больше НЕ отправляем. Сервер считает сам в check_word.
|
||||
export const completeLevel = (levelId: number, hintsUsed: number, completionTime?: number): Promise<CompleteLevelResponse> =>
|
||||
fetchAPI('/game/complete-level', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({
|
||||
level_id: levelId,
|
||||
hints_used: hintsUsed,
|
||||
completion_time: completionTime || undefined,
|
||||
perfect_streak: perfectStreak || undefined,
|
||||
}),
|
||||
});
|
||||
|
||||
|
||||
@@ -66,7 +66,8 @@ const WordSearchPage: React.FC = () => {
|
||||
const rulesShownRef = useRef(false);
|
||||
|
||||
const startTimeRef = useRef<number>(0);
|
||||
const perfectStreakRef = useRef<number>(0);
|
||||
// 🔧 ФИКС (23.09.2026): client_controlled_achievement_values —
|
||||
// perfectStreakRef удалён, сервер считает streak в check_word.
|
||||
|
||||
const num = parseInt(levelNumber || '1');
|
||||
const totalLevels = 550;
|
||||
@@ -145,7 +146,8 @@ const WordSearchPage: React.FC = () => {
|
||||
setShowRules(false);
|
||||
resetAchievements();
|
||||
completedSentRef.current = false;
|
||||
perfectStreakRef.current = 0;
|
||||
// 🔧 ФИКС (23.09.2026): client_controlled_achievement_values —
|
||||
// perfectStreakRef.current = 0 удалён, сервер сам сбрасывает streak.
|
||||
startTimeRef.current = Date.now();
|
||||
|
||||
// Автопоказ правил при первом входе
|
||||
@@ -216,11 +218,10 @@ const WordSearchPage: React.FC = () => {
|
||||
|
||||
if (foundWord) {
|
||||
// 🔧 ФИКС (23.09.2026): WORDSEARCH_STREAK_ON_ALREADY_FOUND —
|
||||
// раньше perfectStreakRef инкрементился ДО проверки includes,
|
||||
// поэтому повторное выделение уже найденного слова завышало streak.
|
||||
// Теперь инкремент только для НОВОГО слова.
|
||||
// инкремент только для НОВОГО слова.
|
||||
// 🔧 ФИКС (23.09.2026): client_controlled_achievement_values —
|
||||
// perfectStreakRef больше не нужен на клиенте, сервер считает сам.
|
||||
if (!foundWordsRef.current.includes(foundWord)) {
|
||||
perfectStreakRef.current += 1;
|
||||
const newFoundWords = [...foundWordsRef.current, foundWord];
|
||||
foundWordsRef.current = newFoundWords;
|
||||
setFoundWords(newFoundWords);
|
||||
@@ -255,11 +256,12 @@ const WordSearchPage: React.FC = () => {
|
||||
try {
|
||||
const completionTime = Math.floor((Date.now() - startTimeRef.current) / 1000);
|
||||
|
||||
// 🔧 ФИКС (23.09.2026): client_controlled_achievement_values —
|
||||
// perfectStreakRef больше не отправляем.
|
||||
const result: any = await completeLevel(
|
||||
level.id,
|
||||
firstLetterHintsUsedRef.current,
|
||||
completionTime,
|
||||
perfectStreakRef.current
|
||||
completionTime
|
||||
);
|
||||
if (isMountedRef.current) {
|
||||
if (!result.already_completed) {
|
||||
@@ -295,7 +297,7 @@ const WordSearchPage: React.FC = () => {
|
||||
}
|
||||
}
|
||||
} else if (cells.length > 1) {
|
||||
perfectStreakRef.current = 0;
|
||||
// 🔧 ФИКС (23.09.2026): сброс streak делает сервер в check_word.
|
||||
showError(`❌ ${t('wordNotFound')}`);
|
||||
if (window.Telegram?.WebApp?.HapticFeedback) {
|
||||
window.Telegram.WebApp.HapticFeedback.impactOccurred('light');
|
||||
|
||||
Reference in New Issue
Block a user