105 Commits

Author SHA1 Message Date
430f370196 1.9.0 2026-02-11 05:31:50 +01:00
c8789741fc feat(guide): update playback speed options (remove 3x, add 8x/16x) 2026-02-11 05:31:49 +01:00
53ef63f25f 1.8.5 2026-02-11 05:24:12 +01:00
9b869bdb5f perf(puzzle): optimize undo logic and dragging performance 2026-02-11 05:22:32 +01:00
764763016b 1.8.4 2026-02-11 05:00:18 +01:00
5cfabf40e8 feat(i18n): add simulation translations for all languages 2026-02-11 05:00:16 +01:00
460de9fac9 1.8.3 2026-02-11 04:50:21 +01:00
a264ac75e3 perf(CustomGameModal): optimize difficulty map rendering with caching 2026-02-11 04:50:13 +01:00
43822d03ac 1.8.2 2026-02-11 04:47:09 +01:00
2e83d3ea9f feat(i18n): add translations for difficulty simulation feature 2026-02-11 04:47:02 +01:00
0023190f5a 1.8.1 2026-02-11 04:32:39 +01:00
2552ea9423 fix(CustomGameModal): improve difficulty map UX - resize and drag outside 2026-02-11 04:32:32 +01:00
e08be0574d 1.8.0 2026-02-11 04:14:12 +01:00
3797e7715f feat(difficulty): implement Monte Carlo simulation for accurate difficulty calculation 2026-02-11 04:14:06 +01:00
19c4516d22 1.7.0 2026-02-11 03:47:30 +01:00
06c345e8f0 fix(CustomGameModal): improve layout of difficulty level and percentage 2026-02-11 03:47:24 +01:00
d9ae630fe5 1.6.4 2026-02-11 03:03:15 +01:00
132c4ebced feat: enhance custom game difficulty calculation and UI 2026-02-11 03:03:14 +01:00
0b8dcacd18 1.6.3 2026-02-11 02:16:01 +01:00
4ef4f2b251 fix: solver logic and feat: save custom game settings 2026-02-11 02:15:59 +01:00
17d8cbfedd 1.6.2 2026-02-11 01:20:38 +01:00
a41e337c43 fix: improve solver gap enforcement and overlapping block detection 2026-02-11 01:20:29 +01:00
1f1de61044 1.6.1 2026-02-11 01:02:00 +01:00
7f22aa9198 fix: enforce gap between blocks in solver logic 2026-02-11 01:01:53 +01:00
133a676682 1.6.0 2026-02-11 00:47:20 +01:00
30318fafaf feat: improve victory sound effect 2026-02-11 00:47:07 +01:00
5549e24c17 1.5.0 2026-02-11 00:27:50 +01:00
ca3193d07e feat: display hint usage percentage in win screen 2026-02-11 00:27:43 +01:00
41a36768cd 1.4.0 2026-02-11 00:18:37 +01:00
315fb29eac refactor: use inline SVGs and compact download button in WinModal 2026-02-11 00:18:32 +01:00
395e9caff4 1.3.0 2026-02-10 23:59:38 +01:00
e1c73181d4 feat: improve share buttons functionality with hybrid approach 2026-02-10 23:59:32 +01:00
874e35bba3 1.2.1 2026-02-10 23:44:03 +01:00
69b04d3336 fix: add missing translations for Arabic and other languages 2026-02-10 23:43:58 +01:00
c5b212234a 1.2.0 2026-02-10 23:13:21 +01:00
8e0ddf3a72 refactor: optimize solver to use pure logic without guessing 2026-02-10 23:13:14 +01:00
bfb24cfb03 1.1.0 2026-02-10 23:00:49 +01:00
8d3bde8d38 feat: add difficulty and dirty flag to result image 2026-02-10 23:00:43 +01:00
d25fa67100 1.0.7 2026-02-10 22:35:34 +01:00
c7834bd8bf feat: enhance custom game mode with fill rate slider and difficulty indicator 2026-02-10 22:35:28 +01:00
7d405ef0f6 1.0.6 2026-02-10 21:56:21 +01:00
431b534477 fix: update PWA translations for multiple languages 2026-02-10 21:56:21 +01:00
ebf9030185 1.0.5 2026-02-10 21:35:24 +01:00
8f52f5daa5 fix: correct PWA translations for all languages 2026-02-10 21:35:24 +01:00
2dc68ab8d0 1.0.4 2026-02-10 21:28:58 +01:00
993ced424e feat: add PWA translations for all languages 2026-02-10 21:28:58 +01:00
1b0b6a671a 1.0.3 2026-02-10 21:16:28 +01:00
e39ac9a794 feat: implement PWA update prompt and manual reload 2026-02-10 21:16:28 +01:00
81ed97b263 1.0.2 2026-02-10 21:06:59 +01:00
61359e6665 style: fix footer position and visibility 2026-02-10 21:06:59 +01:00
8f8f6a6e8e fix: update guide panel colors to be readable in light mode 2026-02-10 21:00:21 +01:00
a02c17e462 fix: use theme variables for install banner readability 2026-02-10 20:56:04 +01:00
490ca6b4a5 revert: remove css filter inversion for share icons 2026-02-10 20:53:18 +01:00
10ed00b7b6 fix: refine share icon inversion to target only specific elements 2026-02-10 20:51:46 +01:00
a335adeca8 style: scope share icon color inversion to win modal only 2026-02-10 20:49:37 +01:00
72adab61c7 fix: ensure share icons are visible in light mode by inverting colors 2026-02-10 20:44:35 +01:00
2c892f3adc chore: bump version to 1.0.1 2026-02-10 17:43:17 +01:00
b6b289cd57 chore: enhance PWA cache invalidation logic 2026-02-10 17:35:05 +01:00
ea2e3c573b feat: display app version from package.json in footer 2026-02-10 17:24:19 +01:00
cf2e9de56d refactor: remove all guide usage checks from win modal logic 2026-02-10 17:18:17 +01:00
4313831e84 75% filled blocks 2026-02-10 09:54:56 +01:00
60ef352cda 10% more filled blocks 2026-02-10 09:39:05 +01:00
91c873ef97 feat: always show share buttons in win modal regardless of guide usage 2026-02-10 04:50:13 +01:00
c4764e9505 fix: allow horizontal scroll on desktop for large grids 2026-02-10 03:10:37 +01:00
423258ef17 chore: remove tracked build artifacts from dev-dist 2026-02-10 03:05:46 +01:00
0bd2b905a9 Fix desktop grid scroll issue: remove width limit and hide scrollbar 2026-02-10 02:59:10 +01:00
572acc3979 feat: complete translations for new game and guide buttons for all languages 2026-02-10 02:43:19 +01:00
7256809f0b fix: japanese translation for new game and guide buttons 2026-02-10 02:35:26 +01:00
9f89fe4340 feat: disable win fanfare and sharing if guide was used 2026-02-10 02:30:58 +01:00
7610a4a523 feat: localize new game and guide buttons 2026-02-10 01:54:34 +01:00
285c486c6e chore: add i18n update script 2026-02-10 01:40:09 +01:00
8a97cc5d0d feat: add traditional chinese language support 2026-02-10 01:37:50 +01:00
c287523fa5 feat: localize new game and guide buttons 2026-02-10 01:20:37 +01:00
eb6b69134f fix: persist language selection and enforce search keys 2026-02-10 00:54:29 +01:00
4d50eb97eb Fix Undo icon and improve mobile UX 2026-02-10 00:08:23 +01:00
a1df95d3d4 fix 2026-02-09 23:35:21 +01:00
4a7c088776 fix: update flag mappings and ignore dev artifacts 2026-02-09 23:25:50 +01:00
6f3ed143e5 feat: add system theme option to navbar 2026-02-09 23:17:52 +01:00
c5f9da81a9 Merge branch 'feature/upgrades' into main 2026-02-09 22:58:42 +01:00
0decf2324c Add vitest setup and puzzleUtils tests 2026-02-09 22:51:00 +01:00
bae864c2d0 UI/UX Overhaul: NavBar, Icons, Mobile Menu, and Status Panel Integration
- Przeniesienie tytułu i wybieraka języka do nowego komponentu NavBar
- Integracja biblioteki flag-icons i mapowanie kodów języków na kraje
- Wdrożenie biblioteki ikon lucide-vue-next i zastąpienie wszystkich emoji ikonami SVG
- Implementacja pełnoekranowego, responsywnego menu mobilnego (hamburger menu)
- Przeniesienie przycisków akcji (Reset, Cofnij) do komponentu StatusPanel
- Nowy układ panelu statusu (połączone statystyki i akcje w jednym szklanym panelu)
- Usunięcie przestarzałych komponentów (GameActions, LevelSelector)
- Poprawki wizualne i stylowe (glassmorphism, animacje przejść)
2026-02-09 22:40:16 +01:00
96999f740c Fix flag display priority to prefer inline SVG when file is missing 2026-02-09 22:21:10 +01:00
4982e6ed49 Add Batch 3 and Batch 4 translations and improve language detection 2026-02-09 22:10:03 +01:00
8dde1d7997 gitignore 2026-02-09 22:10:00 +01:00
d5b5df0e62 Add missing SVG flags for: af, my, km, ceb, gu, ht, ig, ilo, jv, kn, kk, rw, rn, ku, ckb, ky, lo, mr, mn, ne, om, ps, pa, so, bo, ti, wo, yo 2026-02-09 21:47:26 +01:00
3fb5d6bde5 Load flags from SVG files with aliases and fallback; add SVG flags for missing languages (globe, ja, ko, id, fa, he, az, hy, am, ms, vi, th, tl, sw, uz, ta, te); build verified 2026-02-09 21:36:01 +01:00
ee5d3fdb0d Add ESC to close language dropdown; extend language labels and locales; verify build 2026-02-09 21:32:04 +01:00
0f2f97ff3f Fill full translations for new European languages; add language search labels; verify build and preview 2026-02-09 21:27:53 +01:00
70d7242bfe Języki: desktop wyrównanie do lewej; mobile pełny ekran + wyszukiwarka; tłumaczenia etykiet wyszukiwania 2026-02-09 21:16:42 +01:00
8d74848c3f Mobile dropdown: visibility and readability improvements; i18n locales filtered to fully translated; dynamic dropdown locales 2026-02-09 20:33:36 +01:00
c0a42d7213 Mobile: poprawa czytelności i widoczności dropdownu języków; aktualizacja konfiguracji 2026-02-09 20:00:15 +01:00
7a7551107f Mobile: poprawa widoczności dropdownu języków; rozszerzenie listy języków 2026-02-09 19:18:23 +01:00
133440db4c Sort language list alphabetically 2026-02-08 19:19:08 +01:00
4ca1aaa981 Enable automatic PWA refresh on update 2026-02-08 19:09:50 +01:00
62ad664ec0 Add full language UI translations and modal wrapping 2026-02-08 19:00:25 +01:00
27515639aa Add theme toggle and styling updates 2026-02-08 18:29:16 +01:00
ad4ea9617c Grid: highlight hints on hover 2026-02-08 18:18:07 +01:00
4b2d98fe05 PWA: install banner copy 2026-02-08 17:53:06 +01:00
736ed0e5e8 Mobile: long press stawia X 2026-02-08 17:33:51 +01:00
28eb9ad391 PWA: manifest i service worker 2026-02-08 17:19:04 +01:00
86e7a02a5c Win: share screenshot z linkiem i ikonami 2026-02-08 17:12:15 +01:00
0f944857b6 Guide: optymalizacja dla dużych siatek 2026-02-08 16:47:37 +01:00
3316532cbc Custom game: suwak rozmiaru 5-80 2026-02-08 16:33:26 +01:00
40a6725bf1 i18n: automatyczny język + ręczny przełącznik 2026-02-08 16:28:30 +01:00
2d4d03f5d3 Win: fanfary audio + wibracja na urządzeniach mobilnych; UI: usunięty przycisk SPRAWDŹ 2026-02-08 16:13:07 +01:00
89 changed files with 18645 additions and 444 deletions

1
.gitignore vendored
View File

@@ -4,3 +4,4 @@ dist
.vscode .vscode
.idea .idea
*.log *.log
dev-dist

37
check_i18n.js Normal file
View File

@@ -0,0 +1,37 @@
const fs = require('fs');
const fileContent = fs.readFileSync('src/composables/useI18n.js', 'utf8');
// Extract the messages object
const match = fileContent.match(/const messages = ({[\s\S]*?});/);
if (!match) {
console.error('Could not find messages object');
process.exit(1);
}
// We need to make the string valid JS to eval it.
// It seems the content inside `const messages = { ... };` is valid JS object notation.
// But we need to be careful about imports or other things if we were to `eval` the whole file.
// We'll just `eval` the object part.
const messagesStr = match[1];
const messages = eval(`(${messagesStr})`);
const enKeys = Object.keys(messages.en);
const languages = Object.keys(messages);
const missing = {};
languages.forEach(lang => {
if (lang === 'en') return;
const langKeys = Object.keys(messages[lang]);
const missingKeys = enKeys.filter(k => !langKeys.includes(k));
if (missingKeys.length > 0) {
missing[lang] = missingKeys;
}
});
console.log(JSON.stringify(missing, null, 2));

View File

@@ -0,0 +1,118 @@
size,density,avg_solved_percent,min_solved_percent,max_solved_percent,avg_time_ms
5,0.1,89.40,36.00,100.00,0.03
5,0.2,74.20,8.00,100.00,0.04
5,0.3,74.20,0.00,100.00,0.04
5,0.4,80.80,8.00,100.00,0.03
5,0.5,96.80,68.00,100.00,0.03
5,0.6,97.60,84.00,100.00,0.03
5,0.7,99.20,84.00,100.00,0.03
5,0.8,100.00,100.00,100.00,0.02
5,0.9,100.00,100.00,100.00,0.02
10,0.1,56.60,19.00,86.00,0.04
10,0.2,19.80,0.00,51.00,0.05
10,0.3,15.75,0.00,73.00,0.07
10,0.4,54.05,0.00,100.00,0.13
10,0.5,91.80,59.00,100.00,0.17
10,0.6,99.80,96.00,100.00,0.07
10,0.7,99.80,96.00,100.00,0.05
10,0.8,100.00,100.00,100.00,0.04
10,0.9,100.00,100.00,100.00,0.02
15,0.1,37.04,13.33,61.78,0.05
15,0.2,9.78,0.00,26.67,0.03
15,0.3,1.89,0.00,8.00,0.03
15,0.4,11.82,0.00,61.33,0.08
15,0.5,68.20,2.67,100.00,0.14
15,0.6,99.56,96.44,100.00,0.09
15,0.7,99.78,97.33,100.00,0.07
15,0.8,100.00,100.00,100.00,0.05
15,0.9,100.00,100.00,100.00,0.03
20,0.1,22.59,5.00,41.50,0.04
20,0.2,3.25,0.00,14.50,0.04
20,0.3,0.56,0.00,5.00,0.04
20,0.4,1.46,0.00,3.25,0.07
20,0.5,36.75,1.25,99.00,0.26
20,0.6,99.80,99.00,100.00,0.23
20,0.7,99.95,99.00,100.00,0.13
20,0.8,100.00,100.00,100.00,0.09
20,0.9,100.00,100.00,100.00,0.05
25,0.1,16.00,7.84,32.80,0.06
25,0.2,0.00,0.00,0.00,0.04
25,0.3,0.05,0.00,0.64,0.06
25,0.4,0.89,0.00,9.44,0.12
25,0.5,19.13,1.12,96.48,0.35
25,0.6,99.25,94.88,100.00,0.50
25,0.7,99.90,99.36,100.00,0.24
25,0.8,100.00,100.00,100.00,0.15
25,0.9,99.97,99.36,100.00,0.08
30,0.1,7.99,0.00,16.00,0.08
30,0.2,0.17,0.00,3.33,0.07
30,0.3,0.00,0.00,0.00,0.08
30,0.4,0.38,0.00,4.11,0.18
30,0.5,5.42,0.78,21.44,0.41
30,0.6,99.42,94.78,100.00,0.94
30,0.7,99.93,99.56,100.00,0.42
30,0.8,100.00,100.00,100.00,0.22
30,0.9,100.00,100.00,100.00,0.13
35,0.1,5.65,0.00,13.80,0.11
35,0.2,0.14,0.00,2.86,0.10
35,0.3,0.00,0.00,0.00,0.13
35,0.4,0.13,0.00,0.57,0.22
35,0.5,4.42,0.41,23.18,0.56
35,0.6,91.11,8.41,100.00,1.58
35,0.7,99.97,99.67,100.00,0.60
35,0.8,100.00,100.00,100.00,0.33
35,0.9,100.00,100.00,100.00,0.17
40,0.1,2.73,0.00,9.81,0.13
40,0.2,0.00,0.00,0.00,0.13
40,0.3,0.00,0.00,0.00,0.18
40,0.4,0.03,0.00,0.31,0.27
40,0.5,2.14,0.00,9.56,0.69
40,0.6,91.44,22.31,100.00,2.92
40,0.7,99.99,99.75,100.00,0.84
40,0.8,100.00,100.00,100.00,0.43
40,0.9,100.00,100.00,100.00,0.24
45,0.1,1.78,0.00,4.69,0.17
45,0.2,0.00,0.00,0.00,0.17
45,0.3,0.00,0.00,0.00,0.24
45,0.4,0.01,0.00,0.15,0.33
45,0.5,1.44,0.40,5.14,0.96
45,0.6,81.72,6.02,100.00,5.28
45,0.7,99.94,99.41,100.00,1.28
45,0.8,100.00,100.00,100.00,0.64
45,0.9,100.00,100.00,100.00,0.30
50,0.1,1.70,0.00,5.92,0.20
50,0.2,0.00,0.00,0.00,0.23
50,0.3,0.00,0.00,0.00,0.30
50,0.4,0.01,0.00,0.16,0.38
50,0.5,0.51,0.00,1.80,0.90
50,0.6,73.26,5.60,100.00,7.94
50,0.7,99.96,99.76,100.00,1.63
50,0.8,100.00,100.00,100.00,0.83
50,0.9,100.00,100.00,100.00,0.41
60,0.1,0.17,0.00,1.67,0.24
60,0.2,0.00,0.00,0.00,0.35
60,0.3,0.00,0.00,0.00,0.50
60,0.4,0.00,0.00,0.06,0.64
60,0.5,0.23,0.00,1.67,1.24
60,0.6,35.02,1.33,100.00,10.76
60,0.7,99.97,99.83,100.00,2.96
60,0.8,100.00,100.00,100.00,1.27
60,0.9,100.00,100.00,100.00,0.62
70,0.1,0.14,0.00,1.43,0.34
70,0.2,0.00,0.00,0.00,0.54
70,0.3,0.00,0.00,0.00,0.76
70,0.4,0.00,0.00,0.00,0.96
70,0.5,0.04,0.00,0.29,1.49
70,0.6,16.40,1.00,99.71,22.21
70,0.7,99.97,99.73,100.00,4.92
70,0.8,100.00,99.92,100.00,2.03
70,0.9,100.00,100.00,100.00,0.89
80,0.1,0.00,0.00,0.00,0.44
80,0.2,0.00,0.00,0.00,0.78
80,0.3,0.00,0.00,0.00,1.07
80,0.4,0.00,0.00,0.00,1.34
80,0.5,0.01,0.00,0.08,1.97
80,0.6,1.21,0.41,2.30,3.92
80,0.7,99.98,99.94,100.00,7.79
80,0.8,100.00,100.00,100.00,3.14
80,0.9,100.00,100.00,100.00,1.31
1 size density avg_solved_percent min_solved_percent max_solved_percent avg_time_ms
2 5 0.1 89.40 36.00 100.00 0.03
3 5 0.2 74.20 8.00 100.00 0.04
4 5 0.3 74.20 0.00 100.00 0.04
5 5 0.4 80.80 8.00 100.00 0.03
6 5 0.5 96.80 68.00 100.00 0.03
7 5 0.6 97.60 84.00 100.00 0.03
8 5 0.7 99.20 84.00 100.00 0.03
9 5 0.8 100.00 100.00 100.00 0.02
10 5 0.9 100.00 100.00 100.00 0.02
11 10 0.1 56.60 19.00 86.00 0.04
12 10 0.2 19.80 0.00 51.00 0.05
13 10 0.3 15.75 0.00 73.00 0.07
14 10 0.4 54.05 0.00 100.00 0.13
15 10 0.5 91.80 59.00 100.00 0.17
16 10 0.6 99.80 96.00 100.00 0.07
17 10 0.7 99.80 96.00 100.00 0.05
18 10 0.8 100.00 100.00 100.00 0.04
19 10 0.9 100.00 100.00 100.00 0.02
20 15 0.1 37.04 13.33 61.78 0.05
21 15 0.2 9.78 0.00 26.67 0.03
22 15 0.3 1.89 0.00 8.00 0.03
23 15 0.4 11.82 0.00 61.33 0.08
24 15 0.5 68.20 2.67 100.00 0.14
25 15 0.6 99.56 96.44 100.00 0.09
26 15 0.7 99.78 97.33 100.00 0.07
27 15 0.8 100.00 100.00 100.00 0.05
28 15 0.9 100.00 100.00 100.00 0.03
29 20 0.1 22.59 5.00 41.50 0.04
30 20 0.2 3.25 0.00 14.50 0.04
31 20 0.3 0.56 0.00 5.00 0.04
32 20 0.4 1.46 0.00 3.25 0.07
33 20 0.5 36.75 1.25 99.00 0.26
34 20 0.6 99.80 99.00 100.00 0.23
35 20 0.7 99.95 99.00 100.00 0.13
36 20 0.8 100.00 100.00 100.00 0.09
37 20 0.9 100.00 100.00 100.00 0.05
38 25 0.1 16.00 7.84 32.80 0.06
39 25 0.2 0.00 0.00 0.00 0.04
40 25 0.3 0.05 0.00 0.64 0.06
41 25 0.4 0.89 0.00 9.44 0.12
42 25 0.5 19.13 1.12 96.48 0.35
43 25 0.6 99.25 94.88 100.00 0.50
44 25 0.7 99.90 99.36 100.00 0.24
45 25 0.8 100.00 100.00 100.00 0.15
46 25 0.9 99.97 99.36 100.00 0.08
47 30 0.1 7.99 0.00 16.00 0.08
48 30 0.2 0.17 0.00 3.33 0.07
49 30 0.3 0.00 0.00 0.00 0.08
50 30 0.4 0.38 0.00 4.11 0.18
51 30 0.5 5.42 0.78 21.44 0.41
52 30 0.6 99.42 94.78 100.00 0.94
53 30 0.7 99.93 99.56 100.00 0.42
54 30 0.8 100.00 100.00 100.00 0.22
55 30 0.9 100.00 100.00 100.00 0.13
56 35 0.1 5.65 0.00 13.80 0.11
57 35 0.2 0.14 0.00 2.86 0.10
58 35 0.3 0.00 0.00 0.00 0.13
59 35 0.4 0.13 0.00 0.57 0.22
60 35 0.5 4.42 0.41 23.18 0.56
61 35 0.6 91.11 8.41 100.00 1.58
62 35 0.7 99.97 99.67 100.00 0.60
63 35 0.8 100.00 100.00 100.00 0.33
64 35 0.9 100.00 100.00 100.00 0.17
65 40 0.1 2.73 0.00 9.81 0.13
66 40 0.2 0.00 0.00 0.00 0.13
67 40 0.3 0.00 0.00 0.00 0.18
68 40 0.4 0.03 0.00 0.31 0.27
69 40 0.5 2.14 0.00 9.56 0.69
70 40 0.6 91.44 22.31 100.00 2.92
71 40 0.7 99.99 99.75 100.00 0.84
72 40 0.8 100.00 100.00 100.00 0.43
73 40 0.9 100.00 100.00 100.00 0.24
74 45 0.1 1.78 0.00 4.69 0.17
75 45 0.2 0.00 0.00 0.00 0.17
76 45 0.3 0.00 0.00 0.00 0.24
77 45 0.4 0.01 0.00 0.15 0.33
78 45 0.5 1.44 0.40 5.14 0.96
79 45 0.6 81.72 6.02 100.00 5.28
80 45 0.7 99.94 99.41 100.00 1.28
81 45 0.8 100.00 100.00 100.00 0.64
82 45 0.9 100.00 100.00 100.00 0.30
83 50 0.1 1.70 0.00 5.92 0.20
84 50 0.2 0.00 0.00 0.00 0.23
85 50 0.3 0.00 0.00 0.00 0.30
86 50 0.4 0.01 0.00 0.16 0.38
87 50 0.5 0.51 0.00 1.80 0.90
88 50 0.6 73.26 5.60 100.00 7.94
89 50 0.7 99.96 99.76 100.00 1.63
90 50 0.8 100.00 100.00 100.00 0.83
91 50 0.9 100.00 100.00 100.00 0.41
92 60 0.1 0.17 0.00 1.67 0.24
93 60 0.2 0.00 0.00 0.00 0.35
94 60 0.3 0.00 0.00 0.00 0.50
95 60 0.4 0.00 0.00 0.06 0.64
96 60 0.5 0.23 0.00 1.67 1.24
97 60 0.6 35.02 1.33 100.00 10.76
98 60 0.7 99.97 99.83 100.00 2.96
99 60 0.8 100.00 100.00 100.00 1.27
100 60 0.9 100.00 100.00 100.00 0.62
101 70 0.1 0.14 0.00 1.43 0.34
102 70 0.2 0.00 0.00 0.00 0.54
103 70 0.3 0.00 0.00 0.00 0.76
104 70 0.4 0.00 0.00 0.00 0.96
105 70 0.5 0.04 0.00 0.29 1.49
106 70 0.6 16.40 1.00 99.71 22.21
107 70 0.7 99.97 99.73 100.00 4.92
108 70 0.8 100.00 99.92 100.00 2.03
109 70 0.9 100.00 100.00 100.00 0.89
110 80 0.1 0.00 0.00 0.00 0.44
111 80 0.2 0.00 0.00 0.00 0.78
112 80 0.3 0.00 0.00 0.00 1.07
113 80 0.4 0.00 0.00 0.00 1.34
114 80 0.5 0.01 0.00 0.08 1.97
115 80 0.6 1.21 0.41 2.30 3.92
116 80 0.7 99.98 99.94 100.00 7.79
117 80 0.8 100.00 100.00 100.00 3.14
118 80 0.9 100.00 100.00 100.00 1.31

View File

