diff --git a/src/api.ts b/src/api.ts index 0ebd4c4..fc4c22b 100644 --- a/src/api.ts +++ b/src/api.ts @@ -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 => +// 🔧 ФИКС (23.09.2026): client_controlled_achievement_values — +// perfect_streak больше НЕ отправляем. Сервер считает сам в check_word. +export const completeLevel = (levelId: number, hintsUsed: number, completionTime?: number): Promise => fetchAPI('/game/complete-level', { method: 'POST', body: JSON.stringify({ level_id: levelId, hints_used: hintsUsed, completion_time: completionTime || undefined, - perfect_streak: perfectStreak || undefined, }), }); diff --git a/src/pages/WordSearchPage.tsx b/src/pages/WordSearchPage.tsx index 14676d3..80600fb 100644 --- a/src/pages/WordSearchPage.tsx +++ b/src/pages/WordSearchPage.tsx @@ -66,7 +66,8 @@ const WordSearchPage: React.FC = () => { const rulesShownRef = useRef(false); const startTimeRef = useRef(0); - const perfectStreakRef = useRef(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');