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