diff --git a/src/components/CustomGameModal.vue b/src/components/CustomGameModal.vue index 43ad9f7..9c0fa39 100644 --- a/src/components/CustomGameModal.vue +++ b/src/components/CustomGameModal.vue @@ -1,5 +1,5 @@ @@ -52,6 +73,29 @@ const confirm = () => { 80 + +
{{ t('custom.fillRate') }}
+{{ errorMsg }}
@@ -87,6 +131,7 @@ const confirm = () => { border: 1px solid var(--accent-cyan); box-shadow: 0 0 50px rgba(0, 242, 255, 0.2); animation: slideUp 0.3s ease; + transition: all 0.3s ease-in-out; } h2 { @@ -161,6 +206,26 @@ input[type="range"]::-moz-range-thumb { font-size: 0.85rem; } +.difficulty-indicator { + margin: 20px 0; + font-size: 1.2rem; + display: flex; + justify-content: center; + gap: 10px; + align-items: center; +} + +.difficulty-indicator .label { + color: var(--text-color); +} + +.difficulty-indicator .value { + font-weight: bold; + text-transform: uppercase; + text-shadow: 0 0 10px currentColor; + transition: color 0.3s ease; +} + .error { color: #ff4d4d; font-size: 0.9rem; diff --git a/src/composables/useI18n.js b/src/composables/useI18n.js index 1ec7a12..3216ac7 100644 --- a/src/composables/useI18n.js +++ b/src/composables/useI18n.js @@ -29,6 +29,12 @@ const messages = { 'custom.cancel': 'Anuluj', 'custom.start': 'Start', 'custom.sizeError': 'Rozmiar musi być między 5 a 80!', + 'custom.fillRate': 'Wypełnienie', + 'custom.difficulty': 'Poziom trudności', + 'difficulty.easy': 'Łatwy', + 'difficulty.harder': 'Trudniejszy', + 'difficulty.hardest': 'Najtrudniejszy', + 'difficulty.extreme': 'Ekstremalny', 'win.title': 'GRATULACJE!', 'win.message': 'Rozwiązałeś zagadkę!', 'win.time': 'Czas:', @@ -128,6 +134,12 @@ const messages = { 'custom.cancel': 'Cancel', 'custom.start': 'Start', 'custom.sizeError': 'Size must be between 5 and 80!', + 'custom.fillRate': 'Fill Rate', + 'custom.difficulty': 'Difficulty', + 'difficulty.easy': 'Easy', + 'difficulty.harder': 'Harder', + 'difficulty.hardest': 'Hardest', + 'difficulty.extreme': 'Extreme', 'win.title': 'CONGRATULATIONS!', 'win.message': 'You solved the puzzle!', 'win.time': 'Time:', diff --git a/src/stores/puzzle.js b/src/stores/puzzle.js index e9b343c..c81400b 100644 --- a/src/stores/puzzle.js +++ b/src/stores/puzzle.js @@ -120,15 +120,16 @@ export const usePuzzleStore = defineStore('puzzle', () => { hasUsedGuide.value = false; elapsedTime.value = 0; startTimer(); + saveState(); } - function initCustomGame(customSize) { + function initCustomGame(customSize, density = 0.5) { stopTimer(); currentLevelId.value = 'custom'; size.value = customSize; // Generate random grid - solution.value = generateRandomGrid(customSize); + solution.value = generateRandomGrid(customSize, density); resetGrid(); isGameWon.value = false; @@ -275,44 +276,9 @@ export const usePuzzleStore = defineStore('puzzle', () => { return false; } - function initGame(levelId = 'easy') { - // If init called without args and we have save, load it? - // User might want to start fresh if clicking buttons. - // Let's add explicit 'continue' logic or just auto-load on first run. - // For now, let's just stick to explicit init, but maybe load on mount if exists? - // The user didn't explicitly ask for "Continue", but "features from HTML". - // HTML usually auto-saves and loads. - - stopTimer(); - currentLevelId.value = levelId; - - let puzzle = PUZZLES[levelId]; - if (!puzzle) { - puzzle = PUZZLES['easy']; - } - - size.value = puzzle.size; - solution.value = puzzle.grid; - - resetGrid(); - isGameWon.value = false; - elapsedTime.value = 0; - startTimer(); - saveState(); - } + // Duplicate initGame removed - // Modify initCustomGame similarly - function initCustomGame(customSize) { - stopTimer(); - currentLevelId.value = 'custom'; - size.value = customSize; - solution.value = generateRandomGrid(customSize); - resetGrid(); - isGameWon.value = false; - elapsedTime.value = 0; - startTimer(); - saveState(); - } + // Duplicate initCustomGame removed // Duplicate toggleCell/setCell removed diff --git a/src/utils/puzzleUtils.js b/src/utils/puzzleUtils.js index 3566e5d..fc58dbc 100644 --- a/src/utils/puzzleUtils.js +++ b/src/utils/puzzleUtils.js @@ -40,13 +40,12 @@ export function calculateHints(grid) { return { rowHints, colHints }; } -export function generateRandomGrid(size) { +export function generateRandomGrid(size, density = 0.5) { const grid = []; for (let i = 0; i < size; i++) { const row = []; for (let j = 0; j < size; j++) { - // ~25% empty cells - row.push(Math.random() > 0.25 ? 1 : 0); + row.push(Math.random() < density ? 1 : 0); } grid.push(row); }