fix: prevent premature solved status, add DFS boost button, mark boosted exports

This commit is contained in:
2026-02-13 07:03:08 +01:00
parent 43c0290fac
commit c3188bb740
7 changed files with 145 additions and 16 deletions

View File

@@ -68,6 +68,7 @@ const messages = {
'win.shareDownload': 'Pobierz zrzut',
'win.difficulty': 'Poziom:',
'win.usedGuide': 'Podpowiedzi: {percent}% ({count})',
'win.boosted': 'Wspomagany (DFS)',
'pwa.installTitle': 'Zainstaluj aplikację i graj offline',
'pwa.installMobile': 'Dodaj do ekranu głównego',
'pwa.installDesktop': 'Zainstaluj na komputerze',
@@ -244,6 +245,7 @@ const messages = {
'win.shareDownload': 'Download screenshot',
'win.difficulty': 'Difficulty:',
'win.usedGuide': 'Hints: {percent}% ({count})',
'win.boosted': 'Boosted (DFS)',
'pwa.installTitle': 'Install the app and play offline',
'pwa.installMobile': 'Add to home screen',
'pwa.installDesktop': 'Install on desktop',

View File

@@ -8,6 +8,7 @@ export function useSolver() {
const isPlaying = ref(false);
const isProcessing = ref(false);
const isStuck = ref(false);
const speedIndex = ref(0);
const speeds = [1000, 500, 250, 125, 62, 31, 16];
const speedLabels = ['x1', 'x2', 'x4', 'x8', 'x16', 'x32', 'x64'];
@@ -25,6 +26,7 @@ export function useSolver() {
}
if (isProcessing.value) return;
store.markGuideUsed();
isStuck.value = false;
ensureWorker();
isProcessing.value = true;
@@ -62,6 +64,19 @@ export function useSolver() {
}
}
function boost() {
if (store.isGameWon || isProcessing.value) return;
store.markBoostUsed();
isStuck.value = false;
ensureWorker();
isProcessing.value = true;
const playerGrid = store.playerGrid.map(row => row.slice());
const solution = store.solution.map(row => row.slice());
const id = ++requestId;
worker.postMessage({ id, playerGrid, solution, locale: locale.value, action: 'boost' });
}
function ensureWorker() {
if (worker) return;
worker = new Worker(new URL('../workers/solverWorker.js', import.meta.url), { type: 'module' });
@@ -71,15 +86,18 @@ export function useSolver() {
if (type === 'move') {
store.setCell(r, c, state);
isProcessing.value = false;
isStuck.value = false;
if (store.isGameWon) {
pause();
return;
}
} else if (type === 'done') {
isProcessing.value = false;
isStuck.value = false;
pause();
} else if (type === 'stuck') {
isProcessing.value = false;
isStuck.value = true;
pause();
} else {
isProcessing.value = false;
@@ -95,11 +113,13 @@ export function useSolver() {
return {
isPlaying,
isStuck,
speedIndex,
speedLabel: computed(() => speedLabels[speedIndex.value]),
statusText,
step,
togglePlay,
changeSpeed
changeSpeed,
boost
};
}