@@ -0,0 +1,938 @@
[
{
"size": 5,
"density": 0.1,
"avgSolved": 89.4,
"minSolved": 36,
"maxSolved": 100,
"avgTime": 0.031666799999999905
},
{
"size": 5,
"density": 0.2,
"avgSolved": 74.2,
"minSolved": 8,
"maxSolved": 100,
"avgTime": 0.03671869999999924
},
{
"size": 5,
"density": 0.3,
"avgSolved": 74.2,
"minSolved": 0,
"maxSolved": 100,
"avgTime": 0.04439559999999983
},
{
"size": 5,
"density": 0.4,
"avgSolved": 80.8,
"minSolved": 8,
"maxSolved": 100,
"avgTime": 0.0317166499999999
},
{
"size": 5,
"density": 0.5,
"avgSolved": 96.8,
"minSolved": 68,
"maxSolved": 100,
"avgTime": 0.0309604000000002
},
{
"size": 5,
"density": 0.6,
"avgSolved": 97.6,
"minSolved": 84,
"maxSolved": 100,
"avgTime": 0.031464499999999875
},
{
"size": 5,
"density": 0.7,
"avgSolved": 99.2,
"minSolved": 84,
"maxSolved": 100,
"avgTime": 0.03086874999999978
},
{
"size": 5,
"density": 0.8,
"avgSolved": 100,
"minSolved": 100,
"maxSolved": 100,
"avgTime": 0.01615615000000048
},
{
"size": 5,
"density": 0.9,
"avgSolved": 100,
"minSolved": 100,
"maxSolved": 100,
"avgTime": 0.02271474999999956
},
{
"size": 10,
"density": 0.1,
"avgSolved": 56.6,
"minSolved": 19,
"maxSolved": 86,
"avgTime": 0.042958299999999915
},
{
"size": 10,
"density": 0.2,
"avgSolved": 19.8,
"minSolved": 0,
"maxSolved": 51,
"avgTime": 0.050141749999999874
},
{
"size": 10,
"density": 0.3,
"avgSolved": 15.75,
"minSolved": 0,
"maxSolved": 73,
"avgTime": 0.06852290000000014
},
{
"size": 10,
"density": 0.4,
"avgSolved": 54.05,
"minSolved": 0,
"maxSolved": 100,
"avgTime": 0.12701870000000018
},
{
"size": 10,
"density": 0.5,
"avgSolved": 91.8,
"minSolved": 59,
"maxSolved": 100,
"avgTime": 0.16561034999999985
},
{
"size": 10,
"density": 0.6,
"avgSolved": 99.8,
"minSolved": 96,
"maxSolved": 100,
"avgTime": 0.07136649999999882
},
{
"size": 10,
"density": 0.7,
"avgSolved": 99.8,
"minSolved": 96,
"maxSolved": 100,
"avgTime": 0.04808134999999893
},
{
"size": 10,
"density": 0.8,
"avgSolved": 100,
"minSolved": 100,
"maxSolved": 100,
"avgTime": 0.03795824999999979
},
{
"size": 10,
"density": 0.9,
"avgSolved": 100,
"minSolved": 100,
"maxSolved": 100,
"avgTime": 0.024952100000000855
},
{
"size": 15,
"density": 0.1,
"avgSolved": 37.044444444444444,
"minSolved": 13.333333333333334,
"maxSolved": 61.77777777777778,
"avgTime": 0.045045850000000345
},
{
"size": 15,
"density": 0.2,
"avgSolved": 9.777777777777775,
"minSolved": 0,
"maxSolved": 26.666666666666668,
"avgTime": 0.034581349999998776
},
{
"size": 15,
"density": 0.3,
"avgSolved": 1.8888888888888886,
"minSolved": 0,
"maxSolved": 8,
"avgTime": 0.029402199999999823
},
{
"size": 15,
"density": 0.4,
"avgSolved": 11.822222222222223,
"minSolved": 0,
"maxSolved": 61.33333333333333,
"avgTime": 0.07898965000000047
},
{
"size": 15,
"density": 0.5,
"avgSolved": 68.19999999999999,
"minSolved": 2.666666666666667,
"maxSolved": 100,
"avgTime": 0.1374602999999997
},
{
"size": 15,
"density": 0.6,
"avgSolved": 99.55555555555554,
"minSolved": 96.44444444444444,
"maxSolved": 100,
"avgTime": 0.09379159999999978
},
{
"size": 15,
"density": 0.7,
"avgSolved": 99.77777777777779,
"minSolved": 97.33333333333334,
"maxSolved": 100,
"avgTime": 0.07072704999999928
},
{
"size": 15,
"density": 0.8,
"avgSolved": 100,
"minSolved": 100,
"maxSolved": 100,
"avgTime": 0.050104250000000405
},
{
"size": 15,
"density": 0.9,
"avgSolved": 100,
"minSolved": 100,
"maxSolved": 100,
"avgTime": 0.031362550000000766
},
{
"size": 20,
"density": 0.1,
"avgSolved": 22.5875,
"minSolved": 5,
"maxSolved": 41.5,
"avgTime": 0.04363335000000035
},
{
"size": 20,
"density": 0.2,
"avgSolved": 3.25,
"minSolved": 0,
"maxSolved": 14.499999999999998,
"avgTime": 0.03823525000000103
},
{
"size": 20,
"density": 0.3,
"avgSolved": 0.5625,
"minSolved": 0,
"maxSolved": 5,
"avgTime": 0.03880414999999786
},
{
"size": 20,
"density": 0.4,
"avgSolved": 1.4625,
"minSolved": 0,
"maxSolved": 3.25,
"avgTime": 0.06692695000000129
},
{
"size": 20,
"density": 0.5,
"avgSolved": 36.75,
"minSolved": 1.25,
"maxSolved": 99,
"avgTime": 0.25872084999999884
},
{
"size": 20,
"density": 0.6,
"avgSolved": 99.8,
"minSolved": 99,
"maxSolved": 100,
"avgTime": 0.2258772000000004
},
{
"size": 20,
"density": 0.7,
"avgSolved": 99.95,
"minSolved": 99,
"maxSolved": 100,
"avgTime": 0.13418124999999997
},
{
"size": 20,
"density": 0.8,
"avgSolved": 100,
"minSolved": 100,
"maxSolved": 100,
"avgTime": 0.09264785000000053
},
{
"size": 20,
"density": 0.9,
"avgSolved": 100,
"minSolved": 100,
"maxSolved": 100,
"avgTime": 0.05307699999999756
},
{
"size": 25,
"density": 0.1,
"avgSolved": 16.000000000000004,
"minSolved": 7.84,
"maxSolved": 32.800000000000004,
"avgTime": 0.05678540000000112
},
{
"size": 25,
"density": 0.2,
"avgSolved": 0,
"minSolved": 0,
"maxSolved": 0,
"avgTime": 0.04278334999999842
},
{
"size": 25,
"density": 0.3,
"avgSolved": 0.048,
"minSolved": 0,
"maxSolved": 0.64,
"avgTime": 0.05884794999999983
},
{
"size": 25,
"density": 0.4,
"avgSolved": 0.8880000000000001,
"minSolved": 0,
"maxSolved": 9.44,
"avgTime": 0.11761245000000287
},
{
"size": 25,
"density": 0.5,
"avgSolved": 19.128000000000007,
"minSolved": 1.1199999999999999,
"maxSolved": 96.48,
"avgTime": 0.3490229000000021
},
{
"size": 25,
"density": 0.6,
"avgSolved": 99.24799999999998,
"minSolved": 94.88,
"maxSolved": 100,
"avgTime": 0.49611459999999996
},
{
"size": 25,
"density": 0.7,
"avgSolved": 99.904,
"minSolved": 99.36,
"maxSolved": 100,
"avgTime": 0.23916465000000073
},
{
"size": 25,
"density": 0.8,
"avgSolved": 100,
"minSolved": 100,
"maxSolved": 100,
"avgTime": 0.14604994999999973
},
{
"size": 25,
"density": 0.9,
"avgSolved": 99.96799999999999,
"minSolved": 99.36,
"maxSolved": 100,
"avgTime": 0.08385419999999896
},
{
"size": 30,
"density": 0.1,
"avgSolved": 7.988888888888889,
"minSolved": 0,
"maxSolved": 16,
"avgTime": 0.08026245000000073
},
{
"size": 30,
"density": 0.2,
"avgSolved": 0.16666666666666669,
"minSolved": 0,
"maxSolved": 3.3333333333333335,
"avgTime": 0.06999999999999887
},
{
"size": 30,
"density": 0.3,
"avgSolved": 0,
"minSolved": 0,
"maxSolved": 0,
"avgTime": 0.08285835000000005
},
{
"size": 30,
"density": 0.4,
"avgSolved": 0.3777777777777777,
"minSolved": 0,
"maxSolved": 4.111111111111112,
"avgTime": 0.1756041499999988
},
{
"size": 30,
"density": 0.5,
"avgSolved": 5.4222222222222225,
"minSolved": 0.7777777777777778,
"maxSolved": 21.444444444444443,
"avgTime": 0.41105620000000015
},
{
"size": 30,
"density": 0.6,
"avgSolved": 99.41666666666669,
"minSolved": 94.77777777777779,
"maxSolved": 100,
"avgTime": 0.9417500999999995
},
{
"size": 30,
"density": 0.7,
"avgSolved": 99.93333333333335,
"minSolved": 99.55555555555556,
"maxSolved": 100,
"avgTime": 0.41628955000000334
},
{
"size": 30,
"density": 0.8,
"avgSolved": 100,
"minSolved": 100,
"maxSolved": 100,
"avgTime": 0.22320620000000133
},
{
"size": 30,
"density": 0.9,
"avgSolved": 100,
"minSolved": 100,
"maxSolved": 100,
"avgTime": 0.13331460000000134
},
{
"size": 35,
"density": 0.1,
"avgSolved": 5.653061224489796,
"minSolved": 0,
"maxSolved": 13.795918367346937,
"avgTime": 0.11177699999999931
},
{
"size": 35,
"density": 0.2,
"avgSolved": 0.14285714285714285,
"minSolved": 0,
"maxSolved": 2.857142857142857,
"avgTime": 0.09598544999999917
},
{
"size": 35,
"density": 0.3,
"avgSolved": 0,
"minSolved": 0,
"maxSolved": 0,
"avgTime": 0.1290145000000038
},
{
"size": 35,
"density": 0.4,
"avgSolved": 0.1346938775510204,
"minSolved": 0,
"maxSolved": 0.5714285714285714,
"avgTime": 0.21904799999999797
},
{
"size": 35,
"density": 0.5,
"avgSolved": 4.424489795918367,
"minSolved": 0.40816326530612246,
"maxSolved": 23.183673469387756,
"avgTime": 0.5596769500000022
},
{
"size": 35,
"density": 0.6,
"avgSolved": 91.1061224489796,
"minSolved": 8.408163265306122,
"maxSolved": 100,
"avgTime": 1.5827311000000024
},
{
"size": 35,
"density": 0.7,
"avgSolved": 99.9673469387755,
"minSolved": 99.67346938775509,
"maxSolved": 100,
"avgTime": 0.5970167499999988
},
{
"size": 35,
"density": 0.8,
"avgSolved": 100,
"minSolved": 100,
"maxSolved": 100,
"avgTime": 0.33084175000000327
},
{
"size": 35,
"density": 0.9,
"avgSolved": 100,
"minSolved": 100,
"maxSolved": 100,
"avgTime": 0.1685022000000032
},
{
"size": 40,
"density": 0.1,
"avgSolved": 2.734375,
"minSolved": 0,
"maxSolved": 9.8125,
"avgTime": 0.13156869999999826
},
{
"size": 40,
"density": 0.2,
"avgSolved": 0,
"minSolved": 0,
"maxSolved": 0,
"avgTime": 0.13052910000000112
},
{
"size": 40,
"density": 0.3,
"avgSolved": 0,
"minSolved": 0,
"maxSolved": 0,
"avgTime": 0.17675199999999905
},
{
"size": 40,
"density": 0.4,
"avgSolved": 0.03125,
"minSolved": 0,
"maxSolved": 0.3125,
"avgTime": 0.26616039999999686
},
{
"size": 40,
"density": 0.5,
"avgSolved": 2.14375,
"minSolved": 0,
"maxSolved": 9.5625,
"avgTime": 0.694316649999999
},
{
"size": 40,
"density": 0.6,
"avgSolved": 91.44375,
"minSolved": 22.3125,
"maxSolved": 100,
"avgTime": 2.9244042000000006
},
{
"size": 40,
"density": 0.7,
"avgSolved": 99.9875,
"minSolved": 99.75,
"maxSolved": 100,
"avgTime": 0.8381519999999967
},
{
"size": 40,
"density": 0.8,
"avgSolved": 100,
"minSolved": 100,
"maxSolved": 100,
"avgTime": 0.4339062999999925
},
{
"size": 40,
"density": 0.9,
"avgSolved": 100,
"minSolved": 100,
"maxSolved": 100,
"avgTime": 0.2375938000000076
},
{
"size": 45,
"density": 0.1,
"avgSolved": 1.7827160493827159,
"minSolved": 0,
"maxSolved": 4.691358024691358,
"avgTime": 0.1660813500000046
},
{
"size": 45,
"density": 0.2,
"avgSolved": 0,
"minSolved": 0,
"maxSolved": 0,
"avgTime": 0.1715666999999968
},
{
"size": 45,
"density": 0.3,
"avgSolved": 0,
"minSolved": 0,
"maxSolved": 0,
"avgTime": 0.23760415000000706
},
{
"size": 45,
"density": 0.4,
"avgSolved": 0.012345679012345678,
"minSolved": 0,
"maxSolved": 0.14814814814814814,
"avgTime": 0.333931249999992
},
{
"size": 45,
"density": 0.5,
"avgSolved": 1.439506172839506,
"minSolved": 0.39506172839506176,
"maxSolved": 5.135802469135802,
"avgTime": 0.9644125499999916
},
{
"size": 45,
"density": 0.6,
"avgSolved": 81.71851851851852,
"minSolved": 6.0246913580246915,
"maxSolved": 100,
"avgTime": 5.281324949999998
},
{
"size": 45,
"density": 0.7,
"avgSolved": 99.94074074074075,
"minSolved": 99.4074074074074,
"maxSolved": 100,
"avgTime": 1.2768960000000107
},
{
"size": 45,
"density": 0.8,
"avgSolved": 100,
"minSolved": 100,
"maxSolved": 100,
"avgTime": 0.638566650000007
},
{
"size": 45,
"density": 0.9,
"avgSolved": 100,
"minSolved": 100,
"maxSolved": 100,
"avgTime": 0.3004915999999923
},
{
"size": 50,
"density": 0.1,
"avgSolved": 1.7,
"minSolved": 0,
"maxSolved": 5.92,
"avgTime": 0.20294785000000387
},
{
"size": 50,
"density": 0.2,
"avgSolved": 0,
"minSolved": 0,
"maxSolved": 0,
"avgTime": 0.23199789999999892
},
{
"size": 50,
"density": 0.3,
"avgSolved": 0,
"minSolved": 0,
"maxSolved": 0,
"avgTime": 0.29876259999999205
},
{
"size": 50,
"density": 0.4,
"avgSolved": 0.008,
"minSolved": 0,
"maxSolved": 0.16,
"avgTime": 0.38459799999998834
},
{
"size": 50,
"density": 0.5,
"avgSolved": 0.5099999999999999,
"minSolved": 0,
"maxSolved": 1.7999999999999998,
"avgTime": 0.8961771499999941
},
{
"size": 50,
"density": 0.6,
"avgSolved": 73.258,
"minSolved": 5.6000000000000005,
"maxSolved": 100,
"avgTime": 7.937735449999991
},
{
"size": 50,
"density": 0.7,
"avgSolved": 99.96399999999998,
"minSolved": 99.76,
"maxSolved": 100,
"avgTime": 1.6324250000000062
},
{
"size": 50,
"density": 0.8,
"avgSolved": 100,
"minSolved": 100,
"maxSolved": 100,
"avgTime": 0.8293270000000064
},
{
"size": 50,
"density": 0.9,
"avgSolved": 100,
"minSolved": 100,
"maxSolved": 100,
"avgTime": 0.41459575000000654
},
{
"size": 60,
"density": 0.1,
"avgSolved": 0.16666666666666669,
"minSolved": 0,
"maxSolved": 1.6666666666666667,
"avgTime": 0.2432124999999928
},
{
"size": 60,
"density": 0.2,
"avgSolved": 0,
"minSolved": 0,
"maxSolved": 0,
"avgTime": 0.35082704999999237
},
{
"size": 60,
"density": 0.3,
"avgSolved": 0,
"minSolved": 0,
"maxSolved": 0,
"avgTime": 0.49827310000000014
},
{
"size": 60,
"density": 0.4,
"avgSolved": 0.0027777777777777775,
"minSolved": 0,
"maxSolved": 0.05555555555555555,
"avgTime": 0.6393062499999985
},
{
"size": 60,
"density": 0.5,
"avgSolved": 0.23055555555555554,
"minSolved": 0,
"maxSolved": 1.6666666666666667,
"avgTime": 1.2402395500000012
},
{
"size": 60,
"density": 0.6,
"avgSolved": 35.01805555555556,
"minSolved": 1.3333333333333335,
"maxSolved": 100,
"avgTime": 10.759754149999992
},
{
"size": 60,
"density": 0.7,
"avgSolved": 99.96944444444445,
"minSolved": 99.83333333333333,
"maxSolved": 100,
"avgTime": 2.964204100000029
},
{
"size": 60,
"density": 0.8,
"avgSolved": 100,
"minSolved": 100,
"maxSolved": 100,
"avgTime": 1.2736664999999903
},
{
"size": 60,
"density": 0.9,
"avgSolved": 100,
"minSolved": 100,
"maxSolved": 100,
"avgTime": 0.6249353999999812
},
{
"size": 70,
"density": 0.1,
"avgSolved": 0.14285714285714285,
"minSolved": 0,
"maxSolved": 1.4285714285714286,
"avgTime": 0.34277719999998907
},
{
"size": 70,
"density": 0.2,
"avgSolved": 0,
"minSolved": 0,
"maxSolved": 0,
"avgTime": 0.5435105000000249
},
{
"size": 70,
"density": 0.3,
"avgSolved": 0,
"minSolved": 0,
"maxSolved": 0,
"avgTime": 0.7600602999999865
},
{
"size": 70,
"density": 0.4,
"avgSolved": 0,
"minSolved": 0,
"maxSolved": 0,
"avgTime": 0.9591250999999943
},
{
"size": 70,
"density": 0.5,
"avgSolved": 0.04081632653061225,
"minSolved": 0,
"maxSolved": 0.2857142857142857,
"avgTime": 1.491010399999982
},
{
"size": 70,
"density": 0.6,
"avgSolved": 16.403061224489797,
"minSolved": 1,
"maxSolved": 99.71428571428571,
"avgTime": 22.21432699999999
},
{
"size": 70,
"density": 0.7,
"avgSolved": 99.96836734693878,
"minSolved": 99.73469387755102,
"maxSolved": 100,
"avgTime": 4.92020829999999
},
{
"size": 70,
"density": 0.8,
"avgSolved": 99.99591836734695,
"minSolved": 99.91836734693878,
"maxSolved": 100,
"avgTime": 2.0306394499999554
},
{
"size": 70,
"density": 0.9,
"avgSolved": 100,
"minSolved": 100,
"maxSolved": 100,
"avgTime": 0.8882499500000336
},
{
"size": 80,
"density": 0.1,
"avgSolved": 0,
"minSolved": 0,
"maxSolved": 0,
"avgTime": 0.4418666499999858
},
{
"size": 80,
"density": 0.2,
"avgSolved": 0,
"minSolved": 0,
"maxSolved": 0,
"avgTime": 0.7795667999999978
},
{
"size": 80,
"density": 0.3,
"avgSolved": 0,
"minSolved": 0,
"maxSolved": 0,
"avgTime": 1.0745101999999747
},
{
"size": 80,
"density": 0.4,
"avgSolved": 0,
"minSolved": 0,
"maxSolved": 0,
"avgTime": 1.3407041500000105
},
{
"size": 80,
"density": 0.5,
"avgSolved": 0.0125,
"minSolved": 0,
"maxSolved": 0.078125,
"avgTime": 1.9724897000000283
},
{
"size": 80,
"density": 0.6,
"avgSolved": 1.21484375,
"minSolved": 0.40625,
"maxSolved": 2.296875,
"avgTime": 3.9163123999999927
},
{
"size": 80,
"density": 0.7,
"avgSolved": 99.978125,
"minSolved": 99.9375,
"maxSolved": 100,
"avgTime": 7.790070799999967
},
{
"size": 80,
"density": 0.8,
"avgSolved": 100,
"minSolved": 100,
"maxSolved": 100,
"avgTime": 3.1350061999999754
},
{
"size": 80,
"density": 0.9,
"avgSolved": 100,
"minSolved": 100,
"maxSolved": 100,
"avgTime": 1.3134414999999535
}
]

View File

@@ -10,5 +10,5 @@ services:
- "8081:80" - "8081:80"
restart: unless-stopped restart: unless-stopped
# Uncomment the following lines if you want to mount the configuration locally for development/testing # Uncomment the following lines if you want to mount the configuration locally for development/testing
# volumes: volumes:
# - ./nginx.conf:/etc/nginx/conf.d/default.conf:ro - ./nginx.conf:/etc/nginx/conf.d/default.conf:ro

6978
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,19 +1,26 @@
{ {
"name": "vue-nonograms-solid", "name": "vue-nonograms-solid",
"version": "1.0.0", "version": "1.9.0",
"type": "module", "type": "module",
"scripts": { "scripts": {
"dev": "vite", "dev": "vite",
"build": "vite build", "build": "vite build",
"preview": "vite preview" "preview": "vite preview",
"test": "vitest"
}, },
"dependencies": { "dependencies": {
"fireworks-js": "^2.10.8", "fireworks-js": "^2.10.8",
"flag-icons": "^7.5.0",
"lucide-vue-next": "^0.563.0",
"pinia": "^2.1.7", "pinia": "^2.1.7",
"vue": "^3.4.19" "vue": "^3.4.19"
}, },
"devDependencies": { "devDependencies": {
"@vitejs/plugin-vue": "^5.0.4", "@vitejs/plugin-vue": "^5.0.4",
"vite": "^5.1.4" "@vue/test-utils": "^2.4.6",
"jsdom": "^28.0.0",
"vite": "^5.1.4",
"vite-plugin-pwa": "^0.20.5",
"vitest": "^4.0.18"
} }
} }

24
public/pwa-192x192.svg Normal file
View File

@@ -0,0 +1,24 @@
<svg xmlns="http://www.w3.org/2000/svg" width="192" height="192" viewBox="0 0 192 192">
<defs>
<linearGradient id="bg" x1="0" y1="0" x2="1" y2="1">
<stop offset="0" stop-color="#43C6AC"/>
<stop offset="1" stop-color="#191654"/>
</linearGradient>
<linearGradient id="cell" x1="0" y1="0" x2="1" y2="1">
<stop offset="0" stop-color="#00f2fe"/>
<stop offset="1" stop-color="#4facfe"/>
</linearGradient>
</defs>
<rect width="192" height="192" rx="28" fill="url(#bg)"/>
<rect x="28" y="28" width="136" height="136" rx="14" fill="rgba(0,0,0,0.35)"/>
<g fill="url(#cell)">
<rect x="48" y="48" width="20" height="20" rx="4"/>
<rect x="76" y="48" width="20" height="20" rx="4"/>
<rect x="104" y="48" width="20" height="20" rx="4"/>
<rect x="48" y="76" width="20" height="20" rx="4"/>
<rect x="104" y="76" width="20" height="20" rx="4"/>
<rect x="48" y="104" width="20" height="20" rx="4"/>
<rect x="76" y="104" width="20" height="20" rx="4"/>
<rect x="104" y="104" width="20" height="20" rx="4"/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 1.1 KiB

24
public/pwa-512x512.svg Normal file
View File

@@ -0,0 +1,24 @@
<svg xmlns="http://www.w3.org/2000/svg" width="512" height="512" viewBox="0 0 512 512">
<defs>
<linearGradient id="bg" x1="0" y1="0" x2="1" y2="1">
<stop offset="0" stop-color="#43C6AC"/>
<stop offset="1" stop-color="#191654"/>
</linearGradient>
<linearGradient id="cell" x1="0" y1="0" x2="1" y2="1">
<stop offset="0" stop-color="#00f2fe"/>
<stop offset="1" stop-color="#4facfe"/>
</linearGradient>
</defs>
<rect width="512" height="512" rx="80" fill="url(#bg)"/>
<rect x="74" y="74" width="364" height="364" rx="40" fill="rgba(0,0,0,0.35)"/>
<g fill="url(#cell)">
<rect x="138" y="138" width="54" height="54" rx="10"/>
<rect x="214" y="138" width="54" height="54" rx="10"/>
<rect x="290" y="138" width="54" height="54" rx="10"/>
<rect x="138" y="214" width="54" height="54" rx="10"/>
<rect x="290" y="214" width="54" height="54" rx="10"/>
<rect x="138" y="290" width="54" height="54" rx="10"/>
<rect x="214" y="290" width="54" height="54" rx="10"/>
<rect x="290" y="290" width="54" height="54" rx="10"/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

@@ -0,0 +1,61 @@
const fs = require('fs');
const path = require('path');
const filePath = path.join(__dirname, '../src/composables/useI18n.js');
let content = fs.readFileSync(filePath, 'utf8');
const newKeys = {
'custom.simulationHelp': 'How is this calculated?',
'custom.hideMap': 'Hide difficulty map',
'custom.showMap': 'Show difficulty map',
'simulation.title': 'Difficulty Simulation',
'simulation.status.ready': 'Ready',
'simulation.status.stopped': 'Stopped',
'simulation.status.completed': 'Completed',
'simulation.status.simulating': 'Simulating {size}x{size} @ {density}%',
'simulation.start': 'Start Simulation',
'simulation.stop': 'Stop',
'simulation.table.size': 'Size',
'simulation.table.density': 'Density',
'simulation.table.solved': 'Solved (Logic)',
'simulation.empty': 'Press Start to run Monte Carlo simulation'
};
const lines = content.split('\n');
const processedLines = [];
let currentLang = null;
for (let i = 0; i < lines.length; i++) {
let line = lines[i];
// Detect start of language block
const startMatch = line.match(/^\s{2}(['"]?[\w-]+['"]?): \{/);
if (startMatch) {
currentLang = startMatch[1].replace(/['"]/g, '');
}
// Detect end of language block
if (currentLang && (line.trim() === '},' || line.trim() === '}')) {
if (currentLang !== 'pl' && currentLang !== 'en') {
// Ensure previous line has comma
if (processedLines.length > 0) {
let lastLine = processedLines[processedLines.length - 1];
if (!lastLine.trim().endsWith(',') && !lastLine.trim().endsWith('{')) {
processedLines[processedLines.length - 1] = lastLine + ',';
}
}
// Append new keys
Object.entries(newKeys).forEach(([key, value]) => {
processedLines.push(` '${key}': '${value}',`);
});
}
currentLang = null;
}
processedLines.push(line);
}
const finalContent = processedLines.join('\n');
fs.writeFileSync(filePath, finalContent);
console.log('Successfully added simulation translations to all languages.');

View File

@@ -0,0 +1,97 @@
const fs = require('fs');
const path = require('path');
const filePath = path.join(__dirname, '../src/composables/useI18n.js');
let content = fs.readFileSync(filePath, 'utf8');
const newKeys = {
'custom.simulationHelp': 'How is this calculated?',
'simulation.title': 'Difficulty Simulation',
'simulation.status.ready': 'Ready',
'simulation.status.stopped': 'Stopped',
'simulation.status.completed': 'Completed',
'simulation.status.simulating': 'Simulating {size}x{size} @ {density}%',
'simulation.start': 'Start Simulation',
'simulation.stop': 'Stop',
'simulation.table.size': 'Size',
'simulation.table.density': 'Density',
'simulation.table.solved': 'Solved (Logic)',
'simulation.empty': 'Press Start to run Monte Carlo simulation'
};
// Regex to match the end of a language block
// Matches " }," or " }" at the start of a line
const blockEndRegex = /^(\s{2})\},?$/gm;
let newContent = content.replace(blockEndRegex, (match, indent, offset) => {
// Determine which language we are closing
const precedingText = content.substring(0, offset);
const langMatch = precedingText.match(/^\s{2}(\w+([-]\w+)?): \{/gm);
if (!langMatch) return match;
const currentLangLine = langMatch[langMatch.length - 1];
const currentLang = currentLangLine.match(/^\s{2}(\w+([-]\w+)?): \{/)[1];
// Skip pl and en as they are already updated
if (currentLang === 'pl' || currentLang === 'en') {
return match;
}
// Check if the previous line has a comma
// We need to look at the lines before the match
// This is tricky with replace callback.
// Easier strategy: Just insert the keys.
// If the file is well formatted, the last item might or might not have a comma.
// But we can ensure *our* inserted block starts with a comma if needed?
// No, standard JS objects need comma after previous item.
// Let's assume we simply inject before the closing brace.
// We'll add a comma to the previous line if it doesn't have one?
// That's hard with regex replace on the closing brace only.
// Alternative: Split by lines and process.
return match; // Placeholder, we will process by lines below.
});
const lines = content.split('\n');
const processedLines = [];
let currentLang = null;
for (let i = 0; i < lines.length; i++) {
let line = lines[i];
// Detect start of language block
const startMatch = line.match(/^\s{2}(['"]?[\w-]+['"]?): \{/);
if (startMatch) {
currentLang = startMatch[1].replace(/['"]/g, '');
}
// Detect end of language block
if (currentLang && (line.trim() === '},' || line.trim() === '}')) {
if (currentLang !== 'pl' && currentLang !== 'en') {
// Ensure previous line has comma
if (processedLines.length > 0) {
let lastLine = processedLines[processedLines.length - 1];
if (!lastLine.trim().endsWith(',') && !lastLine.trim().endsWith('{')) {
processedLines[processedLines.length - 1] = lastLine + ',';
}
}
// Append new keys
Object.entries(newKeys).forEach(([key, value]) => {
processedLines.push(` '${key}': '${value}',`);
});
// Remove trailing comma from last inserted item if we want strictly JSON-like (but JS allows it)
// It's fine to leave it.
}
currentLang = null;
}
processedLines.push(line);
}
const finalContent = processedLines.join('\n');
fs.writeFileSync(filePath, finalContent);
console.log('Successfully added simulation translations to all languages.');

View File

@@ -0,0 +1,75 @@
import fs from 'fs';
import path from 'path';
import { generateRandomGrid, calculateHints } from '../src/utils/puzzleUtils.js';
import { solvePuzzle } from '../src/utils/solver.js';
const OUTPUT_FILE = 'difficulty_simulation_results.json';
const CSV_FILE = 'difficulty_simulation_results.csv';
// Configuration
const SIZES = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 60, 70, 80]; // Steps of 5 up to 50, then 10
const DENSITIES = [0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9];
const SAMPLES_PER_POINT = 20; // Adjust based on time/accuracy needs
console.log('Starting Monte Carlo Simulation for Nonogram Difficulty...');
console.log(`Config: Sizes=${SIZES.length}, Densities=${DENSITIES.length}, Samples=${SAMPLES_PER_POINT}`);
const results = [];
const csvRows = ['size,density,avg_solved_percent,min_solved_percent,max_solved_percent,avg_time_ms'];
const startTime = Date.now();
for (const size of SIZES) {
for (const density of DENSITIES) {
let totalSolved = 0;
let minSolved = 100;
let maxSolved = 0;
let totalTime = 0;
process.stdout.write(`Simulating Size: ${size}x${size}, Density: ${density} ... `);
for (let i = 0; i < SAMPLES_PER_POINT; i++) {
const t0 = performance.now();
// 1. Generate
const grid = generateRandomGrid(size, density);
const { rowHints, colHints } = calculateHints(grid);
// 2. Solve
const { percentSolved } = solvePuzzle(rowHints, colHints);
const t1 = performance.now();
totalSolved += percentSolved;
minSolved = Math.min(minSolved, percentSolved);
maxSolved = Math.max(maxSolved, percentSolved);
totalTime += (t1 - t0);
}
const avgSolved = totalSolved / SAMPLES_PER_POINT;
const avgTime = totalTime / SAMPLES_PER_POINT;
results.push({
size,
density,
avgSolved,
minSolved,
maxSolved,
avgTime
});
csvRows.push(`${size},${density},${avgSolved.toFixed(2)},${minSolved.toFixed(2)},${maxSolved.toFixed(2)},${avgTime.toFixed(2)}`);
console.log(`Avg Solved: ${avgSolved.toFixed(1)}%`);
}
}
const totalDuration = (Date.now() - startTime) / 1000;
console.log(`Simulation complete in ${totalDuration.toFixed(1)}s`);
// Save results
fs.writeFileSync(OUTPUT_FILE, JSON.stringify(results, null, 2));
fs.writeFileSync(CSV_FILE, csvRows.join('\n'));
console.log(`Results saved to ${OUTPUT_FILE} and ${CSV_FILE}`);

View File

@@ -1,43 +1,159 @@
<script setup> <script setup>
import { onMounted, ref } from 'vue'; import { computed, onMounted, onUnmounted, ref } from 'vue';
import { usePuzzleStore } from './stores/puzzle'; import { usePuzzleStore } from './stores/puzzle';
import { useI18n } from './composables/useI18n';
import GameBoard from './components/GameBoard.vue'; import GameBoard from './components/GameBoard.vue';
import LevelSelector from './components/LevelSelector.vue'; import NavBar from './components/NavBar.vue';
import StatusPanel from './components/StatusPanel.vue'; import StatusPanel from './components/StatusPanel.vue';
import GameActions from './components/GameActions.vue';
import GuidePanel from './components/GuidePanel.vue'; import GuidePanel from './components/GuidePanel.vue';
import WinModal from './components/WinModal.vue'; import WinModal from './components/WinModal.vue';
import CustomGameModal from './components/CustomGameModal.vue'; import CustomGameModal from './components/CustomGameModal.vue';
import SimulationView from './components/SimulationView.vue';
import FixedBar from './components/FixedBar.vue'; import FixedBar from './components/FixedBar.vue';
import ReloadPrompt from './components/ReloadPrompt.vue';
// Main App Entry // Main App Entry
const store = usePuzzleStore(); const store = usePuzzleStore();
const { t, locale, setLocale, locales } = useI18n();
const showCustomModal = ref(false); const showCustomModal = ref(false);
const showSimulation = ref(false);
const showGuide = ref(false); const showGuide = ref(false);
const deferredPrompt = ref(null);
const canInstall = ref(false);
const installDismissed = ref(false);
const isCoarsePointer = ref(false);
const isStandalone = ref(false);
const themePreference = ref('system');
const appVersion = __APP_VERSION__;
let displayModeMedia = null;
let prefersColorSchemeMedia = null;
const installLabel = computed(() => {
return isCoarsePointer.value ? t('pwa.installMobile') : t('pwa.installDesktop');
});
const updateStandalone = () => {
isStandalone.value = window.matchMedia('(display-mode: standalone)').matches || window.navigator.standalone === true;
if (isStandalone.value) {
canInstall.value = false;
installDismissed.value = true;
}
};
const handleBeforeInstallPrompt = (e) => {
e.preventDefault();
deferredPrompt.value = e;
if (!isStandalone.value) {
canInstall.value = true;
}
};
const handleAppInstalled = () => {
deferredPrompt.value = null;
canInstall.value = false;
installDismissed.value = true;
};
const handleInstall = async () => {
if (!deferredPrompt.value) return;
deferredPrompt.value.prompt();
const choice = await deferredPrompt.value.userChoice;
deferredPrompt.value = null;
canInstall.value = false;
if (!choice || choice.outcome !== 'accepted') {
installDismissed.value = true;
}
};
const resolveSystemTheme = () => {
return window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light';
};
const applyTheme = () => {
const nextTheme = themePreference.value === 'system' ? resolveSystemTheme() : themePreference.value;
document.documentElement.dataset.theme = nextTheme;
};
const setThemePreference = (value) => {
themePreference.value = value;
if (typeof localStorage !== 'undefined') {
localStorage.setItem('theme', value);
}
applyTheme();
};
const handleSystemThemeChange = () => {
if (themePreference.value === 'system') {
applyTheme();
}
};
onMounted(() => { onMounted(() => {
if (!store.loadState()) { if (!store.loadState()) {
store.initGame(); // Inicjalizacja domyślnej gry jeśli brak zapisu store.initGame(); // Inicjalizacja domyślnej gry jeśli brak zapisu
} }
if (typeof window !== 'undefined') {
isCoarsePointer.value = window.matchMedia('(pointer: coarse)').matches;
const storedTheme = typeof localStorage !== 'undefined' ? localStorage.getItem('theme') : null;
if (storedTheme === 'light' || storedTheme === 'dark' || storedTheme === 'system') {
themePreference.value = storedTheme;
}
applyTheme();
prefersColorSchemeMedia = window.matchMedia('(prefers-color-scheme: dark)');
if (prefersColorSchemeMedia?.addEventListener) {
prefersColorSchemeMedia.addEventListener('change', handleSystemThemeChange);
} else if (prefersColorSchemeMedia?.addListener) {
prefersColorSchemeMedia.addListener(handleSystemThemeChange);
}
updateStandalone();
window.addEventListener('beforeinstallprompt', handleBeforeInstallPrompt);
window.addEventListener('appinstalled', handleAppInstalled);
displayModeMedia = window.matchMedia('(display-mode: standalone)');
if (displayModeMedia?.addEventListener) {
displayModeMedia.addEventListener('change', updateStandalone);
} else if (displayModeMedia?.addListener) {
displayModeMedia.addListener(updateStandalone);
}
}
});
onUnmounted(() => {
if (typeof window === 'undefined') return;
window.removeEventListener('beforeinstallprompt', handleBeforeInstallPrompt);
window.removeEventListener('appinstalled', handleAppInstalled);
if (prefersColorSchemeMedia?.removeEventListener) {
prefersColorSchemeMedia.removeEventListener('change', handleSystemThemeChange);
} else if (prefersColorSchemeMedia?.removeListener) {
prefersColorSchemeMedia.removeListener(handleSystemThemeChange);
}
if (displayModeMedia?.removeEventListener) {
displayModeMedia.removeEventListener('change', updateStandalone);
} else if (displayModeMedia?.removeListener) {
displayModeMedia.removeListener(updateStandalone);
}
}); });
</script> </script>
<template> <template>
<main class="game-container"> <main class="game-container">
<FixedBar /> <NavBar
<header class="game-header">
<h1>NONOGRAMS</h1>
<div class="underline"></div>
</header>
<div class="game-layout">
<!-- Level Selection -->
<LevelSelector
@open-custom="showCustomModal = true" @open-custom="showCustomModal = true"
@toggle-guide="showGuide = !showGuide" @toggle-guide="showGuide = !showGuide"
@set-theme="setThemePreference"
/> />
<FixedBar />
<div v-if="canInstall && !installDismissed" class="install-banner">
<div class="install-text">{{ t('pwa.installTitle') }}</div>
<div class="install-actions">
<button class="btn-neon secondary install-btn" @click="handleInstall">
{{ installLabel }}
</button>
<button class="install-close" @click="installDismissed = true">×</button>
</div>
</div>
<div class="game-layout">
<!-- Guide Panel (Conditional) --> <!-- Guide Panel (Conditional) -->
<transition name="fade"> <transition name="fade">
<GuidePanel v-if="showGuide" /> <GuidePanel v-if="showGuide" />
@@ -46,19 +162,22 @@ onMounted(() => {
<!-- Status Panel (Time, Moves, Progress) --> <!-- Status Panel (Time, Moves, Progress) -->
<StatusPanel /> <StatusPanel />
<!-- Game Actions (Reset, Random, Undo, Check) -->
<GameActions />
<!-- Game Board --> <!-- Game Board -->
<section class="board-section"> <section class="board-section">
<GameBoard /> <GameBoard />
</section> </section>
</div> </div>
<footer class="app-version">
v{{ appVersion }}
</footer>
<!-- Modals Teleport --> <!-- Modals Teleport -->
<Teleport to="body"> <Teleport to="body">
<WinModal v-if="store.isGameWon" /> <WinModal v-if="store.isGameWon" />
<CustomGameModal v-if="showCustomModal" @close="showCustomModal = false" /> <CustomGameModal v-if="showCustomModal" @close="showCustomModal = false" @open-simulation="showSimulation = true" />
<SimulationView v-if="showSimulation" @close="showSimulation = false" />
<ReloadPrompt />
</Teleport> </Teleport>
</main> </main>
</template> </template>
@@ -73,60 +192,77 @@ onMounted(() => {
padding-bottom: 50px; padding-bottom: 50px;
} }
.game-header { .install-banner {
text-align: center; background: var(--banner-bg);
margin-bottom: 30px; border: 1px solid var(--banner-border);
margin-top: 40px; border-radius: 8px;
padding: 10px 20px;
display: flex;
justify-content: space-between;
align-items: center;
width: 90%;
max-width: 600px;
margin-bottom: 20px;
box-shadow: var(--banner-shadow);
} }
h1 { .install-text {
font-size: 3.5rem; color: var(--text-color);
margin: 0;
letter-spacing: 5px;
font-weight: 300;
color: #fff;
text-shadow: 0 0 20px rgba(0, 255, 255, 0.2);
} }
.underline { .install-actions {
width: 100px; display: flex;
height: 3px; gap: 10px;
background: var(--primary-accent); align-items: center;
margin: 10px auto 0; }
box-shadow: 0 0 10px var(--primary-accent);
.install-close {
background: transparent;
border: none;
color: var(--text-muted);
font-size: 1.5rem;
cursor: pointer;
} }
.game-layout { .game-layout {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
gap: 10px;
width: 100%;
max-width: 900px;
align-items: center; align-items: center;
gap: 20px;
width: 100%;
max-width: 1200px;
padding: 0 20px;
} }
/* Remove old glass panel style from game-layout since we split it */
.board-section { .board-section {
display: flex; display: flex;
justify-content: center; justify-content: center;
margin-top: 10px; width: 100%;
} }
@media (max-width: 768px) { .fade-enter-active,
.game-header { .fade-leave-active {
margin-top: 20px; transition: opacity 0.3s ease;
margin-bottom: 20px;
}
h1 {
font-size: 2.4rem;
letter-spacing: 3px;
}
} }
@media (max-width: 420px) { .fade-enter-from,
h1 { .fade-leave-to {
font-size: 2rem; opacity: 0;
letter-spacing: 2px; }
}
.app-version {
position: fixed;
bottom: 0;
left: 0;
width: 100%;
text-align: center;
padding: 10px;
font-size: 0.8rem;
color: var(--text-muted);
opacity: 0.8;
background: var(--panel-bg);
backdrop-filter: blur(5px);
border-top: 1px solid var(--panel-border);
z-index: 90;
} }
</style> </style>

View File

@@ -0,0 +1,3 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="#ffffff">
<path d="M13.5 9.2V7.1c0-1 .7-1.2 1.2-1.2h2V2.4h-2.9c-3.2 0-4 2.4-4 3.9v2.9H7.7V13h2.1v8.6h3.7V13h2.8l.4-3.8h-3.2Z"/>
</svg>

After

Width:  |  Height:  |  Size: 203 B

View File

@@ -0,0 +1,3 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="#ffffff">
<path d="M20.5 3.5A11 11 0 0 0 2.7 17.7L2 22l4.4-1.2a11 11 0 0 0 5.6 1.4h.1a11 11 0 0 0 7.8-18.7Zm-8.4 16.7h-.1a9 9 0 0 1-4.6-1.3l-.3-.2-2.7.8.7-2.6-.2-.3a9 9 0 1 1 7.2 3.6Zm5-6.7c-.3-.1-1.8-.9-2.1-1s-.5-.1-.7.2-.8 1-1 1.2-.4.2-.7.1a7.2 7.2 0 0 1-2.1-1.3 8 8 0 0 1-1.5-1.9c-.2-.3 0-.5.1-.7l.5-.6c.1-.1.2-.3.3-.5s0-.3 0-.5c-.1-.1-.7-1.7-1-2.3-.3-.7-.6-.6-.7-.6h-.6c-.2 0-.5.1-.7.3s-1 1-1 2.4 1 2.7 1.1 2.9c.1.2 2 3 5 4.2.7.3 1.3.5 1.7.6.7.2 1.4.2 1.9.1.6-.1 1.8-.7 2-1.4.2-.7.2-1.3.1-1.4s-.3-.2-.6-.3Z"/>
</svg>

After

Width:  |  Height:  |  Size: 589 B

3
src/assets/brands/x.svg Normal file
View File

@@ -0,0 +1,3 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="#ffffff">
<path d="M18.9 3H22l-7.2 8.2L23 21h-6.6l-5.2-6.2L5.7 21H2.6l7.7-8.7L1 3h6.8l4.7 5.6L18.9 3Zm-1.2 15.9h1.8L6.4 5.1H4.4l13.3 13.8Z"/>
</svg>

After

Width:  |  Height:  |  Size: 217 B

1
src/assets/flags/af.svg Normal file
View File

@@ -0,0 +1 @@
<svg viewBox="0 0 24 16" xmlns="http://www.w3.org/2000/svg"><rect width="24" height="16" fill="#007749"/><path d="M0 0l12 8L0 16z" fill="#000"/><path d="M0 0l12 8L0 16z" fill="none" stroke="#fff" stroke-width="2"/><path d="M24 0l-12 8 12 8z" fill="#007749"/><rect y="0" width="24" height="5.33" fill="#e03c31"/><rect y="10.67" width="24" height="5.33" fill="#001489"/><path d="M0 5.33h24v5.33H0z" fill="#fff"/><path d="M0 0l12 8L0 16z" fill="#000"/><path d="M0 6.5l10 1.5L0 9.5z" fill="#fc0"/><path d="M12 8L24 0v16z" fill="#007749"/><path d="M12 8L24 0h-6L12 8z" fill="#e03c31"/><path d="M12 8L24 16h-6L12 8z" fill="#001489"/><path d="M0 0l12 8L0 16" stroke="#fff" stroke-width="2" fill="none"/><path d="M12 8H24" stroke="#fff" stroke-width="2" fill="none"/></svg>

After

Width:  |  Height:  |  Size: 765 B

5
src/assets/flags/am.svg Normal file
View File

@@ -0,0 +1,5 @@
<svg viewBox="0 0 24 16" xmlns="http://www.w3.org/2000/svg">
<rect width="24" height="5.33" fill="#ed1c24"/>
<rect y="5.33" width="24" height="5.33" fill="#fecd00"/>
<rect y="10.67" width="24" height="5.33" fill="#008000"/>
</svg>

After

Width:  |  Height:  |  Size: 237 B

5
src/assets/flags/az.svg Normal file
View File

@@ -0,0 +1,5 @@
<svg viewBox="0 0 24 16" xmlns="http://www.w3.org/2000/svg">
<rect width="24" height="5.33" fill="#00b5e2"/>
<rect y="5.33" width="24" height="5.33" fill="#ef3340"/>
<rect y="10.67" width="24" height="5.33" fill="#509e2f"/>
</svg>

After

Width:  |  Height:  |  Size: 237 B

1
src/assets/flags/bo.svg Normal file
View File

@@ -0,0 +1 @@
<svg viewBox="0 0 24 16" xmlns="http://www.w3.org/2000/svg"><rect width="24" height="16" fill="#be0000"/><path d="M0 16L12 4 24 16" fill="#003893"/><circle cx="12" cy="10" r="3" fill="#fcd116"/></svg>

After

Width:  |  Height:  |  Size: 200 B

1
src/assets/flags/ceb.svg Normal file
View File

@@ -0,0 +1 @@
<svg viewBox="0 0 24 16" xmlns="http://www.w3.org/2000/svg"><rect width="24" height="8" fill="#0038a8"/><rect y="8" width="24" height="8" fill="#ce1126"/><path d="M0 0l11 8L0 16z" fill="#fff"/><circle cx="4" cy="8" r="1.5" fill="#fcd116"/></svg>

After

Width:  |  Height:  |  Size: 245 B

1
src/assets/flags/ckb.svg Normal file
View File

@@ -0,0 +1 @@
<svg viewBox="0 0 24 16" xmlns="http://www.w3.org/2000/svg"><rect width="24" height="5.33" fill="#ed1c24"/><rect y="5.33" width="24" height="5.33" fill="#fff"/><rect y="10.67" width="24" height="5.33" fill="#218a42"/><circle cx="12" cy="8" r="2.5" fill="#ffc61e"/></svg>

After

Width:  |  Height:  |  Size: 270 B

5
src/assets/flags/fa.svg Normal file
View File

@@ -0,0 +1,5 @@
<svg viewBox="0 0 24 16" xmlns="http://www.w3.org/2000/svg">
<rect width="24" height="5.33" fill="#239f40"/>
<rect y="5.33" width="24" height="5.33" fill="#ffffff"/>
<rect y="10.67" width="24" height="5.33" fill="#da0000"/>
</svg>

After

Width:  |  Height:  |  Size: 237 B

View File

@@ -0,0 +1,5 @@
<svg viewBox="0 0 24 16" xmlns="http://www.w3.org/2000/svg">
<rect width="24" height="16" fill="#1e90ff"/>
<circle cx="12" cy="8" r="5" fill="#ffffff"/>
<path d="M12 3 v10 M7 8 h10" stroke="#1e90ff" stroke-width="1"/>
</svg>

After

Width:  |  Height:  |  Size: 231 B

1
src/assets/flags/gu.svg Normal file
View File

@@ -0,0 +1 @@
<svg viewBox="0 0 24 16" xmlns="http://www.w3.org/2000/svg"><rect width="24" height="5.33" fill="#ff9933"/><rect y="5.33" width="24" height="5.33" fill="#fff"/><rect y="10.67" width="24" height="5.33" fill="#138808"/><circle cx="12" cy="8" r="2" fill="#000080"/></svg>

After

Width:  |  Height:  |  Size: 268 B

6
src/assets/flags/he.svg Normal file
View File

@@ -0,0 +1,6 @@
<svg viewBox="0 0 24 16" xmlns="http://www.w3.org/2000/svg">
<rect width="24" height="16" fill="#ffffff"/>
<rect y="2" width="24" height="2" fill="#0038b8"/>
<rect y="12" width="24" height="2" fill="#0038b8"/>
<polygon points="12,5 10,9 14,9" fill="#0038b8"/>
</svg>

After

Width:  |  Height:  |  Size: 275 B

1
src/assets/flags/ht.svg Normal file
View File

@@ -0,0 +1 @@
<svg viewBox="0 0 24 16" xmlns="http://www.w3.org/2000/svg"><rect width="24" height="8" fill="#d21034"/><rect y="8" width="24" height="8" fill="#00209f"/><rect x="8" y="4" width="8" height="8" fill="#fff"/></svg>

After

Width:  |  Height:  |  Size: 212 B

5
src/assets/flags/hy.svg Normal file
View File

@@ -0,0 +1,5 @@
<svg viewBox="0 0 24 16" xmlns="http://www.w3.org/2000/svg">
<rect width="24" height="5.33" fill="#d90012"/>
<rect y="5.33" width="24" height="5.33" fill="#0033a0"/>
<rect y="10.67" width="24" height="5.33" fill="#f2a800"/>
</svg>

After

Width:  |  Height:  |  Size: 237 B

4
src/assets/flags/id.svg Normal file
View File

@@ -0,0 +1,4 @@
<svg viewBox="0 0 24 16" xmlns="http://www.w3.org/2000/svg">
<rect width="24" height="8" fill="#ff0000"/>
<rect y="8" width="24" height="8" fill="#ffffff"/>
</svg>

After

Width:  |  Height:  |  Size: 168 B

1
src/assets/flags/ig.svg Normal file
View File

@@ -0,0 +1 @@
<svg viewBox="0 0 24 16" xmlns="http://www.w3.org/2000/svg"><rect width="8" height="16" fill="#008751"/><rect x="8" width="8" height="16" fill="#fff"/><rect x="16" width="8" height="16" fill="#008751"/></svg>

After

Width:  |  Height:  |  Size: 208 B

1
src/assets/flags/ilo.svg Normal file
View File

@@ -0,0 +1 @@
<svg viewBox="0 0 24 16" xmlns="http://www.w3.org/2000/svg"><rect width="24" height="8" fill="#0038a8"/><rect y="8" width="24" height="8" fill="#ce1126"/><path d="M0 0l11 8L0 16z" fill="#fff"/><circle cx="4" cy="8" r="1.5" fill="#fcd116"/></svg>

After

Width:  |  Height:  |  Size: 245 B

4
src/assets/flags/ja.svg Normal file
View File

@@ -0,0 +1,4 @@
<svg viewBox="0 0 24 16" xmlns="http://www.w3.org/2000/svg">
<rect width="24" height="16" fill="#ffffff"/>
<circle cx="12" cy="8" r="4" fill="#bc002d"/>
</svg>

After

Width:  |  Height:  |  Size: 164 B

1
src/assets/flags/jv.svg Normal file
View File

@@ -0,0 +1 @@
<svg viewBox="0 0 24 16" xmlns="http://www.w3.org/2000/svg"><rect width="24" height="8" fill="#ff0000"/><rect y="8" width="24" height="8" fill="#fff"/></svg>

After

Width:  |  Height:  |  Size: 157 B

1
src/assets/flags/kk.svg Normal file
View File

@@ -0,0 +1 @@
<svg viewBox="0 0 24 16" xmlns="http://www.w3.org/2000/svg"><rect width="24" height="16" fill="#00afca"/><circle cx="12" cy="8" r="4" fill="#fec500"/><path d="M0 0v16l4-8z" fill="#fec500"/></svg>

After

Width:  |  Height:  |  Size: 195 B

1
src/assets/flags/km.svg Normal file
View File

@@ -0,0 +1 @@
<svg viewBox="0 0 24 16" xmlns="http://www.w3.org/2000/svg"><rect width="24" height="4" fill="#032ea1"/><rect y="4" width="24" height="8" fill="#e00025"/><rect y="12" width="24" height="4" fill="#032ea1"/><path d="M12 5l-2 5h4z" fill="#fff"/></svg>

After

Width:  |  Height:  |  Size: 248 B

1
src/assets/flags/kn.svg Normal file
View File

@@ -0,0 +1 @@
<svg viewBox="0 0 24 16" xmlns="http://www.w3.org/2000/svg"><rect width="24" height="5.33" fill="#ff9933"/><rect y="5.33" width="24" height="5.33" fill="#fff"/><rect y="10.67" width="24" height="5.33" fill="#138808"/><circle cx="12" cy="8" r="2" fill="#000080"/></svg>

After

Width:  |  Height:  |  Size: 268 B

5
src/assets/flags/ko.svg Normal file
View File

@@ -0,0 +1,5 @@
<svg viewBox="0 0 24 16" xmlns="http://www.w3.org/2000/svg">
<rect width="24" height="16" fill="#ffffff"/>
<circle cx="12" cy="8" r="3.5" fill="#003478"/>
<circle cx="12" cy="8" r="2.2" fill="#c60c30"/>
</svg>

After

Width:  |  Height:  |  Size: 216 B

1
src/assets/flags/ku.svg Normal file
View File

@@ -0,0 +1 @@
<svg viewBox="0 0 24 16" xmlns="http://www.w3.org/2000/svg"><rect width="24" height="5.33" fill="#ed1c24"/><rect y="5.33" width="24" height="5.33" fill="#fff"/><rect y="10.67" width="24" height="5.33" fill="#218a42"/><circle cx="12" cy="8" r="2.5" fill="#ffc61e"/></svg>

After

Width:  |  Height:  |  Size: 270 B

1
src/assets/flags/ky.svg Normal file
View File

@@ -0,0 +1 @@
<svg viewBox="0 0 24 16" xmlns="http://www.w3.org/2000/svg"><rect width="24" height="16" fill="#e61809"/><rect y="3" width="24" height="10" fill="#ffc61e"/><circle cx="12" cy="8" r="3" fill="#e61809"/><path d="M12 5l1 1-1 1-1-1z" fill="#ffc61e"/></svg>

After

Width:  |  Height:  |  Size: 252 B

1
src/assets/flags/lo.svg Normal file
View File

@@ -0,0 +1 @@
<svg viewBox="0 0 24 16" xmlns="http://www.w3.org/2000/svg"><rect width="24" height="4" fill="#ce1126"/><rect y="4" width="24" height="8" fill="#002868"/><rect y="12" width="24" height="4" fill="#ce1126"/><circle cx="12" cy="8" r="2.5" fill="#fff"/></svg>

After

Width:  |  Height:  |  Size: 255 B

1
src/assets/flags/mn.svg Normal file
View File

@@ -0,0 +1 @@
<svg viewBox="0 0 24 16" xmlns="http://www.w3.org/2000/svg"><rect width="24" height="5.33" fill="#da2032"/><rect y="5.33" width="24" height="5.33" fill="#0066b3"/><rect y="10.67" width="24" height="5.33" fill="#da2032"/><path d="M4 2l2 4h-4z" fill="#fdd600"/></svg>

After

Width:  |  Height:  |  Size: 265 B

1
src/assets/flags/mr.svg Normal file
View File

@@ -0,0 +1 @@
<svg viewBox="0 0 24 16" xmlns="http://www.w3.org/2000/svg"><rect width="24" height="5.33" fill="#ff9933"/><rect y="5.33" width="24" height="5.33" fill="#fff"/><rect y="10.67" width="24" height="5.33" fill="#138808"/><circle cx="12" cy="8" r="2" fill="#000080"/></svg>

After

Width:  |  Height:  |  Size: 268 B

4
src/assets/flags/ms.svg Normal file
View File

@@ -0,0 +1,4 @@
<svg viewBox="0 0 24 16" xmlns="http://www.w3.org/2000/svg">
<rect width="24" height="8" fill="#ff0000"/>
<rect y="8" width="24" height="8" fill="#ffffff"/>
</svg>

After

Width:  |  Height:  |  Size: 168 B

1
src/assets/flags/my.svg Normal file
View File

@@ -0,0 +1 @@
<svg viewBox="0 0 24 16" xmlns="http://www.w3.org/2000/svg"><rect width="24" height="5.33" fill="#fecb00"/><rect y="5.33" width="24" height="5.33" fill="#34b233"/><rect y="10.67" width="24" height="5.33" fill="#ea2839"/><path d="M12 4l2.5 7h-8L9 4l-2.5 7h8z" fill="#fff" transform="translate(0 1)"/></svg>

After

Width:  |  Height:  |  Size: 305 B

1
src/assets/flags/ne.svg Normal file
View File

@@ -0,0 +1 @@
<svg viewBox="0 0 24 16" xmlns="http://www.w3.org/2000/svg"><path d="M0 0l16 8L0 16z" fill="#dc143c"/><path d="M0 0l16 8L0 16" stroke="#003893" stroke-width="2" fill="none"/><path d="M4 6l2 2-2 2z" fill="#fff"/><path d="M4 10l2 2-2 2z" fill="#fff"/></svg>

After

Width:  |  Height:  |  Size: 255 B

1
src/assets/flags/om.svg Normal file
View File

@@ -0,0 +1 @@
<svg viewBox="0 0 24 16" xmlns="http://www.w3.org/2000/svg"><rect width="24" height="5.33" fill="#078930"/><rect y="5.33" width="24" height="5.33" fill="#fcdD09"/><rect y="10.67" width="24" height="5.33" fill="#da121a"/><circle cx="12" cy="8" r="2.5" fill="#0f47af"/></svg>

After

Width:  |  Height:  |  Size: 273 B

1
src/assets/flags/pa.svg Normal file
View File

@@ -0,0 +1 @@
<svg viewBox="0 0 24 16" xmlns="http://www.w3.org/2000/svg"><rect width="24" height="16" fill="#fff"/><rect width="6" height="16" fill="#01411c"/><circle cx="15" cy="8" r="3" fill="#01411c"/></svg>

After

Width:  |  Height:  |  Size: 197 B

1
src/assets/flags/ps.svg Normal file
View File

@@ -0,0 +1 @@
<svg viewBox="0 0 24 16" xmlns="http://www.w3.org/2000/svg"><rect width="24" height="5.33" fill="#000"/><rect y="5.33" width="24" height="5.33" fill="#be0000"/><rect y="10.67" width="24" height="5.33" fill="#007a36"/><path d="M12 4l3 6h-6z" fill="#fff"/></svg>

After

Width:  |  Height:  |  Size: 260 B

1
src/assets/flags/rn.svg Normal file
View File

@@ -0,0 +1 @@
<svg viewBox="0 0 24 16" xmlns="http://www.w3.org/2000/svg"><rect width="24" height="16" fill="#fff"/><path d="M0 0l24 16m0-16L0 16" stroke="#ce1126" stroke-width="4"/><circle cx="12" cy="8" r="3" fill="#fff"/><circle cx="12" cy="8" r="2" fill="#1eb53a"/><circle cx="12" cy="8" r="1" fill="#ce1126"/><circle cx="12" cy="8" r="0.5" fill="#1eb53a"/></svg>

After

Width:  |  Height:  |  Size: 353 B

1
src/assets/flags/rw.svg Normal file
View File

@@ -0,0 +1 @@
<svg viewBox="0 0 24 16" xmlns="http://www.w3.org/2000/svg"><rect width="24" height="8" fill="#00a1de"/><rect y="8" width="24" height="4" fill="#fad201"/><rect y="12" width="24" height="4" fill="#20603d"/><circle cx="18" cy="4" r="2" fill="#fad201"/></svg>

After

Width:  |  Height:  |  Size: 256 B

1
src/assets/flags/so.svg Normal file
View File

@@ -0,0 +1 @@
<svg viewBox="0 0 24 16" xmlns="http://www.w3.org/2000/svg"><rect width="24" height="16" fill="#4189dd"/><path d="M12 4l1.5 5h5l-4 3 1.5 5-4-3-4 3 1.5-5-4-3h5z" fill="#fff"/></svg>

After

Width:  |  Height:  |  Size: 180 B

5
src/assets/flags/sw.svg Normal file
View File

@@ -0,0 +1,5 @@
<svg viewBox="0 0 24 16" xmlns="http://www.w3.org/2000/svg">
<rect width="24" height="5.33" fill="#3a75c4"/>
<rect y="5.33" width="24" height="5.33" fill="#ffde00"/>
<rect y="10.67" width="24" height="5.33" fill="#3a75c4"/>
</svg>

After

Width:  |  Height:  |  Size: 237 B

6
src/assets/flags/ta.svg Normal file
View File

@@ -0,0 +1,6 @@
<svg viewBox="0 0 24 16" xmlns="http://www.w3.org/2000/svg">
<rect width="24" height="5.33" fill="#ff9933"/>
<rect y="5.33" width="24" height="5.33" fill="#ffffff"/>
<rect y="10.67" width="24" height="5.33" fill="#128807"/>
<circle cx="12" cy="8" r="2" fill="#000080"/>
</svg>

After

Width:  |  Height:  |  Size: 285 B

6
src/assets/flags/te.svg Normal file
View File

@@ -0,0 +1,6 @@
<svg viewBox="0 0 24 16" xmlns="http://www.w3.org/2000/svg">
<rect width="24" height="5.33" fill="#ff9933"/>
<rect y="5.33" width="24" height="5.33" fill="#ffffff"/>
<rect y="10.67" width="24" height="5.33" fill="#128807"/>
<circle cx="12" cy="8" r="2" fill="#000080"/>
</svg>

After

Width:  |  Height:  |  Size: 285 B

7
src/assets/flags/th.svg Normal file
View File

@@ -0,0 +1,7 @@
<svg viewBox="0 0 24 16" xmlns="http://www.w3.org/2000/svg">
<rect width="24" height="3" fill="#ff0000"/>
<rect y="3" width="24" height="2" fill="#ffffff"/>
<rect y="5" width="24" height="6" fill="#2e2a8c"/>
<rect y="11" width="24" height="2" fill="#ffffff"/>
<rect y="13" width="24" height="3" fill="#ff0000"/>
</svg>

After

Width:  |  Height:  |  Size: 329 B

1
src/assets/flags/ti.svg Normal file
View File

@@ -0,0 +1 @@
<svg viewBox="0 0 24 16" xmlns="http://www.w3.org/2000/svg"><path d="M0 0l24 8L0 16z" fill="#ea0437"/><path d="M0 0l24 8H0z" fill="#0cad4d"/><path d="M0 16l24-8H0z" fill="#418fde"/><circle cx="8" cy="8" r="3" fill="#ffc61e"/></svg>

After

Width:  |  Height:  |  Size: 231 B

5
src/assets/flags/tl.svg Normal file
View File

@@ -0,0 +1,5 @@
<svg viewBox="0 0 24 16" xmlns="http://www.w3.org/2000/svg">
<rect width="24" height="8" fill="#0038a8"/>
<rect y="8" width="24" height="8" fill="#ce1126"/>
<polygon points="0,8 8,0 8,16" fill="#fcd116"/>
</svg>

After

Width:  |  Height:  |  Size: 218 B

View File

@@ -0,0 +1,4 @@
<svg viewBox="0 0 24 16" xmlns="http://www.w3.org/2000/svg">
<rect width="24" height="16" fill="#cccccc"/>
<text x="12" y="10" font-size="6" text-anchor="middle" fill="#666">TL</text>
</svg>

After

Width:  |  Height:  |  Size: 195 B

5
src/assets/flags/uz.svg Normal file
View File

@@ -0,0 +1,5 @@
<svg viewBox="0 0 24 16" xmlns="http://www.w3.org/2000/svg">
<rect width="24" height="5.33" fill="#1eb53a"/>
<rect y="5.33" width="24" height="5.33" fill="#ffffff"/>
<rect y="10.67" width="24" height="5.33" fill="#0099b5"/>
</svg>

After

Width:  |  Height:  |  Size: 237 B

4
src/assets/flags/vi.svg Normal file
View File

@@ -0,0 +1,4 @@
<svg viewBox="0 0 24 16" xmlns="http://www.w3.org/2000/svg">
<rect width="24" height="16" fill="#da251d"/>
<polygon points="12,4.5 13.2,8 16.9,8 13.9,10 15.1,13.5 12,11.5 8.9,13.5 10.1,10 7.1,8 10.8,8" fill="#ffdd00"/>
</svg>

After

Width:  |  Height:  |  Size: 230 B

1
src/assets/flags/wo.svg Normal file
View File

@@ -0,0 +1 @@
<svg viewBox="0 0 24 16" xmlns="http://www.w3.org/2000/svg"><rect width="8" height="16" fill="#00853f"/><rect x="8" width="8" height="16" fill="#fdef42"/><rect x="16" width="8" height="16" fill="#e31b23"/><path d="M12 5l1.5 5h5l-4 3 1.5 5-4-3-4 3 1.5-5-4-3h5z" fill="#00853f"/></svg>

After

Width:  |  Height:  |  Size: 283 B

1
src/assets/flags/yo.svg Normal file
View File

@@ -0,0 +1 @@
<svg viewBox="0 0 24 16" xmlns="http://www.w3.org/2000/svg"><rect width="8" height="16" fill="#008751"/><rect x="8" width="8" height="16" fill="#fff"/><rect x="16" width="8" height="16" fill="#008751"/></svg>

After

Width:  |  Height:  |  Size: 208 B

View File

@@ -22,22 +22,43 @@ const cellClass = computed(() => {
}); });
let lastTap = 0; let lastTap = 0;
let longPressTimer = null;
let longPressTriggered = false;
const clearLongPress = () => {
if (longPressTimer) {
clearTimeout(longPressTimer);
longPressTimer = null;
}
};
const handlePointerDown = (e) => { const handlePointerDown = (e) => {
if (e.pointerType === 'mouse') { if (e.pointerType === 'mouse') {
if (e.button === 0) emit('start-drag', props.r, props.c, false); if (e.button === 0) emit('start-drag', props.r, props.c, false, false);
if (e.button === 2) emit('start-drag', props.r, props.c, true); if (e.button === 2) emit('start-drag', props.r, props.c, true, false);
return; return;
} }
// Touch logic
const now = Date.now(); const now = Date.now();
const isDoubleTap = now - lastTap < 300; if (now - lastTap < 300) {
lastTap = now; // Double tap -> X (Force)
if (isDoubleTap) { emit('start-drag', props.r, props.c, true, true);
emit('start-drag', props.r, props.c, true); lastTap = 0;
} else { } else {
emit('start-drag', props.r, props.c, false); // Single tap / Start drag -> Fill
emit('start-drag', props.r, props.c, false, false);
lastTap = now;
} }
}; };
const handlePointerUp = (e) => {
// Handled in pointerdown
};
const handlePointerCancel = (e) => {
// Handled in pointerdown
};
</script> </script>
<template> <template>
@@ -47,7 +68,10 @@ const handlePointerDown = (e) => {
:data-r="props.r" :data-r="props.r"
:data-c="props.c" :data-c="props.c"
@pointerdown.prevent="handlePointerDown" @pointerdown.prevent="handlePointerDown"
@mouseenter="emit('enter-cell', props.r, props.c)" @pointerup="handlePointerUp"
@pointercancel="handlePointerCancel"
@pointerleave="handlePointerCancel"
@mouseenter="emit('enter-cell', props.r, props.c, $event)"
@contextmenu.prevent @contextmenu.prevent
> >
<span v-if="props.state === 2" class="cross-mark">×</span> <span v-if="props.state === 2" class="cross-mark">×</span>

View File

@@ -1,21 +1,233 @@
<script setup> <script setup>
import { ref } from 'vue'; import { ref, computed, onMounted, onUnmounted, watch, nextTick } from 'vue';
import { usePuzzleStore } from '@/stores/puzzle'; import { usePuzzleStore } from '@/stores/puzzle';
import { useI18n } from '@/composables/useI18n';
import { calculateDifficulty } from '@/utils/puzzleUtils';
import { HelpCircle } from 'lucide-vue-next';
const emit = defineEmits(['close']); const emit = defineEmits(['close', 'open-simulation']);
const store = usePuzzleStore(); const store = usePuzzleStore();
const { t } = useI18n();
const customSize = ref(10); const customSize = ref(10);
const fillRate = ref(50);
const errorMsg = ref(''); const errorMsg = ref('');
const difficultyCanvas = ref(null);
const isDragging = ref(false);
const cachedBackground = ref(null);
const drawMap = () => {
const canvas = difficultyCanvas.value;
if (!canvas) return;
const ctx = canvas.getContext('2d');
const width = canvas.width;
const height = canvas.height;
// Clear
ctx.clearRect(0, 0, width, height);
// Use cached background if available
if (cachedBackground.value) {
ctx.putImageData(cachedBackground.value, 0, 0);
} else {
// Draw Gradient Background (Heavy calculation)
const imgData = ctx.createImageData(width, height);
const data = imgData.data;
// Ranges:
// X: Fill Rate 10% -> 90%
// Y: Size 5 -> 80
for (let y = 0; y < height; y++) {
for (let x = 0; x < width; x++) {
const normalizedX = x / width;
const normalizedY = 1 - (y / height); // 0 at bottom, 1 at top
const fRate = 0.1 + normalizedX * 0.8; // 0.1 to 0.9
const sSize = 5 + normalizedY * 75; // 5 to 80
const { value } = calculateDifficulty(fRate, sSize);
// Color Mapping
const hue = 120 * (1 - value / 100);
const [r, g, b] = hslToRgb(hue / 360, 1, 0.5);
const index = (y * width + x) * 4;
data[index] = r;
data[index + 1] = g;
data[index + 2] = b;
data[index + 3] = 255; // Alpha
}
}
ctx.putImageData(imgData, 0, 0);
cachedBackground.value = imgData;
}
// Draw current position
// Map current fillRate/size to x,y
// Fill: 10..90. Size: 5..80.
const currentFill = Math.max(10, Math.min(90, fillRate.value));
const currentSize = Math.max(5, Math.min(80, customSize.value));
const posX = ((currentFill - 10) / 80) * width;
const posY = (1 - (currentSize - 5) / 75) * height;
// Draw Crosshair/Circle
ctx.beginPath();
ctx.arc(posX, posY, 6, 0, Math.PI * 2);
ctx.fillStyle = '#fff';
ctx.fill();
ctx.lineWidth = 2;
ctx.strokeStyle = '#000';
ctx.stroke();
};
const hslToRgb = (h, s, l) => {
let r, g, b;
if (s === 0) {
r = g = b = l; // achromatic
} else {
const hue2rgb = (p, q, t) => {
if (t < 0) t += 1;
if (t > 1) t -= 1;
if (t < 1 / 6) return p + (q - p) * 6 * t;
if (t < 1 / 2) return q;
if (t < 2 / 3) return p + (q - p) * (2 / 3 - t) * 6;
return p;
};
const q = l < 0.5 ? l * (1 + s) : l + s - l * s;
const p = 2 * l - q;
r = hue2rgb(p, q, h + 1 / 3);
g = hue2rgb(p, q, h);
b = hue2rgb(p, q, h - 1 / 3);
}
return [Math.round(r * 255), Math.round(g * 255), Math.round(b * 255)];
};
const updateFromEvent = (e) => {
const canvas = difficultyCanvas.value;
if (!canvas) return;
const rect = canvas.getBoundingClientRect();
// Handle Touch or Mouse
const clientX = e.touches ? e.touches[0].clientX : e.clientX;
const clientY = e.touches ? e.touches[0].clientY : e.clientY;
let x = clientX - rect.left;
let y = clientY - rect.top;
// Clamp
x = Math.max(0, Math.min(rect.width, x));
y = Math.max(0, Math.min(rect.height, y));
// Reverse Map
// x / width -> fillRate (10..90)
// 1 - y / height -> size (5..80)
const normalizedX = x / rect.width;
const normalizedY = 1 - (y / rect.height);
const newFill = 10 + normalizedX * 80;
const newSize = 5 + normalizedY * 75;
fillRate.value = Math.round(newFill);
customSize.value = Math.round(newSize);
};
const startDrag = (e) => {
isDragging.value = true;
updateFromEvent(e);
// Add global listeners for mouse to handle dragging outside canvas
window.addEventListener('mousemove', onDrag);
window.addEventListener('mouseup', stopDrag);
};
const onDrag = (e) => {
if (!isDragging.value) return;
updateFromEvent(e);
};
const stopDrag = () => {
isDragging.value = false;
window.removeEventListener('mousemove', onDrag);
window.removeEventListener('mouseup', stopDrag);
};
onUnmounted(() => {
window.removeEventListener('mousemove', onDrag);
window.removeEventListener('mouseup', stopDrag);
});
const showAdvanced = ref(false);
const toggleAdvanced = () => {
showAdvanced.value = !showAdvanced.value;
if (showAdvanced.value) {
// Reset cache when opening to ensure size is correct if canvas resized
cachedBackground.value = null;
nextTick(drawMap);
}
};
onMounted(() => {
const savedSize = localStorage.getItem('nonograms_custom_size');
if (savedSize && !isNaN(savedSize)) {
customSize.value = Math.max(5, Math.min(80, Number(savedSize)));
}
const savedFillRate = localStorage.getItem('nonograms_custom_fill_rate');
if (savedFillRate && !isNaN(savedFillRate)) {
fillRate.value = Math.max(10, Math.min(90, Number(savedFillRate)));
}
// Don't draw map initially if hidden
});
watch([customSize, fillRate], () => {
if (showAdvanced.value) {
drawMap();
}
});
watch(customSize, (newVal) => {
localStorage.setItem('nonograms_custom_size', newVal);
});
watch(fillRate, (newVal) => {
localStorage.setItem('nonograms_custom_fill_rate', newVal);
});
const snapToStep = (value, step) => {
const rounded = Math.round(value / step) * step;
return Math.max(5, Math.min(80, rounded));
};
const handleSnap = () => {
customSize.value = snapToStep(Number(customSize.value), 5);
};
const difficultyInfo = computed(() => {
return calculateDifficulty(fillRate.value / 100, customSize.value);
});
const difficultyColor = computed(() => {
switch(difficultyInfo.value.level) {
case 'extreme': return '#ff3333';
case 'hardest': return '#ff9933';
case 'harder': return '#ffff33';
case 'easy': return '#33ff33';
default: return '#33ff33';
}
});
const confirm = () => { const confirm = () => {
const size = parseInt(customSize.value); const size = parseInt(customSize.value);
if (isNaN(size) || size < 5 || size > 100) { if (isNaN(size) || size < 5 || size > 80) {
errorMsg.value = 'Rozmiar musi być między 5 a 100!'; errorMsg.value = t('custom.sizeError');
return; return;
} }
store.initCustomGame(size); store.initCustomGame(size, fillRate.value / 100);
emit('close'); emit('close');
}; };
</script> </script>
@@ -23,24 +235,85 @@ const confirm = () => {
<template> <template>
<div class="modal-overlay" @click.self="emit('close')"> <div class="modal-overlay" @click.self="emit('close')">
<div class="modal glass-panel"> <div class="modal glass-panel">
<h2>GRA WŁASNA</h2> <h2>{{ t('custom.title') }}</h2>
<p>Wprowadź rozmiar siatki (5 - 100):</p>
<div class="modal-content">
<div class="sliders-section">
<div class="slider-container">
<p>{{ t('custom.prompt') }}</p>
<div class="input-group"> <div class="input-group">
<div class="range-value">{{ customSize }}</div>
<input <input
type="number" type="range"
v-model="customSize" v-model="customSize"
min="5" min="5"
max="100" max="80"
@keyup.enter="confirm" step="1"
@change="handleSnap"
/> />
<div class="range-scale">
<span>5</span>
<span>80</span>
</div>
</div>
</div>
<div class="slider-container">
<p>{{ t('custom.fillRate') }}</p>
<div class="input-group">
<div class="range-value">{{ fillRate }}%</div>
<input
type="range"
v-model="fillRate"
min="10"
max="90"
step="1"
/>
<div class="range-scale">
<span>10%</span>
<span>90%</span>
</div>
</div>
</div>
</div>
<div class="map-section" v-if="showAdvanced">
<canvas
ref="difficultyCanvas"
width="400"
height="400"
@mousedown="startDrag"
@touchstart.prevent="startDrag"
@touchmove.prevent="onDrag"
@touchend="stopDrag"
></canvas>
</div>
</div>
<div class="difficulty-indicator">
<div class="label-row">
<div class="label">{{ t('custom.difficulty') }}</div>
<button class="help-btn" @click="emit('open-simulation')" :title="t('custom.simulationHelp') || 'How is this calculated?'">
<HelpCircle class="icon-sm" />
</button>
</div>
<div class="difficulty-row">
<div class="level" :style="{ color: difficultyColor }">{{ t(`difficulty.${difficultyInfo.level}`) }}</div>
<div class="percentage" :style="{ color: difficultyColor }">({{ difficultyInfo.value }}%)</div>
</div>
</div>
<div class="advanced-toggle">
<button class="btn-text" @click="toggleAdvanced">
{{ showAdvanced ? t('custom.hideMap') : t('custom.showMap') }}
</button>
</div> </div>
<p v-if="errorMsg" class="error">{{ errorMsg }}</p> <p v-if="errorMsg" class="error">{{ errorMsg }}</p>
<div class="actions"> <div class="actions">
<button class="btn-neon secondary" @click="emit('close')">Anuluj</button> <button class="btn-neon secondary" @click="emit('close')">{{ t('custom.cancel') }}</button>
<button class="btn-neon" @click="confirm">Start</button> <button class="btn-neon" @click="confirm">{{ t('custom.start') }}</button>
</div> </div>
</div> </div>
</div> </div>
@@ -53,7 +326,7 @@ const confirm = () => {
left: 0; left: 0;
width: 100vw; width: 100vw;
height: 100vh; height: 100vh;
background: rgba(0, 0, 0, 0.7); background: var(--modal-overlay);
backdrop-filter: blur(5px); backdrop-filter: blur(5px);
display: flex; display: flex;
justify-content: center; justify-content: center;
@@ -65,11 +338,60 @@ const confirm = () => {
.modal { .modal {
padding: 40px; padding: 40px;
text-align: center; text-align: center;
max-width: 400px; max-width: 800px;
width: 90%; width: 90%;
border: 1px solid var(--accent-cyan); border: 1px solid var(--accent-cyan);
box-shadow: 0 0 50px rgba(0, 242, 255, 0.2); box-shadow: 0 0 50px rgba(0, 242, 255, 0.2);
animation: slideUp 0.3s ease; animation: slideUp 0.3s ease;
transition: all 0.3s ease-in-out;
}
.modal-content {
display: flex;
flex-direction: row;
gap: 40px;
align-items: center;
justify-content: center;
margin-bottom: 20px;
}
@media (max-width: 700px) {
.modal-content {
flex-direction: column;
gap: 20px;
}
}
.sliders-section {
flex: 1;
display: flex;
flex-direction: column;
align-items: center;
}
.map-section {
flex: 0 0 auto;
display: flex;
justify-content: center;
align-items: center;
}
canvas {
width: 400px;
height: 400px;
border: 2px solid var(--panel-border);
border-radius: 8px;
box-shadow: 0 0 20px rgba(0, 242, 255, 0.1);
cursor: crosshair;
background: #000;
}
@media (max-width: 600px) {
canvas {
width: 100%;
height: auto;
aspect-ratio: 1;
}
} }
h2 { h2 {
@@ -85,25 +407,145 @@ p {
margin-bottom: 20px; margin-bottom: 20px;
} }
.input-group { .slider-container {
margin-bottom: 20px; width: 100%;
margin-bottom: 10px;
} }
input { .input-group {
background: rgba(0, 0, 0, 0.3); margin-bottom: 20px;
border: 1px solid var(--glass-border); display: flex;
color: #fff; flex-direction: column;
padding: 10px; align-items: center;
font-size: 1.2rem; gap: 10px;
border-radius: 8px; }
width: 100px;
.range-value {
min-width: 64px;
padding: 6px 12px;
border-radius: 999px;
background: var(--panel-bg-strong);
border: 1px solid var(--panel-border);
color: var(--text-strong);
font-size: 1.1rem;
text-align: center; text-align: center;
} }
input:focus { input[type="range"] {
-webkit-appearance: none;
width: min(300px, 70vw);
height: 8px;
border-radius: 999px;
background: linear-gradient(90deg, var(--accent-cyan), var(--accent-purple));
outline: none; outline: none;
border-color: var(--accent-cyan); border: 1px solid var(--panel-border);
box-shadow: 0 0 10px rgba(0, 242, 255, 0.3); box-shadow: 0 0 10px rgba(0, 242, 255, 0.2);
}
input[type="range"]::-webkit-slider-thumb {
-webkit-appearance: none;
width: 22px;
height: 22px;
border-radius: 50%;
background: var(--text-strong);
border: 2px solid var(--accent-cyan);
box-shadow: 0 0 12px rgba(0, 242, 255, 0.5);
cursor: pointer;
}
input[type="range"]::-moz-range-thumb {
width: 22px;
height: 22px;
border-radius: 50%;
background: var(--text-strong);
border: 2px solid var(--accent-cyan);
box-shadow: 0 0 12px rgba(0, 242, 255, 0.5);
cursor: pointer;
}
.range-scale {
width: min(300px, 70vw);
display: flex;
justify-content: space-between;
color: var(--text-muted);
font-size: 0.85rem;
}
.difficulty-indicator {
margin: 20px 0 40px 0;
display: flex;
flex-direction: column;
align-items: center;
gap: 5px;
}
.label-row {
display: flex;
align-items: center;
gap: 8px;
}
.help-btn {
background: none;
border: none;
color: var(--text-muted);
cursor: pointer;
display: flex;
align-items: center;
padding: 4px;
border-radius: 50%;
transition: color 0.3s, background 0.3s;
}
.help-btn:hover {
color: var(--accent-cyan);
background: rgba(0, 242, 255, 0.1);
}
.icon-sm {
width: 16px;
height: 16px;
}
.difficulty-row {
display: flex;
flex-direction: row;
gap: 8px;
align-items: baseline;
justify-content: center;
white-space: nowrap;
flex-wrap: nowrap;
}
.label {
font-size: 1rem;
color: var(--text-muted);
}
.level {
font-size: 1.4rem;
font-weight: bold;
text-transform: uppercase;
line-height: 1.2;
}
.percentage {
font-size: 1rem;
font-weight: bold;
}
.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;
display: inline-block;
min-width: 120px; /* Reserve space for longest text */
text-align: left;
} }
.error { .error {
@@ -111,6 +553,25 @@ input:focus {
font-size: 0.9rem; font-size: 0.9rem;
} }
.btn-text {
background: none;
border: none;
color: var(--accent-cyan);
font-size: 0.9rem;
cursor: pointer;
text-decoration: underline;
opacity: 0.8;
transition: opacity 0.3s;
}
.btn-text:hover {
opacity: 1;
}
.advanced-toggle {
margin-bottom: 10px;
}
.actions { .actions {
display: flex; display: flex;
gap: 15px; gap: 15px;

View File

@@ -2,9 +2,11 @@
import { computed, ref } from 'vue'; import { computed, ref } from 'vue';
import { usePuzzleStore } from '@/stores/puzzle'; import { usePuzzleStore } from '@/stores/puzzle';
import { useTimer } from '@/composables/useTimer'; import { useTimer } from '@/composables/useTimer';
import { useI18n } from '@/composables/useI18n';
const store = usePuzzleStore(); const store = usePuzzleStore();
const { formatTime } = useTimer(); const { formatTime } = useTimer();
const { t } = useI18n();
const isVisible = ref(false); const isVisible = ref(false);
const isProgressVisible = ref(true); // Toggle for progress percentage const isProgressVisible = ref(true); // Toggle for progress percentage
@@ -33,14 +35,14 @@ const toggleVisibility = () => {
<div id="fixed-bar" :class="{ visible: isVisible }"> <div id="fixed-bar" :class="{ visible: isVisible }">
<div class="fixed-content"> <div class="fixed-content">
<div class="fixed-stat"> <div class="fixed-stat">
<span>Czas:</span> <span>{{ t('fixed.time') }}</span>
<span>{{ formattedTime }}</span> <span>{{ formattedTime }}</span>
</div> </div>
<div class="fixed-stat"> <div class="fixed-stat">
<span>Postęp:</span> <span>{{ t('fixed.progress') }}</span>
<span style="min-width: 60px; text-align: right;">{{ progressText }}</span> <span style="min-width: 60px; text-align: right;">{{ progressText }}</span>
<button class="btn-eye" @click="toggleVisibility" :title="isProgressVisible ? 'Ukryj' : 'Pokaż'"> <button class="btn-eye" @click="toggleVisibility" :title="isProgressVisible ? t('fixed.hide') : t('fixed.show')">
<span v-if="isProgressVisible">👁</span> <span v-if="isProgressVisible">👁</span>
<span v-else>🔒</span> <span v-else>🔒</span>
</button> </button>
@@ -60,16 +62,16 @@ const toggleVisibility = () => {
left: 0; left: 0;
width: 100%; width: 100%;
height: 60px; height: 60px;
background: rgba(0, 0, 0, 0.85); background: var(--fixed-bar-bg);
backdrop-filter: blur(10px); backdrop-filter: blur(10px);
z-index: 1000; z-index: 1000;
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
border-bottom: 1px solid rgba(255, 255, 255, 0.1); border-bottom: 1px solid var(--fixed-bar-border);
transform: translateY(-100%); transform: translateY(-100%);
transition: transform 0.3s ease; transition: transform 0.3s ease;
box-shadow: 0 4px 20px rgba(0,0,0,0.5); box-shadow: var(--fixed-bar-shadow);
} }
#fixed-bar.visible { #fixed-bar.visible {
@@ -93,13 +95,13 @@ const toggleVisibility = () => {
display: flex; display: flex;
gap: 10px; gap: 10px;
align-items: center; align-items: center;
color: #fff; color: var(--text-strong);
} }
.fixed-stat span:first-child { .fixed-stat span:first-child {
opacity: 0.7;
font-size: 0.9rem; font-size: 0.9rem;
text-transform: uppercase; text-transform: uppercase;
color: var(--text-muted);
} }
.progress-line-container { .progress-line-container {
@@ -108,7 +110,7 @@ const toggleVisibility = () => {
left: 0; left: 0;
width: 100%; width: 100%;
height: 3px; height: 3px;
background: rgba(255, 255, 255, 0.1); background: var(--progress-track-bg);
} }
.progress-line-fill { .progress-line-fill {

View File

@@ -1,47 +0,0 @@
<script setup>
import { usePuzzleStore } from '@/stores/puzzle';
const store = usePuzzleStore();
function handleNewRandom() {
// If currently custom, regenerate custom.
// If not custom, switch to custom with current size?
// Or maybe just re-init current level if it's not custom?
// "NOWA LOSOWA" implies random.
// If user is on Easy/Medium/Hard, "Random" might mean "Random predefined" or "Random generated".
// Let's assume it generates a new random grid of current size.
store.initCustomGame(store.size);
}
</script>
<template>
<div class="game-actions">
<button class="btn-neon secondary" @click="store.resetGame">RESET</button>
<button class="btn-neon secondary" @click="handleNewRandom">NOWA LOSOWA</button>
<button class="btn-neon secondary" @click="store.undo">COFNIJ</button>
<button class="btn-neon secondary" @click="store.checkWin">SPRAWDŹ</button>
</div>
</template>
<style scoped>
.game-actions {
display: flex;
flex-wrap: wrap;
gap: 15px;
justify-content: center;
margin-bottom: 30px;
}
.btn-neon.secondary {
border-color: rgba(255, 255, 255, 0.3);
color: rgba(255, 255, 255, 0.8);
font-size: 0.9rem;
padding: 10px 25px;
}
.btn-neon.secondary:hover {
background: rgba(255, 255, 255, 0.1);
border-color: #fff;
color: #fff;
}
</style>

View File

@@ -12,6 +12,97 @@ const { startDrag, onMouseEnter, stopDrag } = useNonogram();
const cellSize = ref(30); const cellSize = ref(30);
const rowHintsRef = ref(null); const rowHintsRef = ref(null);
const activeRow = ref(null);
const activeCol = ref(null);
const isFinePointer = ref(false);
const scrollWrapper = ref(null);
const scrollTrack = ref(null);
const showScrollbar = ref(false);
const thumbWidth = ref(20);
const thumbLeft = ref(0);
let isDraggingScroll = false;
let dragStartX = 0;
let dragStartLeft = 0;
const checkScroll = () => {
const el = scrollWrapper.value;
if (!el) return;
const sw = el.scrollWidth;
const cw = el.clientWidth;
// Only show custom scrollbar on mobile/tablet (width < 768px) and if content overflows
const isMobile = window.innerWidth <= 768;
showScrollbar.value = isMobile && (sw > cw + 1);
if (showScrollbar.value) {
// Thumb width percentage = (viewport / total) * 100
const ratio = cw / sw;
thumbWidth.value = Math.max(10, ratio * 100);
}
};
const handleScroll = () => {
if (isDraggingScroll) return;
const el = scrollWrapper.value;
if (!el) return;
const sw = el.scrollWidth;
const cw = el.clientWidth;
const sl = el.scrollLeft;
const maxScroll = sw - cw;
if (maxScroll <= 0) return;
// Map scroll position to thumb position (0 to 100 - thumbWidth)
const maxThumb = 100 - thumbWidth.value;
thumbLeft.value = (sl / maxScroll) * maxThumb;
};
const startScrollDrag = (e) => {
isDraggingScroll = true;
dragStartX = e.clientX || e.touches[0].clientX;
dragStartLeft = thumbLeft.value;
document.addEventListener('mousemove', onScrollDrag);
document.addEventListener('mouseup', stopScrollDrag);
document.addEventListener('touchmove', onScrollDrag, { passive: false });
document.addEventListener('touchend', stopScrollDrag);
};
const onScrollDrag = (e) => {
if (!isDraggingScroll || !scrollTrack.value) return;
const clientX = e.clientX || (e.touches ? e.touches[0].clientX : 0);
const deltaX = clientX - dragStartX;
const trackWidth = scrollTrack.value.offsetWidth;
if (trackWidth === 0) return;
// Calculate delta as percentage of track
const deltaPercent = (deltaX / trackWidth) * 100;
// New thumb position
let newLeft = dragStartLeft + deltaPercent;
const maxThumb = 100 - thumbWidth.value;
newLeft = Math.max(0, Math.min(maxThumb, newLeft));
thumbLeft.value = newLeft;
// Sync scroll
const el = scrollWrapper.value;
if (el) {
const sw = el.scrollWidth;
const cw = el.clientWidth;
const maxScroll = sw - cw;
el.scrollLeft = (newLeft / maxThumb) * maxScroll;
}
};
const stopScrollDrag = () => {
isDraggingScroll = false;
document.removeEventListener('mousemove', onScrollDrag);
document.removeEventListener('mouseup', stopScrollDrag);
document.removeEventListener('touchmove', onScrollDrag);
document.removeEventListener('touchend', stopScrollDrag);
};
const getRowHintsWidth = () => { const getRowHintsWidth = () => {
const el = rowHintsRef.value?.$el; const el = rowHintsRef.value?.$el;
@@ -20,17 +111,27 @@ const getRowHintsWidth = () => {
}; };
const computeCellSize = () => { const computeCellSize = () => {
const vw = Math.min(window.innerWidth, 900);
const rootStyles = getComputedStyle(document.documentElement); const rootStyles = getComputedStyle(document.documentElement);
const hintWidth = getRowHintsWidth(); const hintWidth = getRowHintsWidth();
const gapRaw = rootStyles.getPropertyValue('--gap-size') || '2px'; const gapRaw = rootStyles.getPropertyValue('--gap-size') || '2px';
const gridPadRaw = rootStyles.getPropertyValue('--grid-padding') || '5px'; const gridPadRaw = rootStyles.getPropertyValue('--grid-padding') || '5px';
const gap = parseFloat(gapRaw); const gap = parseFloat(gapRaw);
const gridPad = parseFloat(gridPadRaw); const gridPad = parseFloat(gridPadRaw);
const bodyStyles = getComputedStyle(document.body);
const bodyPadding = parseFloat(bodyStyles.paddingLeft) + parseFloat(bodyStyles.paddingRight); let containerWidth;
const availableForGrid = vw - bodyPadding - hintWidth; if (scrollWrapper.value) {
containerWidth = scrollWrapper.value.clientWidth;
} else {
// Fallback if wrapper not ready: window width minus estimated padding
// Body padding (40) + Layout padding (40) = 80
containerWidth = window.innerWidth - 80;
}
// Ensure we don't have negative space
const availableForGrid = Math.max(0, containerWidth - hintWidth);
const size = Math.floor((availableForGrid - gridPad * 2 - (store.size - 1) * gap) / store.size); const size = Math.floor((availableForGrid - gridPad * 2 - (store.size - 1) * gap) / store.size);
// Keep min 18, max 36
cellSize.value = Math.max(18, Math.min(36, size)); cellSize.value = Math.max(18, Math.min(36, size));
}; };
@@ -52,11 +153,26 @@ const handlePointerMove = (e) => {
} }
}; };
const handleCellEnter = (r, c) => {
onMouseEnter(r, c);
if (!isFinePointer.value) return;
activeRow.value = r;
activeCol.value = c;
};
const handleGridLeave = () => {
stopDrag();
activeRow.value = null;
activeCol.value = null;
};
onMounted(() => { onMounted(() => {
nextTick(() => { nextTick(() => {
computeCellSize(); computeCellSize();
}); });
isFinePointer.value = window.matchMedia('(pointer: fine)').matches;
window.addEventListener('resize', computeCellSize); window.addEventListener('resize', computeCellSize);
window.addEventListener('resize', checkScroll);
window.addEventListener('mouseup', handleGlobalMouseUp); window.addEventListener('mouseup', handleGlobalMouseUp);
window.addEventListener('pointerup', handleGlobalPointerUp); window.addEventListener('pointerup', handleGlobalPointerUp);
window.addEventListener('touchend', handleGlobalPointerUp, { passive: true }); window.addEventListener('touchend', handleGlobalPointerUp, { passive: true });
@@ -64,6 +180,7 @@ onMounted(() => {
onUnmounted(() => { onUnmounted(() => {
window.removeEventListener('resize', computeCellSize); window.removeEventListener('resize', computeCellSize);
window.removeEventListener('resize', checkScroll);
window.removeEventListener('mouseup', handleGlobalMouseUp); window.removeEventListener('mouseup', handleGlobalMouseUp);
window.removeEventListener('pointerup', handleGlobalPointerUp); window.removeEventListener('pointerup', handleGlobalPointerUp);
window.removeEventListener('touchend', handleGlobalPointerUp); window.removeEventListener('touchend', handleGlobalPointerUp);
@@ -72,19 +189,20 @@ onUnmounted(() => {
watch(() => store.size, async () => { watch(() => store.size, async () => {
await nextTick(); await nextTick();
computeCellSize(); computeCellSize();
checkScroll();
}); });
</script> </script>
<template> <template>
<div class="game-board-wrapper"> <div class="game-board-wrapper" ref="scrollWrapper" @scroll="handleScroll">
<div class="game-container" :style="{ '--cell-size': `${cellSize}px` }"> <div class="game-container" :style="{ '--cell-size': `${cellSize}px` }">
<div class="corner-spacer"></div> <div class="corner-spacer"></div>
<!-- Column Hints --> <!-- Column Hints -->
<Hints :hints="colHints" orientation="col" :size="store.size" /> <Hints :hints="colHints" orientation="col" :size="store.size" :activeIndex="activeCol" />
<!-- Row Hints --> <!-- Row Hints -->
<Hints ref="rowHintsRef" :hints="rowHints" orientation="row" :size="store.size" /> <Hints ref="rowHintsRef" :hints="rowHints" orientation="row" :size="store.size" :activeIndex="activeRow" />
<!-- Grid --> <!-- Grid -->
<div <div
@@ -94,7 +212,7 @@ watch(() => store.size, async () => {
gridTemplateRows: `repeat(${store.size}, var(--cell-size))` gridTemplateRows: `repeat(${store.size}, var(--cell-size))`
}" }"
@pointermove.prevent="handlePointerMove" @pointermove.prevent="handlePointerMove"
@mouseleave="stopDrag" @mouseleave="handleGridLeave"
> >
<template v-for="(row, r) in store.playerGrid" :key="r"> <template v-for="(row, r) in store.playerGrid" :key="r">
<Cell <Cell
@@ -108,19 +226,45 @@ watch(() => store.size, async () => {
'guide-bottom': (r + 1) % 5 === 0 && r !== store.size - 1 'guide-bottom': (r + 1) % 5 === 0 && r !== store.size - 1
}" }"
@start-drag="startDrag" @start-drag="startDrag"
@enter-cell="onMouseEnter" @enter-cell="handleCellEnter"
/> />
</template> </template>
</div> </div>
</div> </div>
</div> </div>
<Teleport to="body">
<div v-if="showScrollbar" class="fixed-scroll-bar">
<div class="fixed-scroll-track" ref="scrollTrack" @pointerdown="startScrollDrag">
<div
class="fixed-scroll-thumb"
:style="{ width: `${thumbWidth}%`, left: `${thumbLeft}%` }"
></div>
</div>
</div>
</Teleport>
</template> </template>
<style scoped> <style scoped>
.game-board-wrapper { .game-board-wrapper {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
align-items: center; align-items: flex-start;
overflow-x: auto;
width: 100%;
scrollbar-width: none; /* Hide default scrollbar */
}
/* Desktop: Remove scroll behavior to ensure full grid visibility */
@media (min-width: 769px) {
.game-board-wrapper {
overflow-x: auto; /* Allow scrolling if grid is too large (e.g. 80x80) */
align-items: center; /* Center the grid on desktop */
}
}
.game-board-wrapper::-webkit-scrollbar {
display: none;
} }
.game-container { .game-container {
@@ -128,17 +272,24 @@ watch(() => store.size, async () => {
grid-template-columns: auto auto; grid-template-columns: auto auto;
grid-template-rows: auto auto; grid-template-rows: auto auto;
gap: 0; gap: 0;
padding: 20px; padding: 0;
background: rgba(0, 0, 0, 0.2); background: transparent;
border-radius: 16px; box-shadow: none;
box-shadow: 0 0 30px rgba(0, 0, 0, 0.3);
margin-top: 10px; margin-top: 10px;
margin-left: auto;
margin-right: auto;
position: relative;
} }
.corner-spacer { .corner-spacer {
height: auto; /* Adapts to Col Hints height */ height: auto; /* Adapts to Col Hints height */
} }
/* Row Hints */
.game-container > :nth-child(3) {
/* No special styles */
}
.grid { .grid {
display: grid; display: grid;
gap: var(--gap-size); gap: var(--gap-size);

View File

@@ -1,5 +1,6 @@
<script setup> <script setup>
import { useSolver } from '@/composables/useSolver'; import { useSolver } from '@/composables/useSolver';
import { useI18n } from '@/composables/useI18n';
const { const {
isPlaying, isPlaying,
@@ -9,6 +10,7 @@ const {
togglePlay, togglePlay,
changeSpeed changeSpeed
} = useSolver(); } = useSolver();
const { t } = useI18n();
</script> </script>
<template> <template>
@@ -17,15 +19,15 @@ const {
<div class="guide-controls"> <div class="guide-controls">
<button class="btn-neon small" @click="togglePlay" :class="{ active: isPlaying }"> <button class="btn-neon small" @click="togglePlay" :class="{ active: isPlaying }">
{{ isPlaying ? 'PAUSE' : 'PLAY' }} {{ isPlaying ? t('guide.pause') : t('guide.play') }}
</button> </button>
<button class="btn-neon small" @click="step" :disabled="isPlaying"> <button class="btn-neon small" @click="step" :disabled="isPlaying">
STEP {{ t('guide.step') }}
</button> </button>
<button class="btn-neon small" @click="changeSpeed"> <button class="btn-neon small" @click="changeSpeed">
SPEED: {{ speedLabel }} {{ t('guide.speed') }}: {{ speedLabel }}
</button> </button>
</div> </div>
</div> </div>
@@ -33,8 +35,8 @@ const {
<style scoped> <style scoped>
.guide-panel { .guide-panel {
background: rgba(0, 0, 0, 0.25); background: var(--panel-bg);
border: 1px solid rgba(0, 242, 254, 0.3); border: 1px solid var(--panel-border);
border-radius: 12px; border-radius: 12px;
padding: 15px; padding: 15px;
margin-bottom: 20px; margin-bottom: 20px;
@@ -44,6 +46,7 @@ const {
flex-direction: column; flex-direction: column;
align-items: center; align-items: center;
backdrop-filter: blur(5px); backdrop-filter: blur(5px);
box-shadow: var(--panel-shadow);
} }
.status-text { .status-text {
@@ -51,7 +54,7 @@ const {
text-align: center; text-align: center;
margin-bottom: 10px; margin-bottom: 10px;
font-size: 0.9rem; font-size: 0.9rem;
color: #ccc; color: var(--text-muted);
min-height: 20px; min-height: 20px;
font-style: italic; font-style: italic;
} }

View File

@@ -12,6 +12,10 @@ defineProps({
size: { size: {
type: Number, type: Number,
required: true required: true
},
activeIndex: {
type: Number,
default: null
} }
}); });
</script> </script>
@@ -28,12 +32,13 @@ defineProps({
v-for="(group, index) in hints" v-for="(group, index) in hints"
:key="index" :key="index"
class="hint-group" class="hint-group"
:class="{ 'hint-alt': index % 2 !== 0 }" :class="{ 'is-active': index === activeIndex }"
> >
<span <span
v-for="(num, idx) in group" v-for="(num, idx) in group"
:key="idx" :key="idx"
class="hint-num" class="hint-num"
:class="{ 'hint-alt': idx % 2 !== 0 }"
> >
{{ num }} {{ num }}
</span> </span>
@@ -64,8 +69,8 @@ defineProps({
display: flex; display: flex;
justify-content: flex-end; justify-content: flex-end;
align-items: center; align-items: center;
background: rgba(255, 255, 255, 0.05); background: var(--hint-bg);
border: 1px solid rgba(255, 255, 255, 0.1); border: 1px solid var(--hint-border);
border-radius: 4px; border-radius: 4px;
transition: all 0.3s ease; transition: all 0.3s ease;
width: 100%; width: 100%;
@@ -85,19 +90,25 @@ defineProps({
.hint-num { .hint-num {
font-size: 0.85rem; font-size: 0.85rem;
color: #fff; color: var(--text-strong);
font-weight: bold; font-weight: bold;
padding: 2px; padding: 2px;
} }
/* Alternating Colors */ /* Alternating Colors within the group */
.hint-group.hint-alt .hint-num { .hint-num.hint-alt {
color: var(--accent-cyan); color: var(--accent-cyan);
} }
/* Hover effect for readability */ /* Hover effect for readability */
.hint-group:hover { .hint-group:hover {
background: rgba(255, 255, 255, 0.1); background: var(--hint-hover-bg);
border-color: var(--accent-cyan); border-color: var(--accent-cyan);
} }
.hint-group.is-active {
background: rgba(79, 172, 254, 0.2);
border-color: rgba(79, 172, 254, 0.8);
box-shadow: 0 0 12px rgba(79, 172, 254, 0.35);
}
</style> </style>

View File

@@ -1,64 +0,0 @@
<script setup>
import { usePuzzleStore } from '@/stores/puzzle';
const store = usePuzzleStore();
const levels = [
{ id: 'easy', label: 'ŁATWY 5X5' },
{ id: 'medium', label: 'ŚREDNI 10X10' },
{ id: 'hard', label: 'TRUDNY 15X15' }
];
const emit = defineEmits(['open-custom', 'toggle-guide']);
</script>
<template>
<div class="level-selector">
<button
v-for="lvl in levels"
:key="lvl.id"
class="btn-neon"
:class="{ active: store.currentLevelId === lvl.id }"
@click="store.initGame(lvl.id)"
>
{{ lvl.label }}
</button>
<button
class="btn-neon"
:class="{ active: store.currentLevelId === 'custom' }"
@click="emit('open-custom')"
>
WŁASNY
</button>
<button
class="btn-neon guide-btn"
@click="emit('toggle-guide')"
>
GUIDE
</button>
</div>
</template>
<style scoped>
.level-selector {
display: flex;
flex-wrap: wrap;
gap: 15px;
justify-content: center;
margin-bottom: 20px;
}
.btn-neon {
padding: 10px 20px;
border-radius: 20px;
text-transform: uppercase;
font-size: 0.9rem;
letter-spacing: 1px;
}
.guide-btn {
/* Specific styling for guide if needed */
}
</style>

715
src/components/NavBar.vue Normal file
View File

@@ -0,0 +1,715 @@
<script setup>
import { ref, computed, onMounted, onUnmounted, watch } from 'vue';
import { usePuzzleStore } from '@/stores/puzzle';
import { useI18n } from '@/composables/useI18n';
import { Gamepad2, Palette, CircleHelp, Sun, Moon, Menu, X, ChevronDown, ChevronUp, Monitor } from 'lucide-vue-next';
const store = usePuzzleStore();
const { t, locale, setLocale, locales } = useI18n();
const emit = defineEmits(['open-custom', 'toggle-guide', 'set-theme']);
const isGameOpen = ref(false);
const isThemeOpen = ref(false);
const isLangOpen = ref(false);
const isMobileMenuOpen = ref(false);
const langMenuRef = ref(null);
const searchTerm = ref('');
// Map language codes to country codes for flag-icons
const langToCountry = {
en: 'gb',
zh: 'cn',
'zh-hant': 'tw',
hi: 'in',
es: 'es',
fr: 'fr',
ar: 'sa',
bn: 'bd',
ru: 'ru',
pt: 'pt',
ur: 'pk',
pl: 'pl',
de: 'de',
it: 'it',
nl: 'nl',
sv: 'se',
da: 'dk',
fi: 'fi',
no: 'no',
cs: 'cz',
sk: 'sk',
hu: 'hu',
ro: 'ro',
bg: 'bg',
el: 'gr',
uk: 'ua',
be: 'by',
sr: 'rs',
hr: 'hr',
sl: 'si',
lt: 'lt',
lv: 'lv',
et: 'ee',
ga: 'ie',
is: 'is',
mt: 'mt',
sq: 'al',
mk: 'mk',
bs: 'ba',
tr: 'tr',
ca: 'es-ct',
gl: 'es-ga',
cy: 'gb-wls',
gd: 'gb-sct',
eu: 'es-pv',
af: 'za',
am: 'et',
hy: 'am',
az: 'az',
my: 'mm',
km: 'kh',
ceb: 'ph',
fa: 'ir',
gu: 'in',
ht: 'ht',
he: 'il',
ig: 'ng',
ilo: 'ph',
id: 'id',
ja: 'jp',
jv: 'id',
kn: 'in',
kk: 'kz',
rw: 'rw',
rn: 'bi',
ko: 'kr',
ku: 'tr',
ckb: 'iq',
ky: 'kg',
lo: 'la',
ms: 'my',
mr: 'in',
mn: 'mn',
ne: 'np',
om: 'et',
ps: 'af',
pa: 'in',
so: 'so',
sw: 'tz',
tl: 'ph',
ta: 'in',
te: 'in',
th: 'th',
bo: 'cn',
ti: 'er',
uz: 'uz',
vi: 'vn',
wo: 'sn',
yo: 'ng',
'pt-br': 'br',
'pt-pt': 'pt',
'fr-ca': 'ca',
'nl-be': 'be',
'es-es': 'es',
'es-419': 'mx',
'zh-hant': 'tw',
'zh-hans': 'cn'
};
const getFlagClass = (code) => {
const countryCode = langToCountry[code] || code;
return `fi fi-${countryCode}`;
};
const languages = computed(() => {
return locales.value
.map((code) => ({ code, label: t(`language.${code}`) }))
.sort((a, b) => a.label.localeCompare(b.label, locale.value));
});
const filteredLanguages = computed(() => {
const q = searchTerm.value.trim().toLowerCase();
if (!q) return languages.value;
return languages.value.filter((l) => l.label.toLowerCase().includes(q) || l.code.includes(q));
});
const levels = computed(() => [
{ id: 'easy', label: t('level.easy') },
{ id: 'medium', label: t('level.medium') },
{ id: 'hard', label: t('level.hard') }
]);
const closeMobileMenu = () => {
isMobileMenuOpen.value = false;
};
const toggleGameMenu = () => {
isGameOpen.value = !isGameOpen.value;
if (isGameOpen.value) {
isThemeOpen.value = false;
isLangOpen.value = false;
}
};
const toggleThemeMenu = () => {
isThemeOpen.value = !isThemeOpen.value;
if (isThemeOpen.value) {
isGameOpen.value = false;
isLangOpen.value = false;
}
};
const toggleLangMenu = () => {
isLangOpen.value = !isLangOpen.value;
if (isLangOpen.value) {
isGameOpen.value = false;
isThemeOpen.value = false;
}
};
const selectLevel = (id) => {
store.initGame(id);
isGameOpen.value = false;
closeMobileMenu();
};
const openCustom = () => {
emit('open-custom');
isGameOpen.value = false;
closeMobileMenu();
};
const setTheme = (theme) => {
emit('set-theme', theme);
isThemeOpen.value = false;
closeMobileMenu();
};
const selectLanguage = (value) => {
setLocale(value);
isLangOpen.value = false;
closeMobileMenu();
};
const toggleGuide = () => {
emit('toggle-guide');
closeMobileMenu();
};
// Close menus when clicking outside
const closeMenus = (e) => {
if (isMobileMenuOpen.value) return; // Don't close desktop menus if mobile is open (handled separately)
if (!e.target.closest('.nav-dropdown')) {
isGameOpen.value = false;
isThemeOpen.value = false;
isLangOpen.value = false;
}
};
onMounted(() => {
document.addEventListener('click', closeMenus);
});
onUnmounted(() => {
document.removeEventListener('click', closeMenus);
});
// Watch mobile menu to lock body scroll
watch(isMobileMenuOpen, (val) => {
if (val) {
document.body.style.overflow = 'hidden';
} else {
document.body.style.overflow = '';
}
});
</script>
<template>
<nav class="navbar">
<div class="nav-left">
<h1 class="app-title">{{ t('app.title') }}</h1>
</div>
<!-- Mobile Hamburger -->
<button class="btn-neon nav-btn icon-only mobile-only" @click="isMobileMenuOpen = true">
<Menu :size="24" />
</button>
<div class="nav-container desktop-only">
<!-- Game Menu -->
<div class="nav-dropdown">
<button class="btn-neon nav-btn" @click.stop="toggleGameMenu">
<Gamepad2 :size="18" /> {{ t('nav.newGame') }}
</button>
<transition name="slide-fade">
<div v-if="isGameOpen" class="dropdown-menu">
<button
v-for="lvl in levels"
:key="lvl.id"
class="dropdown-item"
@click="selectLevel(lvl.id)"
>
{{ lvl.label }}
</button>
<button class="dropdown-item" @click="openCustom">
{{ t('level.custom') }}
</button>
</div>
</transition>
</div>
<!-- Theme Menu -->
<div class="nav-dropdown">
<button class="btn-neon nav-btn" @click.stop="toggleThemeMenu">
<Palette :size="18" /> {{ t('theme.label') }}
</button>
<transition name="slide-fade">
<div v-if="isThemeOpen" class="dropdown-menu theme-menu">
<button class="dropdown-item" @click="setTheme('system')">
<Monitor :size="16" /> {{ t('theme.system') }}
</button>
<button class="dropdown-item" @click="setTheme('light')">
<Sun :size="16" /> {{ t('theme.light') }}
</button>
<button class="dropdown-item" @click="setTheme('dark')">
<Moon :size="16" /> {{ t('theme.dark') }}
</button>
</div>
</transition>
</div>
<!-- Guide Button -->
<button class="btn-neon nav-btn" @click="toggleGuide">
<CircleHelp :size="18" /> {{ t('nav.guide') }}
</button>
<!-- Language Menu -->
<div class="nav-dropdown">
<button class="btn-neon nav-btn icon-only flag-btn" @click.stop="toggleLangMenu">
<span class="lang-flag-current">
<span :class="getFlagClass(locale)"></span>
</span>
</button>
<transition name="slide-fade">
<div v-if="isLangOpen" class="dropdown-menu lang-menu-dropdown">
<div class="lang-search">
<input
class="lang-search-input"
type="text"
:placeholder="t('language.searchPlaceholder')"
v-model="searchTerm"
@click.stop
/>
</div>
<div class="lang-list">
<button
v-for="lang in filteredLanguages"
:key="lang.code"
class="dropdown-item"
:class="{ active: locale === lang.code }"
@click="selectLanguage(lang.code)"
>
<span class="lang-flag-item">
<span :class="getFlagClass(lang.code)"></span>
</span>
<span class="lang-name">{{ lang.label }}</span>
</button>
</div>
</div>
</transition>
</div>
</div>
<!-- Mobile Menu Overlay -->
<transition name="fade">
<div v-if="isMobileMenuOpen" class="mobile-menu-overlay">
<div class="mobile-menu-header">
<h2 class="mobile-title">{{ t('app.title') }}</h2>
<button class="btn-neon nav-btn icon-only close-btn" @click="closeMobileMenu">
<X :size="24" />
</button>
</div>
<div class="mobile-menu-items">
<!-- Mobile Game Menu -->
<div class="mobile-group">
<button class="mobile-item-trigger" @click="toggleGameMenu">
<span class="flex-center gap-10"><Gamepad2 :size="20" /> {{ t('nav.newGame') }}</span>
<component :is="isGameOpen ? ChevronUp : ChevronDown" :size="16" />
</button>
<div v-if="isGameOpen" class="mobile-sub-menu">
<button
v-for="lvl in levels"
:key="lvl.id"
class="mobile-sub-item"
@click="selectLevel(lvl.id)"
>
{{ lvl.label }}
</button>
<button class="mobile-sub-item" @click="openCustom">
{{ t('level.custom') }}
</button>
</div>
</div>
<!-- Mobile Theme Menu -->
<div class="mobile-group">
<button class="mobile-item-trigger" @click="toggleThemeMenu">
<span class="flex-center gap-10"><Palette :size="20" /> {{ t('theme.label') }}</span>
<component :is="isThemeOpen ? ChevronUp : ChevronDown" :size="16" />
</button>
<div v-if="isThemeOpen" class="mobile-sub-menu">
<button class="mobile-sub-item" @click="setTheme('system')">
<Monitor :size="16" /> {{ t('theme.system') }}
</button>
<button class="mobile-sub-item" @click="setTheme('light')">
<Sun :size="16" /> {{ t('theme.light') }}
</button>
<button class="mobile-sub-item" @click="setTheme('dark')">
<Moon :size="16" /> {{ t('theme.dark') }}
</button>
</div>
</div>
<!-- Mobile Guide -->
<div class="mobile-group">
<button class="mobile-item-trigger" @click="toggleGuide">
<span class="flex-center gap-10"><CircleHelp :size="20" /> {{ t('nav.guide') }}</span>
</button>
</div>
<!-- Mobile Language -->
<div class="mobile-group">
<button class="mobile-item-trigger" @click="toggleLangMenu">
<span class="flex-center gap-10">
<span class="lang-flag-current mobile-flag">
<span :class="getFlagClass(locale)"></span>
</span>
{{ t('language.label') }}
</span>
<component :is="isLangOpen ? ChevronUp : ChevronDown" :size="16" />
</button>
<div v-if="isLangOpen" class="mobile-sub-menu">
<div class="lang-search mobile-search">
<input
class="lang-search-input"
type="text"
:placeholder="t('language.searchPlaceholder')"
v-model="searchTerm"
@click.stop
/>
</div>
<div class="lang-list mobile-lang-list">
<button
v-for="lang in filteredLanguages"
:key="lang.code"
class="mobile-sub-item"
:class="{ active: locale === lang.code }"
@click="selectLanguage(lang.code)"
>
<span class="lang-flag-item">
<span :class="getFlagClass(lang.code)"></span>
</span>
<span class="lang-name">{{ lang.label }}</span>
</button>
</div>
</div>
</div>
</div>
</div>
</transition>
</nav>
</template>
<style scoped>
.navbar {
width: 100%;
padding: 15px 30px;
background: rgba(0, 0, 0, 0.2);
backdrop-filter: blur(10px);
border-bottom: 1px solid rgba(0, 242, 254, 0.1);
margin-bottom: 20px;
display: flex;
justify-content: space-between;
align-items: center;
z-index: 100;
position: sticky;
top: 0;
}
.nav-left {
display: flex;
align-items: center;
}
.app-title {
font-size: 1.8rem;
margin: 0;
letter-spacing: 3px;
font-weight: 300;
color: var(--text-strong);
text-shadow: 0 0 10px var(--title-glow);
}
.nav-container {
display: flex;
gap: 20px;
align-items: center;
}
.nav-dropdown {
position: relative;
}
.nav-btn {
display: flex;
align-items: center;
gap: 8px;
padding: 8px 20px;
font-size: 0.95rem;
min-width: 120px;
justify-content: center;
}
.nav-btn.icon-only {
min-width: auto;
padding: 8px 12px;
}
.nav-btn.flag-btn {
background: transparent;
border: none;
box-shadow: none;
padding: 0;
}
.nav-btn.flag-btn:hover {
background: transparent;
transform: scale(1.1);
}
.lang-flag-current img, .lang-flag-current svg {
box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
transition: box-shadow 0.3s ease;
}
.nav-btn.flag-btn:hover .lang-flag-current img,
.nav-btn.flag-btn:hover .lang-flag-current svg {
box-shadow: 0 0 15px var(--primary-neon);
}
.dropdown-menu {
position: absolute;
top: 100%;
right: 0;
margin-top: 10px;
background: rgba(10, 10, 20, 0.95);
border: 1px solid var(--primary-neon);
border-radius: 8px;
padding: 8px;
display: flex;
flex-direction: column;
gap: 5px;
min-width: 150px;
box-shadow: 0 0 20px rgba(0, 242, 254, 0.2);
z-index: 1000;
}
.lang-menu-dropdown {
width: 250px;
right: 0;
left: auto;
max-height: 400px;
overflow-y: auto;
}
.lang-search {
padding: 5px;
border-bottom: 1px solid rgba(255, 255, 255, 0.1);
margin-bottom: 5px;
}
.lang-search-input {
width: 100%;
background: rgba(255, 255, 255, 0.1);
border: 1px solid rgba(255, 255, 255, 0.2);
color: #fff;
padding: 5px 10px;
border-radius: 4px;
outline: none;
}
.lang-list {
display: flex;
flex-direction: column;
gap: 2px;
}
.dropdown-item {
background: transparent;
border: none;
color: #fff;
padding: 10px 15px;
cursor: pointer;
text-align: left;
border-radius: 4px;
transition: all 0.2s ease;
font-family: 'Segoe UI', sans-serif;
display: flex;
align-items: center;
gap: 10px;
width: 100%;
}
.dropdown-item:hover, .dropdown-item.active {
background: rgba(0, 242, 254, 0.15);
color: var(--primary-neon);
}
.icon {
font-size: 1.1rem;
}
.lang-flag-current img, .lang-flag-item img {
width: 24px;
height: 16px;
object-fit: cover;
border-radius: 2px;
display: block;
}
.lang-flag-current svg, .lang-flag-item svg {
width: 24px;
height: 16px;
display: block;
}
/* Helper */
.flex-center { display: flex; align-items: center; }
.gap-10 { gap: 10px; }
/* Desktop/Mobile Visibility */
.desktop-only { display: flex; }
.mobile-only { display: none; }
@media (max-width: 768px) {
.desktop-only { display: none; }
.mobile-only { display: flex; }
.navbar {
padding: 10px 20px;
}
}
/* Mobile Overlay */
.mobile-menu-overlay {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100vh;
background: rgba(10, 10, 25, 0.98);
backdrop-filter: blur(20px);
z-index: 10000;
display: flex;
flex-direction: column;
padding: 0;
overflow-y: auto;
}
.mobile-menu-header {
display: flex;
justify-content: space-between;
align-items: center;
padding: 10px 20px;
border-bottom: 1px solid rgba(0, 242, 254, 0.2);
flex-shrink: 0;
}
.mobile-title {
font-size: 1.8rem;
color: var(--primary-neon);
margin: 0;
letter-spacing: 3px;
font-weight: 300;
}
.mobile-menu-items {
display: flex;
flex-direction: column;
gap: 15px;
padding: 20px;
}
.mobile-group {
display: flex;
flex-direction: column;
border-bottom: 1px solid rgba(255, 255, 255, 0.05);
padding-bottom: 10px;
}
.mobile-item-trigger {
background: transparent;
border: none;
color: #fff;
font-size: 1.2rem;
padding: 15px 0;
text-align: left;
display: flex;
justify-content: space-between;
align-items: center;
width: 100%;
cursor: pointer;
text-transform: uppercase;
letter-spacing: 1px;
}
.mobile-sub-menu {
display: flex;
flex-direction: column;
gap: 10px;
padding-left: 15px;
padding-bottom: 10px;
animation: slideDown 0.3s ease-out;
}
.mobile-sub-item {
background: transparent;
border: none;
color: rgba(255, 255, 255, 0.7);
padding: 10px;
text-align: left;
font-size: 1rem;
cursor: pointer;
display: flex;
align-items: center;
gap: 10px;
border-radius: 4px;
}
.mobile-sub-item:hover, .mobile-sub-item.active {
color: var(--primary-neon);
background: rgba(0, 242, 254, 0.1);
}
.mobile-flag {
margin-right: 5px;
}
@keyframes slideDown {
from { opacity: 0; transform: translateY(-10px); }
to { opacity: 1; transform: translateY(0); }
}
.fade-enter-active,
.fade-leave-active {
transition: opacity 0.3s ease;
}
.fade-enter-from,
.fade-leave-to {
opacity: 0;
}
</style>

View File

@@ -0,0 +1,110 @@
<script setup>
import { useRegisterSW } from 'virtual:pwa-register/vue'
import { useI18n } from '@/composables/useI18n'
const { t } = useI18n()
const {
offlineReady,
needRefresh,
updateServiceWorker,
} = useRegisterSW()
const close = async () => {
offlineReady.value = false
needRefresh.value = false
}
</script>
<template>
<div
v-if="offlineReady || needRefresh"
class="pwa-toast"
role="alert"
>
<div class="message">
<span v-if="offlineReady">
{{ t('pwa.offlineReady') }}
</span>
<span v-else>
{{ t('pwa.newContent') }}
</span>
</div>
<div class="buttons">
<button v-if="needRefresh" class="btn-neon small" @click="updateServiceWorker()">
{{ t('pwa.reload') }}
</button>
<button class="close-btn" @click="close">
{{ t('pwa.close') }}
</button>
</div>
</div>
</template>
<style scoped>
.pwa-toast {
position: fixed;
right: 0;
bottom: 60px; /* Above the footer */
margin: 16px;
padding: 15px;
border: 1px solid var(--banner-border);
background: var(--banner-bg);
border-radius: 12px;
z-index: 2000;
text-align: left;
box-shadow: var(--banner-shadow);
display: flex;
flex-direction: column;
gap: 10px;
backdrop-filter: blur(10px);
color: var(--text-color);
max-width: 320px;
animation: slideIn 0.3s ease-out;
}
@keyframes slideIn {
from {
transform: translateY(20px);
opacity: 0;
}
to {
transform: translateY(0);
opacity: 1;
}
}
.message {
font-size: 0.95rem;
line-height: 1.4;
}
.buttons {
display: flex;
gap: 10px;
align-items: center;
justify-content: flex-end;
margin-top: 5px;
}
.close-btn {
background: transparent;
border: 1px solid var(--text-muted);
color: var(--text-muted);
padding: 6px 12px;
border-radius: 20px;
cursor: pointer;
font-size: 0.85rem;
transition: all 0.2s;
}
.close-btn:hover {
border-color: var(--text-color);
color: var(--text-color);
}
.btn-neon.small {
padding: 6px 16px;
font-size: 0.85rem;
}
</style>

View File

@@ -0,0 +1,320 @@
<script setup>
import { ref, computed } from 'vue';
import { generateRandomGrid, calculateHints } from '@/utils/puzzleUtils';
import { solvePuzzle } from '@/utils/solver';
import { useI18n } from '@/composables/useI18n';
import { X, Play, Square, RotateCcw } from 'lucide-vue-next';
const emit = defineEmits(['close']);
const { t } = useI18n();
const SIZES = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50];
const DENSITIES = [0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9];
const SAMPLES_PER_POINT = 10; // Reduced for web performance demo
const isRunning = ref(false);
const progress = ref(0);
const currentStatus = ref('');
const results = ref([]);
const simulationSpeed = ref(1); // 1 = Normal, 2 = Fast (less render updates)
let stopRequested = false;
const displayStatus = computed(() => {
if (!currentStatus.value) return t('simulation.status.ready');
return currentStatus.value;
});
const startSimulation = async () => {
if (isRunning.value) return;
isRunning.value = true;
stopRequested = false;
results.value = [];
progress.value = 0;
const totalSteps = SIZES.length * DENSITIES.length;
let stepCount = 0;
for (const size of SIZES) {
for (const density of DENSITIES) {
if (stopRequested) {
currentStatus.value = t('simulation.status.stopped');
isRunning.value = false;
return;
}
currentStatus.value = t('simulation.status.simulating', {
size: size,
density: (density * 100).toFixed(0)
});
let totalSolved = 0;
// Run samples
for (let i = 0; i < SAMPLES_PER_POINT; i++) {
const grid = generateRandomGrid(size, density);
const { rowHints, colHints } = calculateHints(grid);
const { percentSolved } = solvePuzzle(rowHints, colHints);
totalSolved += percentSolved;
// Yield to UI every few samples to keep it responsive
if (i % 2 === 0) await new Promise(r => setTimeout(r, 0));
}
const avgSolved = totalSolved / SAMPLES_PER_POINT;
results.value.unshift({
size,
density,
avgSolved: avgSolved.toFixed(1)
});
stepCount++;
progress.value = (stepCount / totalSteps) * 100;
}
}
isRunning.value = false;
currentStatus.value = t('simulation.status.completed');
};
const stopSimulation = () => {
stopRequested = true;
};
const getRowColor = (solved) => {
if (solved >= 90) return 'color-easy';
if (solved >= 60) return 'color-harder';
if (solved >= 30) return 'color-hardest';
return 'color-extreme';
};
</script>
<template>
<div class="modal-overlay" @click.self="emit('close')">
<div class="modal glass-panel">
<div class="header">
<h2>{{ t('simulation.title') }}</h2>
<button class="close-btn" @click="emit('close')">
<X />
</button>
</div>
<div class="content">
<div class="controls">
<div class="status-bar">
<div class="status-text">{{ displayStatus }}</div>
<div class="progress-track">
<div class="progress-fill" :style="{ width: progress + '%' }"></div>
</div>
</div>
<div class="actions">
<button v-if="!isRunning" class="btn-neon" @click="startSimulation">
<Play class="icon" /> {{ t('simulation.start') }}
</button>
<button v-else class="btn-neon secondary" @click="stopSimulation">
<Square class="icon" /> {{ t('simulation.stop') }}
</button>
</div>
</div>
<div class="results-container">
<table class="results-table">
<thead>
<tr>
<th>{{ t('simulation.table.size') }}</th>
<th>{{ t('simulation.table.density') }}</th>
<th>{{ t('simulation.table.solved') }}</th>
</tr>
</thead>
<tbody>
<tr v-for="(row, idx) in results" :key="idx" :class="getRowColor(row.avgSolved)">
<td>{{ row.size }}x{{ row.size }}</td>
<td>{{ (row.density * 100).toFixed(0) }}%</td>
<td>{{ row.avgSolved }}%</td>
</tr>
</tbody>
</table>
<div v-if="results.length === 0" class="empty-state">
{{ t('simulation.empty') }}
</div>
</div>
</div>
</div>
</div>
</template>
<style scoped>
.modal-overlay {
position: fixed;
top: 0;
left: 0;
width: 100vw;
height: 100vh;
background: var(--modal-overlay);
backdrop-filter: blur(5px);
display: flex;
justify-content: center;
align-items: center;
z-index: 3000;
animation: fadeIn 0.3s ease;
}
.modal {
padding: 30px;
width: 90%;
max-width: 600px;
height: 80vh;
display: flex;
flex-direction: column;
border: 1px solid var(--accent-cyan);
box-shadow: 0 0 50px rgba(0, 242, 255, 0.2);
}
.header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 20px;
}
h2 {
color: var(--accent-cyan);
margin: 0;
font-size: 1.5rem;
}
.close-btn {
background: none;
border: none;
color: var(--text-muted);
cursor: pointer;
padding: 5px;
}
.close-btn:hover {
color: var(--text-color);
}
.content {
flex: 1;
display: flex;
flex-direction: column;
gap: 20px;
overflow: hidden;
}
.controls {
display: flex;
flex-direction: column;
gap: 15px;
padding-bottom: 15px;
border-bottom: 1px solid var(--panel-border);
}
.status-bar {
display: flex;
flex-direction: column;
gap: 5px;
}
.status-text {
font-size: 0.9rem;
color: var(--text-muted);
}
.progress-track {
width: 100%;
height: 4px;
background: var(--panel-bg-strong);
border-radius: 2px;
overflow: hidden;
}
.progress-fill {
height: 100%;
background: var(--accent-cyan);
transition: width 0.3s ease;
}
.actions {
display: flex;
justify-content: flex-end;
}
.btn-neon {
display: flex;
align-items: center;
gap: 8px;
padding: 8px 16px;
font-size: 0.9rem;
}
.icon {
width: 16px;
height: 16px;
}
.results-container {
flex: 1;
overflow-y: auto;
background: rgba(0, 0, 0, 0.2);
border-radius: 8px;
padding: 10px;
}
.results-table {
width: 100%;
border-collapse: collapse;
font-size: 0.9rem;
}
.results-table th {
text-align: left;
padding: 8px;
color: var(--text-muted);
border-bottom: 1px solid var(--panel-border);
position: sticky;
top: 0;
background: var(--panel-bg);
}
.results-table td {
padding: 8px;
border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}
.color-easy { color: #33ff33; }
.color-harder { color: #ffff33; }
.color-hardest { color: #ff9933; }
.color-extreme { color: #ff3333; }
.empty-state {
padding: 40px;
text-align: center;
color: var(--text-muted);
font-style: italic;
}
/* Scrollbar styling */
.results-container::-webkit-scrollbar {
width: 8px;
}
.results-container::-webkit-scrollbar-track {
background: rgba(0, 0, 0, 0.1);
}
.results-container::-webkit-scrollbar-thumb {
background: var(--panel-border);
border-radius: 4px;
}
@keyframes fadeIn {
from { opacity: 0; }
to { opacity: 1; }
}
</style>

View File

@@ -2,9 +2,12 @@
import { computed } from 'vue'; import { computed } from 'vue';
import { usePuzzleStore } from '@/stores/puzzle'; import { usePuzzleStore } from '@/stores/puzzle';
import { useTimer } from '@/composables/useTimer'; import { useTimer } from '@/composables/useTimer';
import { useI18n } from '@/composables/useI18n';
import { RotateCcw, RefreshCw, Eye, Undo } from 'lucide-vue-next';
const store = usePuzzleStore(); const store = usePuzzleStore();
const { formatTime } = useTimer(); const { formatTime } = useTimer();
const { t } = useI18n();
const formattedTime = computed(() => formatTime(store.elapsedTime)); const formattedTime = computed(() => formatTime(store.elapsedTime));
const progressText = computed(() => `${store.progressPercentage.toFixed(3)}%`); const progressText = computed(() => `${store.progressPercentage.toFixed(3)}%`);
@@ -12,40 +15,66 @@ const progressText = computed(() => `${store.progressPercentage.toFixed(3)}%`);
<template> <template>
<div class="status-panel glass-panel"> <div class="status-panel glass-panel">
<div class="stats-group">
<div class="stat-item"> <div class="stat-item">
<span class="label">CZAS</span> <span class="label">{{ t('status.time') }}</span>
<span class="value">{{ formattedTime }}</span> <span class="value">{{ formattedTime }}</span>
</div> </div>
<div class="stat-item"> <div class="stat-item">
<span class="label">RUCHY</span> <span class="label">{{ t('status.moves') }}</span>
<span class="value">{{ store.moves }}</span> <span class="value">{{ store.moves }}</span>
</div> </div>
<div class="stat-item"> <div class="stat-item">
<span class="label">POSTĘP</span> <span class="label">{{ t('status.progress') }}</span>
<div class="progress-wrapper"> <div class="progress-wrapper">
<span class="value small">{{ progressText }}</span> <span class="value small">{{ progressText }}</span>
<span class="eye-icon">👁</span> <button class="eye-btn" :title="t('status.progress')">
<Eye :size="20" />
</button>
</div> </div>
</div> </div>
</div> </div>
<div class="panel-separator"></div>
<div class="actions-group">
<button class="action-btn" @click="store.resetGame" :title="t('actions.reset')">
<RefreshCw :size="20" />
</button>
<div class="action-separator"></div>
<button class="action-btn" @click="store.undo" :title="t('actions.undo')">
<Undo :size="20" />
</button>
</div>
</div>
</template> </template>
<style scoped> <style scoped>
.status-panel { .status-panel {
display: flex; display: flex;
justify-content: space-around; justify-content: space-between;
align-items: center; align-items: stretch;
padding: 20px 40px; padding: 0;
border-radius: 15px; border-radius: 15px;
background: rgba(255, 255, 255, 0.1); background: var(--panel-bg);
backdrop-filter: blur(10px); backdrop-filter: blur(10px);
border: 1px solid rgba(255, 255, 255, 0.1); border: 1px solid var(--panel-border);
box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2); box-shadow: var(--panel-shadow);
margin-bottom: 30px; margin-bottom: 30px;
width: 100%; width: 100%;
max-width: 600px; max-width: 650px;
overflow: hidden;
height: 90px;
}
.stats-group {
flex: 1;
display: flex;
justify-content: space-around;
align-items: center;
padding: 10px 20px;
} }
.stat-item { .stat-item {
@@ -58,13 +87,13 @@ const progressText = computed(() => `${store.progressPercentage.toFixed(3)}%`);
.label { .label {
font-size: 0.8rem; font-size: 0.8rem;
text-transform: uppercase; text-transform: uppercase;
color: rgba(255, 255, 255, 0.7); color: var(--text-muted);
letter-spacing: 1px; letter-spacing: 1px;
} }
.value { .value {
font-size: 1.8rem; font-size: 1.8rem;
color: #fff; color: var(--text-strong);
font-weight: 300; font-weight: 300;
font-family: 'Courier New', monospace; font-family: 'Courier New', monospace;
} }
@@ -79,8 +108,56 @@ const progressText = computed(() => `${store.progressPercentage.toFixed(3)}%`);
gap: 8px; gap: 8px;
} }
.eye-icon { .eye-btn {
background: transparent;
border: none;
color: var(--text-strong);
opacity: 0.7; opacity: 0.7;
cursor: pointer; cursor: pointer;
padding: 0;
display: flex;
align-items: center;
transition: opacity 0.2s;
}
.eye-btn:hover {
opacity: 1;
color: var(--primary-neon);
}
.panel-separator {
width: 1px;
background: rgba(255, 255, 255, 0.1);
margin: 10px 0;
}
.actions-group {
display: flex;
flex-direction: column;
width: 60px;
}
.action-btn {
flex: 1;
background: transparent;
border: none;
color: var(--text-strong);
cursor: pointer;
display: flex;
align-items: center;
justify-content: center;
transition: all 0.2s;
}
.action-btn:hover {
background: rgba(255, 255, 255, 0.1);
color: var(--primary-neon);
}
.action-separator {
height: 1px;
background: rgba(255, 255, 255, 0.1);
width: 80%;
align-self: center;
} }
</style> </style>

View File

@@ -1,11 +1,23 @@
<script setup> <script setup>
import { onMounted, onUnmounted, ref } from 'vue'; import { computed, onMounted, onUnmounted, ref } from 'vue';
import { Fireworks } from 'fireworks-js'; import { Fireworks } from 'fireworks-js';
import { usePuzzleStore } from '@/stores/puzzle'; import { usePuzzleStore } from '@/stores/puzzle';
import { useI18n } from '@/composables/useI18n';
import { useTimer } from '@/composables/useTimer';
import { Download, FileCode } from 'lucide-vue-next';
import { calculateDifficulty } from '@/utils/puzzleUtils';
const store = usePuzzleStore(); const store = usePuzzleStore();
const { t } = useI18n();
const { formatTime } = useTimer();
const fireworksRef = ref(null); const fireworksRef = ref(null);
let fireworksInstance = null; let fireworksInstance = null;
let audioContext = null;
let masterGain = null;
const shareInProgress = ref(false);
const formattedTime = computed(() => formatTime(store.elapsedTime));
const shareText = computed(() => t('win.shareText', { size: store.size, time: formattedTime.value }));
const handleClose = () => { const handleClose = () => {
store.closeWinModal(); store.closeWinModal();
@@ -17,6 +29,395 @@ const handleKeyDown = (e) => {
} }
}; };
const playFanfare = async () => {
const AudioCtx = window.AudioContext || window.webkitAudioContext;
if (!AudioCtx) return;
audioContext = new AudioCtx();
if (audioContext.state === 'suspended') {
try {
await audioContext.resume();
} catch {
return;
}
}
masterGain = audioContext.createGain();
masterGain.gain.value = 0.25; // Slightly louder but softer tone
masterGain.connect(audioContext.destination);
const now = audioContext.currentTime;
const playNote = (freq, startTime, duration) => {
const osc = audioContext.createOscillator();
const gain = audioContext.createGain();
// Mix of sine and triangle for a bell-like quality
osc.type = 'sine';
osc.frequency.value = freq;
// Envelope for elegant bell/chime sound
gain.gain.setValueAtTime(0, startTime);
gain.gain.linearRampToValueAtTime(0.4, startTime + 0.05); // Soft attack
gain.gain.exponentialRampToValueAtTime(0.01, startTime + duration); // Long release
osc.connect(gain);
gain.connect(masterGain);
osc.start(startTime);
osc.stop(startTime + duration + 0.1);
};
// C Major 7 Arpeggio sequence (C5, E5, G5, B5, C6) - Elegant & Uplifting
const sequence = [
{ freq: 523.25, time: 0.0, dur: 0.8 }, // C5
{ freq: 659.25, time: 0.1, dur: 0.8 }, // E5
{ freq: 783.99, time: 0.2, dur: 0.8 }, // G5
{ freq: 987.77, time: 0.3, dur: 0.8 }, // B5 (Maj7)
{ freq: 1046.50, time: 0.4, dur: 2.0 }, // C6 (High C resolve)
// Add a bass root note at the end for fullness
{ freq: 523.25, time: 0.4, dur: 2.0 } // C5
];
sequence.forEach(note => playNote(note.freq, now + note.time, note.dur));
};
const triggerVibration = () => {
if (!('vibrate' in navigator)) return;
const isCoarse = window.matchMedia?.('(pointer: coarse)')?.matches;
const isTouch = navigator.maxTouchPoints && navigator.maxTouchPoints > 0;
if (isCoarse || isTouch) {
navigator.vibrate([80, 40, 120, 40, 180]);
}
};
const buildShareCanvas = () => {
const grid = store.playerGrid;
if (!grid || !grid.length) return null;
const appUrl = 'https://nonograms.7u.pl/';
const size = store.size;
const maxBoard = 640;
const cellSize = Math.max(8, Math.floor(maxBoard / size));
const boardSize = cellSize * size;
const padding = 28;
const headerHeight = 64;
const footerHeight = 28;
const infoHeight = 40; // New space for difficulty/guide info
const width = boardSize + padding * 2;
const height = boardSize + padding * 2 + headerHeight + footerHeight + infoHeight;
const scale = window.devicePixelRatio || 1;
const canvas = document.createElement('canvas');
canvas.width = width * scale;
canvas.height = height * scale;
const ctx = canvas.getContext('2d');
if (!ctx) return null;
ctx.scale(scale, scale);
const bg = ctx.createLinearGradient(0, 0, width, height);
bg.addColorStop(0, '#1b2a4a');
bg.addColorStop(1, '#0a1324');
ctx.fillStyle = bg;
ctx.fillRect(0, 0, width, height);
ctx.fillStyle = 'rgba(0, 0, 0, 0.35)';
ctx.fillRect(12, 12, width - 24, height - 24);
ctx.fillStyle = '#e8fbff';
ctx.font = '700 26px "Segoe UI", sans-serif';
ctx.fillText(t('app.title'), padding, padding + 10);
ctx.font = '600 16px "Segoe UI", sans-serif';
ctx.fillText(`${t('win.time')} ${formattedTime.value}`, padding, padding + 34);
// Difficulty & Density Info
const densityPercent = Math.round(store.currentDensity * 100);
const difficultyKey = calculateDifficulty(store.currentDensity);
let diffColor = '#33ff33';
if (difficultyKey === 'extreme') diffColor = '#ff3333';
else if (difficultyKey === 'hardest') diffColor = '#ff9933';
else if (difficultyKey === 'harder') diffColor = '#ffff33';
const difficultyText = t(`difficulty.${difficultyKey}`);
ctx.font = '600 14px "Segoe UI", sans-serif';
// Right aligned difficulty info
const diffLabel = `${t('win.difficulty')} ${difficultyText} (${densityPercent}%)`;
const diffWidth = ctx.measureText(diffLabel).width;
ctx.fillStyle = diffColor;
ctx.fillText(diffLabel, width - padding - diffWidth, padding + 34);
const gridX = padding;
const gridY = padding + headerHeight;
ctx.fillStyle = 'rgba(255, 255, 255, 0.06)';
ctx.fillRect(gridX, gridY, boardSize, boardSize);
ctx.strokeStyle = 'rgba(255, 255, 255, 0.12)';
ctx.lineWidth = 1;
for (let i = 0; i <= size; i++) {
const x = gridX + i * cellSize;
const y = gridY + i * cellSize;
ctx.beginPath();
ctx.moveTo(x, gridY);
ctx.lineTo(x, gridY + boardSize);
ctx.stroke();
ctx.beginPath();
ctx.moveTo(gridX, y);
ctx.lineTo(gridX + boardSize, y);
ctx.stroke();
}
ctx.fillStyle = '#00f2fe';
ctx.strokeStyle = 'rgba(255, 255, 255, 0.5)';
ctx.lineWidth = Math.max(1.5, Math.floor(cellSize * 0.12));
for (let r = 0; r < size; r++) {
for (let c = 0; c < size; c++) {
const state = grid[r]?.[c];
if (state === 1) {
const x = gridX + c * cellSize + 1;
const y = gridY + r * cellSize + 1;
ctx.fillRect(x, y, cellSize - 2, cellSize - 2);
} else if (state === 2) {
const x = gridX + c * cellSize + cellSize * 0.2;
const y = gridY + r * cellSize + cellSize * 0.2;
const d = cellSize * 0.6;
ctx.beginPath();
ctx.moveTo(x, y);
ctx.lineTo(x + d, y + d);
ctx.stroke();
ctx.beginPath();
ctx.moveTo(x + d, y);
ctx.lineTo(x, y + d);
ctx.stroke();
}
}
}
// Guide Usage Info (Dirty Flag)
if (store.guideUsageCount > 0) {
ctx.fillStyle = '#ff4d4d';
ctx.font = '600 14px "Segoe UI", sans-serif';
const totalCells = store.size * store.size;
const percent = Math.min(100, Math.round((store.guideUsageCount / totalCells) * 100));
const guideText = t('win.usedGuide', { count: store.guideUsageCount, percent });
ctx.fillText(`⚠️ ${guideText}`, padding, height - padding - footerHeight + 10);
}
ctx.fillStyle = 'rgba(255, 255, 255, 0.75)';
ctx.font = '500 14px "Segoe UI", sans-serif';
ctx.fillText(appUrl, padding, height - padding + 6);
return canvas;
};
const buildShareSVG = () => {
const grid = store.playerGrid;
if (!grid || !grid.length) return null;
const appUrl = 'https://nonograms.7u.pl/';
const size = store.size;
const maxBoard = 640;
const cellSize = Math.max(8, Math.floor(maxBoard / size));
const boardSize = cellSize * size;
const padding = 28;
const headerHeight = 64;
const footerHeight = 28;
const infoHeight = 40;
const width = boardSize + padding * 2;
const height = boardSize + padding * 2 + headerHeight + footerHeight + infoHeight;
// Colors
const bgGradientStart = '#1b2a4a';
const bgGradientEnd = '#0a1324';
const overlayColor = 'rgba(0, 0, 0, 0.35)';
const textColor = '#e8fbff';
const gridColor = 'rgba(255, 255, 255, 0.06)';
const gridLineColor = 'rgba(255, 255, 255, 0.12)';
const filledColor = '#00f2fe';
const crossColor = 'rgba(255, 255, 255, 0.5)';
const urlColor = 'rgba(255, 255, 255, 0.75)';
// Difficulty Logic
const densityPercent = Math.round(store.currentDensity * 100);
const diffInfo = calculateDifficulty(store.currentDensity, store.size);
const difficultyKey = diffInfo.level;
let diffColor = '#33ff33';
if (difficultyKey === 'extreme') diffColor = '#ff3333';
else if (difficultyKey === 'hardest') diffColor = '#ff9933';
else if (difficultyKey === 'harder') diffColor = '#ffff33';
const difficultyText = t(`difficulty.${difficultyKey}`);
const diffLabel = `${t('win.difficulty')} ${difficultyText} (${densityPercent}%)`;
let svgContent = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${width} ${height}" width="${width}" height="${height}">`;
// Background
svgContent += `
<defs>
<linearGradient id="bg" x1="0%" y1="0%" x2="100%" y2="100%">
<stop offset="0%" stop-color="${bgGradientStart}"/>
<stop offset="100%" stop-color="${bgGradientEnd}"/>
</linearGradient>
</defs>
<rect width="100%" height="100%" fill="url(#bg)"/>
<rect x="12" y="12" width="${width - 24}" height="${height - 24}" fill="${overlayColor}"/>
`;
// Text: Title & Time
svgContent += `
<text x="${padding}" y="${padding + 28}" font-family="Segoe UI, sans-serif" font-weight="700" font-size="26" fill="${textColor}">${t('app.title')}</text>
<text x="${padding}" y="${padding + 56}" font-family="Segoe UI, sans-serif" font-weight="600" font-size="16" fill="${textColor}">${t('win.time')} ${formattedTime.value}</text>
`;
// Text: Difficulty (Right Aligned - manual approx or end anchor)
svgContent += `
<text x="${width - padding}" y="${padding + 56}" font-family="Segoe UI, sans-serif" font-weight="600" font-size="14" fill="${diffColor}" text-anchor="end">${diffLabel}</text>
`;
const gridX = padding;
const gridY = padding + headerHeight;
// Grid Background
svgContent += `<rect x="${gridX}" y="${gridY}" width="${boardSize}" height="${boardSize}" fill="${gridColor}"/>`;
// Grid Lines
let gridLines = '';
for (let i = 0; i <= size; i++) {
const pos = i * cellSize;
// Vertical
gridLines += `<line x1="${gridX + pos}" y1="${gridY}" x2="${gridX + pos}" y2="${gridY + boardSize}" stroke="${gridLineColor}" stroke-width="1"/>`;
// Horizontal
gridLines += `<line x1="${gridX}" y1="${gridY + pos}" x2="${gridX + boardSize}" y2="${gridY + pos}" stroke="${gridLineColor}" stroke-width="1"/>`;
}
svgContent += gridLines;
// Cells
let cells = '';
const lineWidth = Math.max(1.5, Math.floor(cellSize * 0.12));
for (let r = 0; r < size; r++) {
for (let c = 0; c < size; c++) {
const state = grid[r]?.[c];
const cx = gridX + c * cellSize;
const cy = gridY + r * cellSize;
if (state === 1) { // Filled
cells += `<rect x="${cx + 1}" y="${cy + 1}" width="${cellSize - 2}" height="${cellSize - 2}" fill="${filledColor}"/>`;
} else if (state === 2) { // Cross
const d = cellSize * 0.6;
const off = cellSize * 0.2;
cells += `
<path d="M${cx + off} ${cy + off} L${cx + off + d} ${cy + off + d} M${cx + off + d} ${cy + off} L${cx + off} ${cy + off + d}"
stroke="${crossColor}" stroke-width="${lineWidth}" stroke-linecap="round"/>
`;
}
}
}
svgContent += cells;
// Guide Usage
if (store.guideUsageCount > 0) {
const totalCells = store.size * store.size;
const percent = Math.min(100, Math.round((store.guideUsageCount / totalCells) * 100));
const guideText = t('win.usedGuide', { count: store.guideUsageCount, percent });
svgContent += `<text x="${padding}" y="${height - padding - footerHeight + 10}" font-family="Segoe UI, sans-serif" font-weight="600" font-size="14" fill="#ff4d4d">⚠️ ${guideText}</text>`;
}
// URL
svgContent += `<text x="${padding}" y="${height - padding + 6}" font-family="Segoe UI, sans-serif" font-weight="500" font-size="14" fill="${urlColor}">${appUrl}</text>`;
svgContent += '</svg>';
return svgContent;
};
const canvasToBlob = (canvas) => new Promise((resolve) => canvas.toBlob((blob) => resolve(blob), 'image/png'));
const createShareBlob = async () => {
const canvas = buildShareCanvas();
if (!canvas) return null;
return canvasToBlob(canvas);
};
const downloadShareSVG = () => {
const svgString = buildShareSVG();
if (!svgString) return;
const blob = new Blob([svgString], { type: 'image/svg+xml' });
const url = URL.createObjectURL(blob);
const link = document.createElement('a');
link.href = url;
link.download = `nonogram-${store.size}x${store.size}.svg`;
document.body.appendChild(link);
link.click();
link.remove();
URL.revokeObjectURL(url);
};
const downloadShareImage = async () => {
const blob = await createShareBlob();
if (!blob) return;
const url = URL.createObjectURL(blob);
const link = document.createElement('a');
link.href = url;
link.download = `nonogram-${store.size}x${store.size}.png`;
document.body.appendChild(link);
link.click();
link.remove();
URL.revokeObjectURL(url);
};
const buildShareUrl = (target, text, url) => {
const encodedText = encodeURIComponent(text);
const encodedUrl = encodeURIComponent(url);
if (target === 'x') {
return `https://x.com/intent/tweet?text=${encodedText}&url=${encodedUrl}`;
}
if (target === 'facebook') {
return `https://www.facebook.com/sharer/sharer.php?u=${encodedUrl}&quote=${encodedText}`;
}
if (target === 'whatsapp') {
return `https://wa.me/?text=${encodeURIComponent(`${text} ${url}`)}`;
}
return '';
};
const shareTo = async (target) => {
if (shareInProgress.value) return;
shareInProgress.value = true;
const text = shareText.value;
const url = window.location.href;
const shareUrl = buildShareUrl(target, text, url);
try {
// Try native share first if available (supports images)
if (navigator.share && navigator.canShare) {
const blob = await createShareBlob();
if (blob) {
const file = new File([blob], `nonogram-${store.size}x${store.size}.png`, { type: 'image/png' });
if (navigator.canShare({ files: [file] })) {
await navigator.share({
files: [file],
text,
title: t('app.title'),
url
});
return;
}
}
}
} catch (error) {
if (error.name === 'AbortError') {
return; // User cancelled native share, do nothing
}
// Other errors -> fall through to fallback
} finally {
shareInProgress.value = false;
}
// Fallback: Direct Link + Download
// Open window immediately if possible (though we awaited above, so it might be blocked,
// but we can't do much about it if we want to try native share first).
// Ideally, for Desktop, navigator.share is undefined so we skip the await above.
if (shareUrl) {
window.open(shareUrl, '_blank', 'noopener');
}
// Trigger download as "screenshot support"
downloadShareImage();
};
onMounted(() => { onMounted(() => {
if (fireworksRef.value) { if (fireworksRef.value) {
fireworksInstance = new Fireworks(fireworksRef.value, { fireworksInstance = new Fireworks(fireworksRef.value, {
@@ -37,6 +438,8 @@ onMounted(() => {
}); });
fireworksInstance.start(); fireworksInstance.start();
} }
playFanfare();
triggerVibration();
window.addEventListener('keydown', handleKeyDown); window.addEventListener('keydown', handleKeyDown);
}); });
@@ -44,6 +447,14 @@ onUnmounted(() => {
window.removeEventListener('keydown', handleKeyDown); window.removeEventListener('keydown', handleKeyDown);
fireworksInstance?.stop(true); fireworksInstance?.stop(true);
fireworksInstance = null; fireworksInstance = null;
if ('vibrate' in navigator) {
navigator.vibrate(0);
}
if (audioContext) {
audioContext.close();
audioContext = null;
}
masterGain = null;
}); });
</script> </script>
@@ -51,18 +462,44 @@ onUnmounted(() => {
<div class="modal-overlay" @click.self="handleClose"> <div class="modal-overlay" @click.self="handleClose">
<div ref="fireworksRef" class="fireworks-layer"></div> <div ref="fireworksRef" class="fireworks-layer"></div>
<div class="modal glass-panel"> <div class="modal glass-panel">
<h2>GRATULACJE!</h2> <h2>{{ t('win.title') }}</h2>
<p>Rozwiązałeś zagadkę!</p> <p>{{ t('win.message') }}</p>
<div class="stats"> <div class="stats">
<div class="stat"> <div class="stat">
<span>Czas:</span> <span>{{ t('win.time') }}</span>
<strong>{{ store.elapsedTime }}s</strong> <strong>{{ formattedTime }}</strong>
</div>
</div>
<div class="share">
<div class="share-title">{{ t('win.shareTitle') }}</div>
<div class="share-buttons">
<!-- X (Twitter) -->
<button class="btn-neon secondary share-btn" :disabled="shareInProgress" :aria-label="t('win.shareX')" @click="shareTo('x')">
<svg viewBox="0 0 24 24" fill="currentColor" class="share-icon"><path d="M18.901 3H22l-7.21 8.26L23 21h-6.66L11.13 14.76 5.66 21H2.56l7.73-8.83L1 3h6.8l4.63 5.56L18.9 3h.001zm-1.2 15.9h1.77L6.44 5.1H4.44l13.26 13.8z"/></svg>
</button>
<!-- Facebook -->
<button class="btn-neon secondary share-btn" :disabled="shareInProgress" :aria-label="t('win.shareFacebook')" @click="shareTo('facebook')">
<svg viewBox="0 0 24 24" fill="currentColor" class="share-icon"><path d="M24 12.073c0-6.627-5.373-12-12-12s-12 5.373-12 12c0 5.99 4.388 10.954 10.125 11.854v-8.385H7.078v-3.47h3.047V9.43c0-3.007 1.791-4.669 4.533-4.669 1.312 0 2.686.235 2.686.235v2.953H15.83c-1.491 0-1.956.925-1.956 1.874v2.25h3.328l-.532 3.47h-2.796v8.385C19.612 23.027 24 18.062 24 12.073z"/></svg>
</button>
<!-- WhatsApp -->
<button class="btn-neon secondary share-btn" :disabled="shareInProgress" :aria-label="t('win.shareWhatsapp')" @click="shareTo('whatsapp')">
<svg viewBox="0 0 24 24" fill="currentColor" class="share-icon"><path d="M17.472 14.382c-.297-.149-1.758-.867-2.03-.967-.273-.099-.471-.148-.67.15-.197.297-.767.966-.94 1.164-.173.199-.347.223-.644.075-.297-.15-1.255-.463-2.39-1.475-.883-.788-1.48-1.761-1.653-2.059-.173-.297-.018-.458.13-.606.134-.133.298-.347.446-.52.149-.174.198-.298.298-.497.099-.198.05-.371-.025-.52-.075-.149-.669-1.612-.916-2.207-.242-.579-.487-.5-.669-.51-.173-.008-.371-.008-.57-.008-.198 0-.52.074-.792.372-.272.297-1.04 1.016-1.04 2.479 0 1.462 1.065 2.875 1.213 3.074.149.198 2.096 3.2 5.077 4.487.709.306 1.262.489 1.694.625.712.227 1.36.195 1.871.118.571-.085 1.758-.719 2.006-1.413.248-.694.248-1.289.173-1.413-.074-.124-.272-.198-.57-.347m-5.421 7.403h-.004a9.87 9.87 0 01-5.031-1.378l-.361-.214-3.741.982.998-3.648-.235-.374a9.86 9.86 0 01-1.51-5.26c.001-5.45 4.436-9.884 9.888-9.884 2.64 0 5.122 1.03 6.988 2.898a9.825 9.825 0 012.893 6.994c-.003 5.45-4.437 9.884-9.885 9.884m8.413-18.297A11.815 11.815 0 0012.05 0C5.495 0 .16 5.335.157 11.892c0 2.096.547 4.142 1.588 5.945L.057 24l6.305-1.654a11.882 11.882 0 005.683 1.448h.005c6.554 0 11.89-5.335 11.893-11.893a11.821 11.821 0 00-3.48-8.413Z"/></svg>
</button>
<!-- Download Screenshot (Compact) -->
<button class="btn-neon secondary share-btn" :disabled="shareInProgress" :aria-label="t('win.shareDownload')" @click="downloadShareImage">
<Download :size="20" />
</button>
<!-- Download SVG (Compact) -->
<button class="btn-neon secondary share-btn" :disabled="shareInProgress" aria-label="Download SVG" @click="downloadShareSVG">
<FileCode :size="20" />
</button>
</div> </div>
</div> </div>
<div class="actions"> <div class="actions">
<button class="btn-neon" @click="store.resetGame">Zagraj Ponownie</button> <button class="btn-neon" @click="store.resetGame">{{ t('win.playAgain') }}</button>
</div> </div>
</div> </div>
</div> </div>
@@ -75,7 +512,7 @@ onUnmounted(() => {
left: 0; left: 0;
width: 100vw; width: 100vw;
height: 100vh; height: 100vh;
background: rgba(0, 0, 0, 0.7); background: var(--modal-overlay);
backdrop-filter: blur(5px); backdrop-filter: blur(5px);
display: flex; display: flex;
justify-content: center; justify-content: center;
@@ -96,13 +533,15 @@ onUnmounted(() => {
.modal { .modal {
padding: 40px; padding: 40px;
text-align: center; text-align: center;
max-width: 400px; width: fit-content;
width: 90%; max-width: min(92vw, 560px);
min-width: 280px;
border: 1px solid var(--primary-accent); border: 1px solid var(--primary-accent);
box-shadow: 0 0 50px rgba(0, 242, 255, 0.2); box-shadow: 0 0 50px rgba(0, 242, 255, 0.2);
animation: slideUp 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275); animation: slideUp 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
position: relative; position: relative;
z-index: 1001; z-index: 1001;
overflow-wrap: anywhere;
} }
h2 { h2 {
@@ -110,18 +549,20 @@ h2 {
color: var(--primary-accent); color: var(--primary-accent);
margin: 0 0 10px 0; margin: 0 0 10px 0;
text-shadow: 0 0 20px var(--primary-accent); text-shadow: 0 0 20px var(--primary-accent);
overflow-wrap: anywhere;
} }
p { p {
color: var(--text-secondary); color: var(--text-secondary);
font-size: 1.2rem; font-size: 1.2rem;
margin-bottom: 30px; margin-bottom: 30px;
overflow-wrap: anywhere;
} }
.stats { .stats {
margin-bottom: 30px; margin-bottom: 30px;
padding: 20px; padding: 20px;
background: rgba(0, 0, 0, 0.3); background: var(--panel-bg-strong);
border-radius: 8px; border-radius: 8px;
} }
@@ -130,10 +571,62 @@ p {
} }
.stat strong { .stat strong {
color: #fff; color: var(--text-strong);
margin-left: 10px; margin-left: 10px;
} }
.share {
margin-bottom: 24px;
display: flex;
flex-direction: column;
gap: 12px;
}
.share-title {
font-size: 0.95rem;
letter-spacing: 1px;
text-transform: uppercase;
color: var(--text-muted);
overflow-wrap: anywhere;
}
.share-buttons {
display: flex;
flex-wrap: wrap;
gap: 10px;
justify-content: center;
}
.share-btn {
width: 44px;
height: 44px;
padding: 0;
border-radius: 50%;
display: inline-flex;
align-items: center;
justify-content: center;
}
.share-icon {
width: 22px;
height: 22px;
display: block;
}
.share-download {
align-self: center;
padding: 8px 18px;
font-size: 0.85rem;
max-width: 100%;
white-space: normal;
}
.actions .btn-neon {
max-width: 100%;
white-space: normal;
}
@keyframes fadeIn { @keyframes fadeIn {
from { opacity: 0; } from { opacity: 0; }
to { opacity: 1; } to { opacity: 1; }

6436
src/composables/useI18n.js Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -8,7 +8,7 @@ export function useNonogram() {
const dragMode = ref(null); // 'fill', 'empty', 'cross' const dragMode = ref(null); // 'fill', 'empty', 'cross'
const startCellState = ref(null); const startCellState = ref(null);
const startDrag = (r, c, isRightClick = false) => { const startDrag = (r, c, isRightClick = false, force = false) => {
if (store.isGameWon) return; if (store.isGameWon) return;
isDragging.value = true; isDragging.value = true;
@@ -16,9 +16,7 @@ export function useNonogram() {
if (isRightClick) { if (isRightClick) {
// Right click logic // Right click logic
// If current is 1 (filled), do nothing usually? Or ignore? if (!force && current === 1) {
// Standard: Toggle 0 <-> 2
if (current === 1) {
dragMode.value = null; // invalid drag start dragMode.value = null; // invalid drag start
return; return;
} }
@@ -46,6 +44,7 @@ export function useNonogram() {
}; };
const stopDrag = () => { const stopDrag = () => {
store.endInteraction();
isDragging.value = false; isDragging.value = false;
dragMode.value = null; dragMode.value = null;
}; };

View File

@@ -1,15 +1,17 @@
import { ref, computed, onUnmounted } from 'vue'; import { ref, computed, onUnmounted } from 'vue';
import { usePuzzleStore } from '@/stores/puzzle'; import { usePuzzleStore } from '@/stores/puzzle';
import { useI18n } from '@/composables/useI18n';
export function useSolver() { export function useSolver() {
const store = usePuzzleStore(); const store = usePuzzleStore();
const { t, locale } = useI18n();
const isPlaying = ref(false); const isPlaying = ref(false);
const isProcessing = ref(false); const isProcessing = ref(false);
const speedIndex = ref(0); const speedIndex = ref(0);
const speeds = [1000, 500, 250, 125]; const speeds = [1000, 500, 250, 125, 62];
const speedLabels = ['x1', 'x2', 'x3', 'x4']; const speedLabels = ['x1', 'x2', 'x4', 'x8', 'x16'];
const statusText = ref('Oczekiwanie...'); const statusText = ref(t('guide.waiting'));
let intervalId = null; let intervalId = null;
let worker = null; let worker = null;
@@ -18,17 +20,18 @@ export function useSolver() {
function step() { function step() {
if (store.isGameWon) { if (store.isGameWon) {
pause(); pause();
statusText.value = "Rozwiązane!"; statusText.value = t('guide.solved');
return; return;
} }
if (isProcessing.value) return; if (isProcessing.value) return;
store.markGuideUsed();
ensureWorker(); ensureWorker();
isProcessing.value = true; isProcessing.value = true;
const playerGrid = store.playerGrid.map(row => row.slice()); const playerGrid = store.playerGrid.map(row => row.slice());
const solution = store.solution.map(row => row.slice()); const solution = store.solution.map(row => row.slice());
const id = ++requestId; const id = ++requestId;
worker.postMessage({ id, playerGrid, solution }); worker.postMessage({ id, playerGrid, solution, locale: locale.value });
} }
function togglePlay() { function togglePlay() {
@@ -75,6 +78,9 @@ export function useSolver() {
} else if (type === 'done') { } else if (type === 'done') {
isProcessing.value = false; isProcessing.value = false;
pause(); pause();
} else if (type === 'stuck') {
isProcessing.value = false;
pause();
} else { } else {
isProcessing.value = false; isProcessing.value = false;
} }

View File

@@ -1,6 +1,7 @@
import { createApp } from 'vue' import { createApp } from 'vue'
import { createPinia } from 'pinia' import { createPinia } from 'pinia'
import App from './App.vue' import App from './App.vue'
import '/node_modules/flag-icons/css/flag-icons.min.css'
import './styles/main.css' import './styles/main.css'
// Custom directive v-cell-hover (zgodnie z wymaganiami) // Custom directive v-cell-hover (zgodnie z wymaganiami)
@@ -29,3 +30,4 @@ app.use(createPinia())
app.directive('cell-hover', vCellHover) app.directive('cell-hover', vCellHover)
app.mount('#app') app.mount('#app')

View File

@@ -63,6 +63,10 @@ export const usePuzzleStore = defineStore('puzzle', () => {
const solution = ref([]); const solution = ref([]);
const playerGrid = ref([]); // 0: empty, 1: filled, 2: cross const playerGrid = ref([]); // 0: empty, 1: filled, 2: cross
const isGameWon = ref(false); const isGameWon = ref(false);
const hasUsedGuide = ref(false);
const guideUsageCount = ref(0);
const currentDifficulty = ref(null); // 'easy', 'medium', 'hard', 'custom' or object { density: 0.5 }
const currentDensity = ref(0);
const size = ref(5); const size = ref(5);
const startTime = ref(null); const startTime = ref(null);
const elapsedTime = ref(0); const elapsedTime = ref(0);
@@ -71,6 +75,7 @@ export const usePuzzleStore = defineStore('puzzle', () => {
// History for undo // History for undo
const history = ref([]); const history = ref([]);
const currentTransaction = ref(null);
// Progress State // Progress State
const totalCellsToFill = computed(() => { const totalCellsToFill = computed(() => {
@@ -116,40 +121,69 @@ export const usePuzzleStore = defineStore('puzzle', () => {
resetGrid(); resetGrid();
isGameWon.value = false; isGameWon.value = false;
hasUsedGuide.value = false;
guideUsageCount.value = 0;
currentDensity.value = totalCellsToFill.value / (size.value * size.value);
elapsedTime.value = 0; elapsedTime.value = 0;
startTimer(); startTimer();
saveState();
} }
function initCustomGame(customSize) { function initCustomGame(customSize, density = 0.5) {
stopTimer(); stopTimer();
currentLevelId.value = 'custom'; currentLevelId.value = 'custom';
size.value = customSize; size.value = customSize;
// Generate random grid // Generate random grid
solution.value = generateRandomGrid(customSize); solution.value = generateRandomGrid(customSize, density);
resetGrid(); resetGrid();
isGameWon.value = false; isGameWon.value = false;
hasUsedGuide.value = false;
guideUsageCount.value = 0;
currentDensity.value = density;
elapsedTime.value = 0; elapsedTime.value = 0;
startTimer(); startTimer();
saveState();
} }
function resetGrid() { function resetGrid() {
playerGrid.value = Array(size.value).fill().map(() => Array(size.value).fill(0)); playerGrid.value = Array(size.value).fill().map(() => Array(size.value).fill(0));
moves.value = 0; moves.value = 0;
history.value = []; history.value = [];
currentTransaction.value = null;
} }
function pushHistory() { function startInteraction() {
const gridCopy = playerGrid.value.map(row => [...row]); currentTransaction.value = [];
history.value.push(gridCopy); }
function endInteraction() {
if (currentTransaction.value && currentTransaction.value.length > 0) {
history.value.push(currentTransaction.value);
if (history.value.length > 50) history.value.shift(); if (history.value.length > 50) history.value.shift();
saveState();
}
currentTransaction.value = null;
} }
function undo() { function undo() {
if (history.value.length === 0 || isGameWon.value) return; if (history.value.length === 0 || isGameWon.value) return;
const previousState = history.value.pop();
playerGrid.value = previousState; const transaction = history.value.pop();
// Handle legacy history (full grid snapshot)
if (!Array.isArray(transaction) || (transaction.length > 0 && Array.isArray(transaction[0]))) {
playerGrid.value = transaction;
} else {
// Handle new history (list of changes)
// Revert changes in reverse order
for (let i = transaction.length - 1; i >= 0; i--) {
const { r, c, oldVal } = transaction[i];
playerGrid.value[r][c] = oldVal;
}
}
moves.value++; moves.value++;
saveState(); saveState();
} }
@@ -157,8 +191,6 @@ export const usePuzzleStore = defineStore('puzzle', () => {
function toggleCell(r, c, isRightClick = false) { function toggleCell(r, c, isRightClick = false) {
if (isGameWon.value) return; if (isGameWon.value) return;
pushHistory();
const currentState = playerGrid.value[r][c]; const currentState = playerGrid.value[r][c];
let newState; let newState;
@@ -170,20 +202,48 @@ export const usePuzzleStore = defineStore('puzzle', () => {
newState = currentState === 1 ? 0 : 1; newState = currentState === 1 ? 0 : 1;
} }
playerGrid.value[r][c] = newState; // This triggers reactivity if (currentState === newState) return;
// Apply change
playerGrid.value[r][c] = newState;
// Record history
const change = { r, c, oldVal: currentState, newVal: newState };
if (currentTransaction.value) {
currentTransaction.value.push(change);
} else {
// Atomic change if no interaction started
history.value.push([change]);
if (history.value.length > 50) history.value.shift();
saveState();
}
moves.value++; moves.value++;
checkWin(); checkWin();
saveState(); // saveState(); // Moved to endInteraction or atomic block
} }
function setCell(r, c, state) { function setCell(r, c, state) {
if (isGameWon.value) return; if (isGameWon.value) return;
if (playerGrid.value[r][c] !== state) { const currentState = playerGrid.value[r][c];
pushHistory();
if (currentState !== state) {
// Apply change
playerGrid.value[r][c] = state; playerGrid.value[r][c] = state;
// Record history
const change = { r, c, oldVal: currentState, newVal: state };
if (currentTransaction.value) {
currentTransaction.value.push(change);
} else {
history.value.push([change]);
if (history.value.length > 50) history.value.shift();
saveState();
}
moves.value++; moves.value++;
checkWin(); checkWin();
saveState(); // saveState(); // Moved to endInteraction or atomic block
} }
} }
@@ -238,6 +298,9 @@ export const usePuzzleStore = defineStore('puzzle', () => {
solution: solution.value, solution: solution.value,
playerGrid: playerGrid.value, playerGrid: playerGrid.value,
isGameWon: isGameWon.value, isGameWon: isGameWon.value,
hasUsedGuide: hasUsedGuide.value,
guideUsageCount: guideUsageCount.value,
currentDensity: currentDensity.value,
elapsedTime: elapsedTime.value, elapsedTime: elapsedTime.value,
moves: moves.value, moves: moves.value,
history: history.value history: history.value
@@ -255,6 +318,9 @@ export const usePuzzleStore = defineStore('puzzle', () => {
solution.value = parsed.solution; solution.value = parsed.solution;
playerGrid.value = parsed.playerGrid; playerGrid.value = parsed.playerGrid;
isGameWon.value = parsed.isGameWon; isGameWon.value = parsed.isGameWon;
hasUsedGuide.value = parsed.hasUsedGuide || false;
guideUsageCount.value = parsed.guideUsageCount || 0;
currentDensity.value = parsed.currentDensity || 0;
elapsedTime.value = parsed.elapsedTime || 0; elapsedTime.value = parsed.elapsedTime || 0;
moves.value = parsed.moves || 0; moves.value = parsed.moves || 0;
history.value = parsed.history || []; history.value = parsed.history || [];
@@ -271,44 +337,9 @@ export const usePuzzleStore = defineStore('puzzle', () => {
return false; return false;
} }
function initGame(levelId = 'easy') { // Duplicate initGame removed
// 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(); // Duplicate initCustomGame removed
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();
}
// 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 toggleCell/setCell removed // Duplicate toggleCell/setCell removed
@@ -316,6 +347,8 @@ export const usePuzzleStore = defineStore('puzzle', () => {
if (currentLevelId.value === 'custom') { if (currentLevelId.value === 'custom') {
resetGrid(); resetGrid();
isGameWon.value = false; isGameWon.value = false;
hasUsedGuide.value = false;
guideUsageCount.value = 0;
elapsedTime.value = 0; elapsedTime.value = 0;
startTimer(); startTimer();
saveState(); saveState();
@@ -324,6 +357,13 @@ export const usePuzzleStore = defineStore('puzzle', () => {
} }
} }
function markGuideUsed() {
if (isGameWon.value) return;
hasUsedGuide.value = true;
guideUsageCount.value++;
saveState();
}
function closeWinModal() { function closeWinModal() {
if (!isGameWon.value) return; if (!isGameWon.value) return;
isGameWon.value = false; isGameWon.value = false;
@@ -347,7 +387,13 @@ export const usePuzzleStore = defineStore('puzzle', () => {
loadState, // expose loadState loadState, // expose loadState
moves, moves,
undo, undo,
closeWinModal closeWinModal,
hasUsedGuide,
guideUsageCount,
currentDensity,
markGuideUsed,
startInteraction,
endInteraction
}; };
}); });

View File

@@ -1,3 +1,5 @@
@import './scrollbar.css';
:root { :root {
/* --- Glassmorphism Design System --- */ /* --- Glassmorphism Design System --- */
--bg-gradient: linear-gradient(135deg, #43C6AC 0%, #191654 100%); --bg-gradient: linear-gradient(135deg, #43C6AC 0%, #191654 100%);
@@ -5,12 +7,56 @@
--glass-border: rgba(255, 255, 255, 0.2); --glass-border: rgba(255, 255, 255, 0.2);
--glass-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.37); --glass-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.37);
--text-color: #ffffff; --text-color: #ffffff;
--text-strong: #ffffff;
--text-secondary: rgba(255, 255, 255, 0.85);
--text-muted: rgba(255, 255, 255, 0.7);
--accent-cyan: #00f2fe; --accent-cyan: #00f2fe;
--accent-purple: #4facfe; --accent-purple: #4facfe;
--primary-accent: #00f2fe;
--cell-empty: rgba(255, 255, 255, 0.05); --cell-empty: rgba(255, 255, 255, 0.05);
--cell-hover: rgba(255, 255, 255, 0.2); --cell-hover: rgba(255, 255, 255, 0.2);
--cell-filled-gradient: linear-gradient(45deg, #00f2fe, #4facfe); --cell-filled-gradient: linear-gradient(45deg, #00f2fe, #4facfe);
--cell-x-color: rgba(255, 255, 255, 0.4); --cell-x-color: rgba(255, 255, 255, 0.4);
--title-glow: rgba(0, 255, 255, 0.2);
--toggle-bg: rgba(255, 255, 255, 0.08);
--toggle-border: rgba(255, 255, 255, 0.2);
--toggle-shadow: 0 0 15px rgba(0, 0, 0, 0.2);
--toggle-btn-border: rgba(255, 255, 255, 0.2);
--toggle-hover-border: #ffffff;
--toggle-active-shadow: 0 0 10px rgba(0, 242, 255, 0.3);
--banner-bg: rgba(0, 0, 0, 0.35);
--banner-border: rgba(0, 242, 254, 0.35);
--banner-shadow: 0 8px 30px rgba(0, 0, 0, 0.25);
--panel-bg: rgba(255, 255, 255, 0.1);
--panel-border: rgba(255, 255, 255, 0.1);
--panel-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
--panel-bg-strong: rgba(0, 0, 0, 0.3);
--modal-overlay: rgba(0, 0, 0, 0.7);
--fixed-bar-bg: rgba(0, 0, 0, 0.85);
--fixed-bar-border: rgba(255, 255, 255, 0.1);
--fixed-bar-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
--progress-track-bg: rgba(255, 255, 255, 0.1);
--hint-bg: rgba(255, 255, 255, 0.05);
--hint-border: rgba(255, 255, 255, 0.1);
--hint-hover-bg: rgba(255, 255, 255, 0.1);
--button-bg: rgba(255, 255, 255, 0.1);
--button-border: rgba(255, 255, 255, 0.2);
--button-text: #ffffff;
--button-hover-bg: rgba(255, 255, 255, 0.25);
--button-hover-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
--button-active-shadow: 0 0 20px rgba(79, 172, 254, 0.4);
--button-secondary-bg: rgba(0, 0, 0, 0.2);
--button-secondary-border: rgba(255, 255, 255, 0.1);
--button-secondary-text: rgba(255, 255, 255, 0.8);
--button-secondary-hover-bg: rgba(255, 255, 255, 0.1);
--button-secondary-hover-border: #ffffff;
--button-secondary-hover-text: #ffffff;
--scroll-track: rgba(0, 0, 0, 0.1);
--scroll-thumb: rgba(255, 255, 255, 0.2);
--scroll-thumb-hover: var(--accent-cyan);
--fixed-bar-bg: rgba(0, 0, 0, 0.85);
--fixed-bar-thumb: rgba(0, 242, 255, 0.5);
--fixed-bar-thumb-hover: rgba(0, 242, 255, 0.8);
/* Rozmiary */ /* Rozmiary */
--cell-size: 30px; --cell-size: 30px;
@@ -19,12 +65,75 @@
--grid-padding: 5px; --grid-padding: 5px;
} }
:root[data-theme="light"] {
--bg-gradient: linear-gradient(135deg, #f7fbff 0%, #dde7ff 100%);
--glass-bg: rgba(255, 255, 255, 0.75);
--glass-border: rgba(15, 23, 42, 0.12);
--glass-shadow: 0 8px 32px 0 rgba(15, 23, 42, 0.12);
--text-color: #0f172a;
--text-strong: #0f172a;
--text-secondary: rgba(15, 23, 42, 0.7);
--text-muted: rgba(15, 23, 42, 0.6);
--accent-cyan: #0ea5e9;
--accent-purple: #6366f1;
--primary-accent: #0ea5e9;
--cell-empty: rgba(15, 23, 42, 0.05);
--cell-hover: rgba(15, 23, 42, 0.12);
--cell-filled-gradient: linear-gradient(45deg, #0ea5e9, #6366f1);
--cell-x-color: rgba(15, 23, 42, 0.35);
--title-glow: rgba(14, 165, 233, 0.35);
--toggle-bg: rgba(255, 255, 255, 0.85);
--toggle-border: rgba(15, 23, 42, 0.12);
--toggle-shadow: 0 8px 20px rgba(15, 23, 42, 0.12);
--toggle-btn-border: rgba(15, 23, 42, 0.18);
--toggle-hover-border: rgba(15, 23, 42, 0.5);
--toggle-active-shadow: 0 0 12px rgba(14, 165, 233, 0.25);
--banner-bg: rgba(255, 255, 255, 0.8);
--banner-border: rgba(14, 165, 233, 0.35);
--banner-shadow: 0 12px 28px rgba(15, 23, 42, 0.16);
--panel-bg: rgba(255, 255, 255, 0.7);
--panel-border: rgba(15, 23, 42, 0.12);
--panel-shadow: 0 12px 24px rgba(15, 23, 42, 0.12);
--panel-bg-strong: rgba(15, 23, 42, 0.08);
--modal-overlay: rgba(15, 23, 42, 0.45);
--fixed-bar-bg: rgba(248, 250, 255, 0.95);
--fixed-bar-border: rgba(15, 23, 42, 0.12);
--fixed-bar-shadow: 0 8px 24px rgba(15, 23, 42, 0.18);
--progress-track-bg: rgba(15, 23, 42, 0.08);
--hint-bg: rgba(255, 255, 255, 0.7);
--hint-border: rgba(15, 23, 42, 0.12);
--hint-hover-bg: rgba(15, 23, 42, 0.06);
--button-bg: rgba(255, 255, 255, 0.85);
--button-border: rgba(15, 23, 42, 0.16);
--button-text: #0f172a;
--button-hover-bg: rgba(255, 255, 255, 1);
--button-hover-shadow: 0 6px 18px rgba(15, 23, 42, 0.18);
--button-active-shadow: 0 0 18px rgba(14, 165, 233, 0.25);
--button-secondary-bg: rgba(15, 23, 42, 0.06);
--button-secondary-border: rgba(15, 23, 42, 0.2);
--button-secondary-text: rgba(15, 23, 42, 0.8);
--button-secondary-hover-bg: rgba(15, 23, 42, 0.12);
--button-secondary-hover-border: rgba(15, 23, 42, 0.5);
--button-secondary-hover-text: #0f172a;
--scroll-track: rgba(15, 23, 42, 0.08);
--scroll-thumb: rgba(15, 23, 42, 0.2);
--scroll-thumb-hover: #0ea5e9;
--fixed-bar-bg: rgba(248, 250, 255, 0.95);
--fixed-bar-thumb: rgba(14, 165, 233, 0.5);
--fixed-bar-thumb-hover: rgba(14, 165, 233, 0.8);
}
* { * {
box-sizing: border-box; box-sizing: border-box;
user-select: none; user-select: none;
-webkit-user-select: none; -webkit-user-select: none;
} }
html {
overflow-x: hidden;
width: 100%;
}
body { body {
margin: 0; margin: 0;
padding: 20px; padding: 20px;
@@ -60,9 +169,9 @@ body {
/* Button Styles */ /* Button Styles */
button.btn-neon { button.btn-neon {
background: rgba(255, 255, 255, 0.1); background: var(--button-bg);
border: 1px solid rgba(255, 255, 255, 0.2); border: 1px solid var(--button-border);
color: #fff; color: var(--button-text);
padding: 12px 24px; padding: 12px 24px;
font-size: 0.95rem; font-size: 0.95rem;
border-radius: 30px; border-radius: 30px;
@@ -79,21 +188,21 @@ button.btn-neon {
} }
button.btn-neon:hover { button.btn-neon:hover {
background: rgba(255, 255, 255, 0.25); background: var(--button-hover-bg);
transform: translateY(-2px); transform: translateY(-2px);
box-shadow: 0 5px 15px rgba(0,0,0,0.2); box-shadow: var(--button-hover-shadow);
} }
button.btn-neon.active { button.btn-neon.active {
background: linear-gradient(90deg, var(--accent-cyan), var(--accent-purple)); background: linear-gradient(90deg, var(--accent-cyan), var(--accent-purple));
border-color: transparent; border-color: transparent;
box-shadow: 0 0 20px rgba(79, 172, 254, 0.4); box-shadow: var(--button-active-shadow);
font-weight: 700; font-weight: 700;
} }
button.btn-neon.secondary { button.btn-neon.secondary {
border-color: rgba(255, 255, 255, 0.1); border-color: var(--button-secondary-border);
background: rgba(0,0,0,0.2); background: var(--button-secondary-bg);
} }
/* Scrollbar */ /* Scrollbar */
@@ -101,14 +210,14 @@ button.btn-neon.secondary {
width: 8px; width: 8px;
} }
::-webkit-scrollbar-track { ::-webkit-scrollbar-track {
background: rgba(0,0,0,0.1); background: var(--scroll-track);
} }
::-webkit-scrollbar-thumb { ::-webkit-scrollbar-thumb {
background: rgba(255,255,255,0.2); background: var(--scroll-thumb);
border-radius: 4px; border-radius: 4px;
} }
::-webkit-scrollbar-thumb:hover { ::-webkit-scrollbar-thumb:hover {
background: var(--accent-cyan); background: var(--scroll-thumb-hover);
} }
/* Animations */ /* Animations */

54
src/styles/scrollbar.css Normal file
View File

@@ -0,0 +1,54 @@
/* Fixed Scroll Bar */
.fixed-scroll-bar {
position: fixed;
bottom: 15px;
left: 50%;
transform: translateX(-50%);
width: 85%;
max-width: 400px;
height: 44px; /* Increased hit area */
background: transparent;
display: flex;
align-items: center;
justify-content: center;
z-index: 1000;
opacity: 0;
animation: fadeIn 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
pointer-events: none;
}
@keyframes fadeIn {
from { opacity: 0; transform: translateX(-50%) translateY(10px); }
to { opacity: 1; transform: translateX(-50%) translateY(0); }
}
.fixed-scroll-track {
width: 100%;
height: 14px; /* Increased visual thickness */
background: rgba(15, 23, 42, 0.4);
backdrop-filter: blur(4px);
-webkit-backdrop-filter: blur(4px);
border-radius: 7px;
position: relative;
pointer-events: auto;
border: 1px solid rgba(255, 255, 255, 0.15);
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
}
.fixed-scroll-thumb {
position: absolute;
top: 0;
height: 100%;
background: var(--primary-accent);
border-radius: 7px;
cursor: grab;
box-shadow: 0 0 12px rgba(0, 242, 255, 0.5);
transition: background 0.2s ease, box-shadow 0.2s ease;
}
.fixed-scroll-thumb:active {
cursor: grabbing;
background: #fff;
box-shadow: 0 0 15px rgba(255, 255, 255, 0.6);
}

View File

@@ -40,15 +40,91 @@ export function calculateHints(grid) {
return { rowHints, colHints }; return { rowHints, colHints };
} }
export function generateRandomGrid(size) { export function generateRandomGrid(size, density = 0.5) {
const grid = []; const grid = [];
for (let i = 0; i < size; i++) { for (let i = 0; i < size; i++) {
const row = []; const row = [];
for (let j = 0; j < size; j++) { for (let j = 0; j < size; j++) {
// ~50% chance of being filled row.push(Math.random() < density ? 1 : 0);
row.push(Math.random() > 0.5 ? 1 : 0);
} }
grid.push(row); grid.push(row);
} }
return grid; return grid;
} }
export function calculateDifficulty(density, size = 10) {
// Data derived from Monte Carlo Simulation (Logical Solver)
// Format: { size: [solved_pct_at_0.1, ..., solved_pct_at_0.9] }
// Densities: 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9
const SIM_DATA = {
5: [89, 74, 74, 81, 97, 98, 99, 100, 100],
10: [57, 20, 16, 54, 92, 100, 100, 100, 100],
15: [37, 10, 2, 12, 68, 100, 100, 100, 100],
20: [23, 3, 1, 2, 37, 100, 100, 100, 100],
25: [16, 0, 0, 1, 19, 99, 100, 100, 100],
30: [8, 0, 0, 0, 5, 99, 100, 100, 100],
35: [6, 0, 0, 0, 4, 91, 100, 100, 100],
40: [3, 0, 0, 0, 2, 91, 100, 100, 100],
45: [2, 0, 0, 0, 1, 82, 100, 100, 100],
50: [2, 0, 0, 0, 1, 73, 100, 100, 100],
60: [0, 0, 0, 0, 0, 35, 100, 100, 100],
70: [0, 0, 0, 0, 0, 16, 100, 100, 100],
80: [0, 0, 0, 0, 0, 1, 100, 100, 100]
};
// Helper to get interpolated value from array
const getSimulatedSolvedPct = (s, d) => {
// Find closest sizes
const sizes = Object.keys(SIM_DATA).map(Number).sort((a, b) => a - b);
let sLower = sizes[0];
let sUpper = sizes[sizes.length - 1];
for (let i = 0; i < sizes.length - 1; i++) {
if (s >= sizes[i] && s <= sizes[i+1]) {
sLower = sizes[i];
sUpper = sizes[i+1];
break;
}
}
// Clamp density to 0.1 - 0.9
const dClamped = Math.max(0.1, Math.min(0.9, d));
// Index in array: 0.1 -> 0, 0.9 -> 8
const dIndex = (dClamped - 0.1) * 10;
const dLowerIdx = Math.floor(dIndex);
const dUpperIdx = Math.ceil(dIndex);
const dFraction = dIndex - dLowerIdx;
// Bilinear Interpolation
// 1. Interpolate Density for Lower Size
const rowLower = SIM_DATA[sLower];
const valLower = rowLower[dLowerIdx] * (1 - dFraction) + (rowLower[dUpperIdx] || rowLower[dLowerIdx]) * dFraction;
// 2. Interpolate Density for Upper Size
const rowUpper = SIM_DATA[sUpper];
const valUpper = rowUpper[dLowerIdx] * (1 - dFraction) + (rowUpper[dUpperIdx] || rowUpper[dLowerIdx]) * dFraction;
// 3. Interpolate Size
if (sLower === sUpper) return valLower;
const sFraction = (s - sLower) / (sUpper - sLower);
return valLower * (1 - sFraction) + valUpper * sFraction;
};
const solvedPct = getSimulatedSolvedPct(size, density);
// Difficulty Score: Inverse of Solved Percent
// 100% Solved -> 0 Difficulty
// 0% Solved -> 100 Difficulty
const value = Math.round(100 - solvedPct);
// Thresholds
let level = 'easy';
if (value >= 90) level = 'extreme'; // < 10% Solved
else if (value >= 60) level = 'hardest'; // < 40% Solved
else if (value >= 30) level = 'harder'; // < 70% Solved
else level = 'easy'; // > 70% Solved
return { level, value };
}

View File

@@ -0,0 +1,51 @@
import { describe, it, expect } from 'vitest'
import { calculateHints } from './puzzleUtils'
describe('puzzleUtils', () => {
it('calculateHints correctly calculates hints for a simple grid', () => {
const grid = [
[1, 0, 1],
[1, 1, 1],
[0, 1, 0]
]
// Row 0: 1, then space, then 1 -> [1, 1]
// Row 1: 1, 1, 1 -> [3]
// Row 2: space, 1, space -> [1]
// Col 0: 1, 1, 0 -> [2]
// Col 1: 0, 1, 1 -> [2] ? Wait. Col 1 is 0, 1, 1. So space, 1, 1 -> [2].
// Let's trace col 1 manually:
// r0,c1 = 0
// r1,c1 = 1 -> count=1
// r2,c1 = 1 -> count=2
// end -> push 2.
// So Col 1 is [2].
// Wait, my manual trace above for col 1:
// grid[0][1] is 0.
// grid[1][1] is 1.
// grid[2][1] is 1.
// Yes, [2].
// Col 2: 1, 1, 0 -> [2].
const expected = {
rowHints: [[1, 1], [3], [1]],
colHints: [[2], [2], [2]]
}
expect(calculateHints(grid)).toEqual(expected)
})
it('calculateHints handles empty rows/cols', () => {
const grid = [
[0, 0, 0],
[0, 0, 0],
[0, 0, 0]
]
const expected = {
rowHints: [[0], [0], [0]],
colHints: [[0], [0], [0]]
}
expect(calculateHints(grid)).toEqual(expected)
})
})

278
src/utils/solver.js Normal file
View File

@@ -0,0 +1,278 @@
/**
* Represents the state of a cell in the solver.
* -1: Unknown
* 0: Empty
* 1: Filled
*/
/**
* Solves a single line (row or column) based on hints and current knowledge.
* Uses the "Left-Right Overlap" algorithm to find common filled cells.
* Also identifies definitely empty cells (reachable by no block).
*
* @param {number[]} currentLine - Array of -1, 0, 1
* @param {number[]} hints - Array of block lengths
* @returns {number[]} - Updated line (or null if contradiction/impossible - though shouldn't happen for valid puzzles)
*/
function solveLine(currentLine, hints) {
const length = currentLine.length;
// If no hints, all must be empty
if (hints.length === 0 || (hints.length === 1 && hints[0] === 0)) {
return Array(length).fill(0);
}
// Helper to check if a block can be placed at start index
const canPlace = (line, start, blockSize) => {
if (start + blockSize > line.length) return false;
// Check if any cell in block is 0 (Empty) -> Invalid
for (let i = start; i < start + blockSize; i++) {
if (line[i] === 0) return false;
}
// Check boundaries (must be separated by empty or edge)
if (start > 0 && line[start - 1] === 1) return false;
if (start + blockSize < line.length && line[start + blockSize] === 1) return false;
return true;
};
// 1. Calculate Left-Most Positions
const leftPositions = [];
let currentIdx = 0;
for (let hIndex = 0; hIndex < hints.length; hIndex++) {
const block = hints[hIndex];
// Find first valid position
while (currentIdx <= length - block) {
if (canPlace(currentLine, currentIdx, block)) {
// Verify we can fit remaining blocks
// Simple heuristic: do we have enough space?
// A full recursive check is better but slower.
// For "Logical Solver" we assume valid placement is possible if we respect current constraints.
// However, strictly, we need to know if there is *any* valid arrangement starting here.
// Let's use a recursive check with memoization for "can fit rest".
if (canFitRest(currentLine, currentIdx + block + 1, hints, hIndex + 1)) {
leftPositions.push(currentIdx);
currentIdx += block + 1; // Move past this block + 1 space
break;
}
}
currentIdx++;
}
if (leftPositions.length <= hIndex) return null; // Impossible
}
// 2. Calculate Right-Most Positions (by reversing line and hints)
// This is symmetrical to Left-Most.
// Instead of implementing reverse logic, we can just reverse inputs, run left-most, and reverse back.
// But we need to respect the "currentLine" constraints which might be asymmetric.
// Actually, "Right-Most" is just "Left-Most" on the reversed grid.
const reversedLine = [...currentLine].reverse();
const reversedHints = [...hints].reverse();
const rightPositionsReversed = [];
currentIdx = 0;
for (let hIndex = 0; hIndex < reversedHints.length; hIndex++) {
const block = reversedHints[hIndex];
while (currentIdx <= length - block) {
if (canPlace(reversedLine, currentIdx, block)) {
if (canFitRest(reversedLine, currentIdx + block + 1, reversedHints, hIndex + 1)) {
rightPositionsReversed.push(currentIdx);
currentIdx += block + 1;
break;
}
}
currentIdx++;
}
if (rightPositionsReversed.length <= hIndex) return null;
}
// Convert reversed positions to actual indices
// index in reversed = length - 1 - (original_index + block_size - 1)
// original_start = length - 1 - (reversed_start + block_size - 1) = length - reversed_start - block_size
const rightPositions = rightPositionsReversed.map((rStart, i) => {
const block = reversedHints[i];
return length - rStart - block;
}).reverse();
// 3. Intersect
const newLine = [...currentLine];
// Fill intersection
for (let i = 0; i < hints.length; i++) {
const l = leftPositions[i];
const r = rightPositions[i];
const block = hints[i];
// If overlap exists: [r, l + block - 1]
// Example: Block 5. Left: 2, Right: 4.
// Left: ..XXXXX...
// Right: ....XXXXX.
// Overlap: ..XXX...
// Indices: max(l, r) to min(l+block, r+block) - 1 ?
// Range is [r, l + block - 1] (inclusive)
if (r < l + block) {
for (let k = r; k < l + block; k++) {
newLine[k] = 1;
}
}
}
// Determine Empty cells?
// A cell is empty if it is not covered by ANY block in ANY valid configuration.
// This is harder with just L/R limits.
// However, we can use the "Simple Glue" logic:
// If a cell is outside the range [LeftLimit[i], RightLimit[i] + block] for ALL i, it's empty.
// Wait, indices are not strictly partitioned. Block 1 could be at 0 or 10.
// But logic dictates order.
// Range of block i is [LeftPositions[i], RightPositions[i] + hints[i]].
// If a cell k is not in ANY of these ranges, it is 0.
// Mask of possible filled cells
const possibleFilled = Array(length).fill(false);
for (let i = 0; i < hints.length; i++) {
for (let k = leftPositions[i]; k < rightPositions[i] + hints[i]; k++) {
possibleFilled[k] = true;
}
}
for (let k = 0; k < length; k++) {
if (!possibleFilled[k]) {
newLine[k] = 0;
}
}
return newLine;
}
// Memoized helper for checking if hints fit
const memo = new Map();
function canFitRest(line, startIndex, hints, hintIndex) {
// Optimization: If hints are empty, we just need to check if remaining line has no '1's
if (hintIndex >= hints.length) {
for (let i = startIndex; i < line.length; i++) {
if (line[i] === 1) return false;
}
return true;
}
// Key for memoization (primitive approach)
// In a full solver, we'd pass a cache. For single line, maybe overkill, but safe.
// let key = `${startIndex}-${hintIndex}`;
// Skipping memo for now as line lengths are small (<80) and recursion depth is low.
const remainingLen = line.length - startIndex;
// Min space needed: sum of hints + (hints.length - 1) spaces
// Calculate lazily or precalc?
let minSpace = 0;
for(let i=hintIndex; i<hints.length; i++) minSpace += hints[i] + (i < hints.length - 1 ? 1 : 0);
if (remainingLen < minSpace) return false;
const block = hints[hintIndex];
// Try to find *any* valid placement for this block
// We only need ONE valid path to return true.
for (let i = startIndex; i <= line.length - minSpace; i++) { // Optimization on upper bound?
// Check placement
let valid = true;
// Block
for (let k = 0; k < block; k++) {
if (line[i+k] === 0) { valid = false; break; }
}
if (!valid) continue;
// Boundary before (checked by loop start usually, but strictly:
if (i > 0 && line[i-1] === 1) valid = false; // Should have been handled by caller or skip
// Wait, the caller (loop) iterates i.
// If i > startIndex, we implied space at i-1.
// If line[i-1] is 1, we can't place here if we skipped it.
// Actually, if we skip a '1', that's invalid.
// So we can't just skip '1's.
// Correct logic:
// We iterate i. If we pass a '1' at index < i, that 1 is orphaned -> Invalid path.
// So we can only scan forward as long as we don't skip a '1'.
let skippedOne = false;
for (let x = startIndex; x < i; x++) {
if (line[x] === 1) { skippedOne = true; break; }
}
if (skippedOne) break; // Cannot go further right, we left a 1 behind.
// Boundary after
if (i + block < line.length && line[i+block] === 1) valid = false;
if (valid) {
// Recurse
if (canFitRest(line, i + block + 1, hints, hintIndex + 1)) return true;
}
}
return false;
}
/**
* Solves the puzzle using logical iteration.
* @param {number[][]} rowHints
* @param {number[][]} colHints
* @returns {object} { solvedGrid: number[][], percentSolved: number }
*/
export function solvePuzzle(rowHints, colHints) {
const rows = rowHints.length;
const cols = colHints.length;
// Initialize grid with -1
let grid = Array(rows).fill(null).map(() => Array(cols).fill(-1));
let changed = true;
let iterations = 0;
const MAX_ITER = 100; // Safety break
while (changed && iterations < MAX_ITER) {
changed = false;
iterations++;
// Rows
for (let r = 0; r < rows; r++) {
const newLine = solveLine(grid[r], rowHints[r]);
if (newLine) {
for (let c = 0; c < cols; c++) {
if (grid[r][c] !== newLine[c]) {
grid[r][c] = newLine[c];
changed = true;
}
}
}
}
// Cols
for (let c = 0; c < cols; c++) {
const currentCol = grid.map(row => row[c]);
const newCol = solveLine(currentCol, colHints[c]);
if (newCol) {
for (let r = 0; r < rows; r++) {
if (grid[r][c] !== newCol[r]) {
grid[r][c] = newCol[r];
changed = true;
}
}
}
}
}
// Calculate solved %
let solvedCount = 0;
for (let r = 0; r < rows; r++) {
for (let c = 0; c < cols; c++) {
if (grid[r][c] !== -1) solvedCount++;
}
}
return {
solvedGrid: grid,
percentSolved: (solvedCount / (rows * cols)) * 100
};
}

View File

@@ -1,60 +1,233 @@
import { calculateHints } from '../utils/puzzleUtils.js'; import { calculateHints } from '../utils/puzzleUtils.js';
const getPermutations = (length, hints) => { const messages = {
const results = []; pl: {
const recurse = (index, hintIndex, currentLine) => { 'worker.solved': 'Rozwiązane!',
if (hintIndex === hints.length) { 'worker.logicRow': 'Logika: Wiersz {row}, Kolumna {col} -> {state}',
while (currentLine.length < length) { 'worker.logicCol': 'Logika: Kolumna {col}, Wiersz {row} -> {state}',
currentLine.push(0); 'worker.stuck': 'Brak logicznego ruchu. Spróbuj zgadnąć lub cofnąć.',
'worker.done': 'Koniec!',
'worker.state.filled': 'Pełne',
'worker.state.empty': 'Puste'
},
en: {
'worker.solved': 'Solved!',
'worker.logicRow': 'Logic: Row {row}, Column {col} -> {state}',
'worker.logicCol': 'Logic: Column {col}, Row {row} -> {state}',
'worker.stuck': 'No logical move found. Try guessing or undoing.',
'worker.done': 'Done!',
'worker.state.filled': 'Filled',
'worker.state.empty': 'Empty'
} }
results.push(currentLine); };
return;
const resolveLocale = (value) => {
if (!value) return 'en';
const short = String(value).toLowerCase().split('-')[0];
return short === 'pl' ? 'pl' : 'en';
};
const format = (text, params = {}) => {
return text.replace(/\{(\w+)\}/g, (_, key) => {
const value = params[key];
return value === undefined ? `{${key}}` : String(value);
});
};
const t = (locale, key, params) => {
const lang = messages[locale] || messages.en;
const value = lang[key] || messages.en[key] || key;
return typeof value === 'string' ? format(value, params) : key;
};
const buildPrefix = (lineState) => {
const n = lineState.length;
const filled = new Array(n + 1).fill(0);
const cross = new Array(n + 1).fill(0);
for (let i = 0; i < n; i++) {
filled[i + 1] = filled[i] + (lineState[i] === 1 ? 1 : 0);
cross[i + 1] = cross[i] + (lineState[i] === 2 ? 1 : 0);
}
return { filled, cross };
};
const buildSuffixMin = (hints) => {
const m = hints.length;
const suffixMin = new Array(m + 1).fill(0);
let sumHints = 0;
for (let i = m - 1; i >= 0; i--) {
sumHints += hints[i];
const separators = m - i - 1;
suffixMin[i] = sumHints + separators;
}
return suffixMin;
};
const solveLineLogic = (lineState, hints) => {
const n = lineState.length;
const m = hints.length;
if (m === 0) {
for (let i = 0; i < n; i++) {
if (lineState[i] === 0) return { index: i, state: 2 };
}
return { index: -1 };
} }
const currentHint = hints[hintIndex]; const { filled, cross } = buildPrefix(lineState);
let remainingHintsLen = 0; const suffixMin = buildSuffixMin(hints);
for (let i = hintIndex + 1; i < hints.length; i++) remainingHintsLen += hints[i] + 1;
const maxStart = length - remainingHintsLen - currentHint;
for (let start = index; start <= maxStart; start++) { const hasFilled = (a, b) => filled[b] - filled[a] > 0;
const newLine = [...currentLine]; const hasCross = (a, b) => cross[b] - cross[a] > 0;
for (let k = index; k < start; k++) newLine.push(0);
for (let k = 0; k < currentHint; k++) newLine.push(1); const memoSuffix = Array.from({ length: n + 1 }, () => Array(m + 1).fill(null));
if (hintIndex < hints.length - 1) newLine.push(0); const memoPrefix = Array.from({ length: n + 1 }, () => Array(m + 1).fill(null));
recurse(newLine.length, hintIndex + 1, newLine);
const canPlaceSuffix = (pos, hintIndex) => {
const cached = memoSuffix[pos][hintIndex];
if (cached !== null) return cached;
if (hintIndex === m) {
const result = !hasFilled(pos, n);
memoSuffix[pos][hintIndex] = result;
return result;
} }
const len = hints[hintIndex];
// maxStart logic: we need enough space for this block (len) + subsequent blocks/gaps (suffixMin[hintIndex+1])
// suffixMin[hintIndex] = len + (m - hintIndex - 1) + suffixMin[hintIndex+1]
// Actually suffixMin[hintIndex] already includes everything needed from here to end.
// So if we place block at start, end is start + len.
// Total space needed is suffixMin[hintIndex].
// So start can go up to n - suffixMin[hintIndex].
const maxStart = n - suffixMin[hintIndex];
for (let start = pos; start <= maxStart; start++) {
if (hasFilled(pos, start)) continue; // Must be empty before this block
if (hasCross(start, start + len)) continue; // Block space must be free of crosses
// If not the last block, we need a gap after
if (hintIndex < m - 1) {
if (start + len < n && lineState[start + len] === 1) continue; // Gap must not be filled
// We can assume gap is at start + len. Next block starts at least at start + len + 1
const nextPos = start + len + 1;
if (canPlaceSuffix(nextPos, hintIndex + 1)) {
memoSuffix[pos][hintIndex] = true;
return true;
}
} else {
// Last block
// Check if we can fill the rest with empty
if (hasFilled(start + len, n)) continue;
memoSuffix[pos][hintIndex] = true;
return true;
}
}
memoSuffix[pos][hintIndex] = false;
return false;
}; };
recurse(0, 0, []); const canPlacePrefix = (pos, hintCount) => {
return results; const cached = memoPrefix[pos][hintCount];
}; if (cached !== null) return cached;
if (hintCount === 0) {
const isValidPermutation = (perm, currentLineState) => { const result = !hasFilled(0, pos);
for (let i = 0; i < perm.length; i++) { memoPrefix[pos][hintCount] = result;
const boardVal = currentLineState[i]; return result;
const permVal = perm[i];
if (boardVal === 1 && permVal !== 1) return false;
if (boardVal === 2 && permVal !== 0) return false;
} }
const len = hints[hintCount - 1];
// Logic for prefix:
// We are placing the (hintCount-1)-th block ending at 'start + len' <= pos.
// So 'start' <= pos - len.
// But we also need to ensure there is space for previous blocks.
// However, the simple constraint is just iterating backwards.
// maxStart: if this is the only block, maxStart = pos - len.
// If there are previous blocks, we need a gap before this block.
// So previous block ended at start - 1.
// Actually the recursive call will handle space check.
// But for the gap check:
// If we place block at 'start', we need lineState[start-1] != 1 (if start > 0).
// And we recursively check canPlacePrefix(start-1, count-1).
// But if start=0 and count > 1, impossible.
const maxStart = pos - len; // Simplified, loop condition handles rest
for (let start = maxStart; start >= 0; start--) {
if (hasCross(start, start + len)) continue;
if (hasFilled(start + len, pos)) continue; // Must be empty after this block up to pos
// Check gap before
if (hintCount > 1) {
if (start === 0) continue; // No space for previous blocks
if (lineState[start - 1] === 1) continue; // Gap must not be filled
const prevPos = start - 1;
if (canPlacePrefix(prevPos, hintCount - 1)) {
memoPrefix[pos][hintCount] = true;
return true; return true;
};
const solveLineLogic = (lineState, hints, size) => {
const allPerms = getPermutations(size, hints);
const validPerms = allPerms.filter(p => isValidPermutation(p, lineState));
if (validPerms.length === 0) return { index: -1 };
for (let i = 0; i < size; i++) {
if (lineState[i] !== 0) continue;
let allOne = true;
let allZero = true;
for (const p of validPerms) {
if (p[i] === 0) allOne = false;
if (p[i] === 1) allZero = false;
if (!allOne && !allZero) break;
} }
if (allOne) return { index: i, state: 1 }; } else {
if (allZero) return { index: i, state: 2 }; // First block
if (hasFilled(0, start)) continue; // Before first block must be empty
memoPrefix[pos][hintCount] = true;
return true;
}
}
memoPrefix[pos][hintCount] = false;
return false;
};
const possibleStarts = [];
for (let i = 0; i < m; i++) {
const len = hints[i];
const starts = [];
for (let start = 0; start <= n - len; start++) {
if (i === 0) {
if (!canPlacePrefix(start, 0)) continue;
} else {
if (start === 0) continue;
if (lineState[start - 1] === 1) continue;
if (!canPlacePrefix(start - 1, i)) continue;
}
if (hasCross(start, start + len)) continue;
if (start + len < n && lineState[start + len] === 1) continue;
const nextPos = start + len < n ? start + len + 1 : start + len;
if (!canPlaceSuffix(nextPos, i + 1)) continue;
starts.push(start);
}
possibleStarts.push(starts);
}
const mustFill = new Array(n).fill(false);
const coverage = new Array(n).fill(false);
for (let i = 0; i < m; i++) {
const starts = possibleStarts[i];
const len = hints[i];
if (starts.length === 0) return { index: -1 };
let earliest = starts[0];
let latest = starts[0];
for (let j = 1; j < starts.length; j++) {
earliest = Math.min(earliest, starts[j]);
latest = Math.max(latest, starts[j]);
}
const startOverlap = Math.max(earliest, latest);
const endOverlap = Math.min(earliest + len - 1, latest + len - 1);
for (let k = startOverlap; k <= endOverlap; k++) {
if (k >= 0 && k < n) mustFill[k] = true;
}
for (let s = 0; s < starts.length; s++) {
const start = starts[s];
for (let k = start; k < start + len; k++) {
coverage[k] = true;
}
}
}
for (let i = 0; i < n; i++) {
if (lineState[i] === 0 && mustFill[i]) return { index: i, state: 1 };
}
for (let i = 0; i < n; i++) {
if (lineState[i] === 0 && !coverage[i]) return { index: i, state: 2 };
} }
return { index: -1 }; return { index: -1 };
}; };
@@ -73,9 +246,9 @@ const isSolved = (grid, solution) => {
return true; return true;
}; };
const handleStep = (playerGrid, solution) => { const handleStep = (playerGrid, solution, locale) => {
if (isSolved(playerGrid, solution)) { if (isSolved(playerGrid, solution)) {
return { type: 'done', statusText: 'Rozwiązane!' }; return { type: 'done', statusText: t(locale, 'worker.solved') };
} }
const size = solution.length; const size = solution.length;
@@ -84,14 +257,15 @@ const handleStep = (playerGrid, solution) => {
for (let r = 0; r < size; r++) { for (let r = 0; r < size; r++) {
const rowLine = playerGrid[r]; const rowLine = playerGrid[r];
const hints = rowHints[r]; const hints = rowHints[r];
const result = solveLineLogic(rowLine, hints, size); const result = solveLineLogic(rowLine, hints);
if (result.index !== -1) { if (result.index !== -1) {
const stateLabel = t(locale, result.state === 1 ? 'worker.state.filled' : 'worker.state.empty');
return { return {
type: 'move', type: 'move',
r, r,
c: result.index, c: result.index,
state: result.state, state: result.state,
statusText: `Logika: Wiersz ${r + 1}, Kolumna ${result.index + 1} -> ${result.state === 1 ? 'Pełne' : 'Puste'}` statusText: t(locale, 'worker.logicRow', { row: r + 1, col: result.index + 1, state: stateLabel })
}; };
} }
} }
@@ -100,45 +274,27 @@ const handleStep = (playerGrid, solution) => {
const colLine = []; const colLine = [];
for (let r = 0; r < size; r++) colLine.push(playerGrid[r][c]); for (let r = 0; r < size; r++) colLine.push(playerGrid[r][c]);
const hints = colHints[c]; const hints = colHints[c];
const result = solveLineLogic(colLine, hints, size); const result = solveLineLogic(colLine, hints);
if (result.index !== -1) { if (result.index !== -1) {
const stateLabel = t(locale, result.state === 1 ? 'worker.state.filled' : 'worker.state.empty');
return { return {
type: 'move', type: 'move',
r: result.index, r: result.index,
c, c,
state: result.state, state: result.state,
statusText: `Logika: Kolumna ${c + 1}, Wiersz ${result.index + 1} -> ${result.state === 1 ? 'Pełne' : 'Puste'}` statusText: t(locale, 'worker.logicCol', { row: result.index + 1, col: c + 1, state: stateLabel })
}; };
} }
} }
for (let r = 0; r < size; r++) { // Check for guess logic - we want to avoid this unless strictly necessary
for (let c = 0; c < size; c++) { // If no logic move found, return 'stuck' instead of cheating
const current = playerGrid[r][c]; return { type: 'stuck', statusText: t(locale, 'worker.stuck') };
const target = solution[r][c];
let isCorrect = false;
if (target === 1 && current === 1) isCorrect = true;
if (target === 0 && current === 2) isCorrect = true;
if (target === 0 && current === 0) isCorrect = false;
if (target === 1 && current === 0) isCorrect = false;
if (!isCorrect) {
const newState = target === 1 ? 1 : 2;
return {
type: 'move',
r,
c,
state: newState,
statusText: `Zgadywanie: Wiersz ${r + 1}, Kolumna ${c + 1}`
};
}
}
}
return { type: 'done', statusText: 'Koniec!' };
}; };
self.onmessage = (event) => { self.onmessage = (event) => {
const { id, playerGrid, solution } = event.data; const { id, playerGrid, solution, locale } = event.data;
const result = handleStep(playerGrid, solution); const resolved = resolveLocale(locale);
const result = handleStep(playerGrid, solution, resolved);
self.postMessage({ id, ...result }); self.postMessage({ id, ...result });
}; };

60
update_i18n_guide.cjs Normal file
View File

@@ -0,0 +1,60 @@
const fs = require('fs');
const filePath = 'src/composables/useI18n.js';
let content = fs.readFileSync(filePath, 'utf8');
// 1. Add key to all language objects
const lines = content.split('\n');
const newLines = [];
let insideLang = false;
let currentLang = null;
for (let i = 0; i < lines.length; i++) {
const line = lines[i];
const langStartMatch = line.match(/^\s{2}(['"]?[\w-]+['"]?): \{/);
if (langStartMatch) {
insideLang = true;
currentLang = langStartMatch[1].replace(/['"]/g, '');
}
if (insideLang && (line.trim() === '},' || line.trim() === '}')) {
let translation = 'GUIDE';
if (currentLang === 'pl') translation = 'PRZEWODNIK';
if (currentLang === 'es') translation = 'GUÍA';
if (currentLang === 'fr') translation = 'GUIDE';
if (currentLang === 'de') translation = 'ANLEITUNG';
if (currentLang === 'it') translation = 'GUIDA';
if (currentLang === 'pt' || currentLang === 'pt-br') translation = 'GUIA';
if (currentLang === 'ru') translation = 'РУКОВОДСТВО';
if (currentLang === 'zh') translation = '指南';
// Ensure previous line has comma
if (newLines.length > 0) {
const lastLine = newLines[newLines.length - 1];
if (!lastLine.trim().endsWith(',') && !lastLine.trim().endsWith('{')) {
newLines[newLines.length - 1] = lastLine + ',';
}
}
newLines.push(` 'nav.guide': '${translation}'`);
insideLang = false;
currentLang = null;
}
newLines.push(line);
}
content = newLines.join('\n');
// 2. Add to requiredKeys
// Find "const requiredKeys = ["
// We know it ends with 'nav.newGame' now.
content = content.replace(
"'nav.newGame'",
"'nav.newGame','nav.guide'"
);
fs.writeFileSync(filePath, content);
console.log('Updated useI18n.js with nav.guide');

View File

@@ -1,9 +1,48 @@
import { defineConfig } from 'vite' import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue' import vue from '@vitejs/plugin-vue'
import { VitePWA } from 'vite-plugin-pwa'
import path from 'path' import path from 'path'
export default defineConfig({ export default defineConfig({
plugins: [vue()], define: {
'__APP_VERSION__': JSON.stringify(process.env.npm_package_version)
},
plugins: [
vue(),
VitePWA({
registerType: 'prompt',
injectRegister: 'auto',
workbox: {
cleanupOutdatedCaches: true,
globPatterns: ['**/*.{js,css,html,ico,png,svg,json,vue,txt,woff2}']
},
devOptions: {
enabled: true
},
manifest: {
name: 'Nonograms',
short_name: 'Nonograms',
description: 'Nonograms',
start_url: '/',
scope: '/',
display: 'standalone',
background_color: '#191654',
theme_color: '#00f2fe',
icons: [
{
src: '/pwa-192x192.svg',
sizes: '192x192',
type: 'image/svg+xml'
},
{
src: '/pwa-512x512.svg',
sizes: '512x512',
type: 'image/svg+xml'
}
]
}
})
],
resolve: { resolve: {
alias: { alias: {
'@': path.resolve(__dirname, './src') '@': path.resolve(__dirname, './src')

16
vitest.config.js Normal file
View File

@@ -0,0 +1,16 @@
import { defineConfig } from 'vitest/config'
import vue from '@vitejs/plugin-vue'
import path from 'path'
export default defineConfig({
plugins: [vue()],
test: {
globals: true,
environment: 'jsdom',
},
resolve: {
alias: {
'@': path.resolve(__dirname, './src')
}
}
})