Skip to content

Commit 6390095

Browse files
committed
feat: add more nonograms.
1 parent 2473a1a commit 6390095

File tree

1 file changed

+87
-3
lines changed

1 file changed

+87
-3
lines changed

src/pages/apps/NonogramPage.js

Lines changed: 87 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,88 @@ const PUZZLES = [
142142
[0, 1, 1, 1, 0],
143143
[0, 1, 0, 1, 0],
144144
],
145+
// 5x5 Letter 'A'
146+
[
147+
[0, 1, 1, 1, 0],
148+
[1, 0, 0, 0, 1],
149+
[1, 1, 1, 1, 1],
150+
[1, 0, 0, 0, 1],
151+
[1, 0, 0, 0, 1],
152+
],
153+
// 5x5 Star
154+
[
155+
[0, 0, 1, 0, 0],
156+
[0, 1, 1, 1, 0],
157+
[1, 1, 1, 1, 1],
158+
[0, 1, 0, 1, 0],
159+
[1, 0, 0, 0, 1],
160+
],
161+
// 5x5 Spiral
162+
[
163+
[1, 1, 1, 1, 1],
164+
[1, 0, 0, 0, 1],
165+
[1, 0, 1, 0, 1],
166+
[1, 0, 0, 0, 1],
167+
[1, 1, 1, 1, 1],
168+
],
169+
// 5x5 Mushroom
170+
[
171+
[0, 1, 1, 1, 0],
172+
[1, 1, 1, 1, 1],
173+
[0, 0, 1, 0, 0],
174+
[0, 0, 1, 0, 0],
175+
[0, 0, 1, 0, 0],
176+
],
177+
// 5x5 Rook (Chess Piece)
178+
[
179+
[1, 1, 1, 1, 1],
180+
[0, 1, 1, 1, 0],
181+
[0, 1, 1, 1, 0],
182+
[0, 1, 1, 1, 0],
183+
[1, 1, 1, 1, 1],
184+
],
185+
// 5x5 Hollow Diamond
186+
[
187+
[0, 0, 1, 0, 0],
188+
[0, 1, 0, 1, 0],
189+
[1, 0, 0, 0, 1],
190+
[0, 1, 0, 1, 0],
191+
[0, 0, 1, 0, 0],
192+
],
193+
// 5x5 Simple Boat
194+
[
195+
[0, 0, 0, 0, 0],
196+
[0, 1, 0, 1, 0],
197+
[1, 1, 1, 1, 1],
198+
[1, 1, 1, 1, 1],
199+
[0, 1, 1, 1, 0],
200+
],
201+
];
202+
203+
const PUZZLENAMES = [
204+
"Heart",
205+
"F for Fezcodex",
206+
"Diamond",
207+
"Cross",
208+
"House",
209+
"Smiley Face",
210+
"Nonogram (N)",
211+
"Checkerboard",
212+
"Plus Sign",
213+
"Arrow pointing up",
214+
"Simple Tree",
215+
"Fish",
216+
"Letter U",
217+
"Target",
218+
"Stairs",
219+
"Creeper Face",
220+
"Letter 'A'",
221+
"Star",
222+
"Spiral",
223+
"Mushroom",
224+
"Rook (Chess Piece)",
225+
"Hollow Diamond",
226+
"Simple Boat",
145227
];
146228

147229
// Helper to generate clues from a solved puzzle
@@ -218,13 +300,15 @@ const NonogramPage = () => {
218300
const [gameWon, setGameWon] = useState(false);
219301
const [message, setMessage] = useState('');
220302
const [activeTool, setActiveTool] = useState('fill'); // 'fill' or 'mark'
303+
const [puzzleName, setPuzzleName] = useState('');
221304

222305
const NUM_ROWS = solvedPuzzle.length;
223306
const NUM_COLS = solvedPuzzle.length > 0 ? solvedPuzzle[0].length : 0;
224307

225308
const initGame = useCallback(() => {
226309
const randomIndex = Math.floor(Math.random() * PUZZLES.length);
227310
const newSolvedPuzzle = PUZZLES[randomIndex];
311+
setPuzzleName(PUZZLENAMES[randomIndex]);
228312
setSolvedPuzzle(newSolvedPuzzle);
229313

230314
const { rowClues: newRowClues, colClues: newColClues } = generateClues(newSolvedPuzzle);
@@ -267,11 +351,11 @@ const NonogramPage = () => {
267351
if (playerGrid.length > 0 && solvedPuzzle.length > 0) {
268352
if (checkWin()) {
269353
setGameWon(true);
270-
setMessage('Congratulations! You solved the puzzle!');
271-
addToast({ message: 'You solved the Nonogram!', type: 'success' });
354+
setMessage(`Congratulations! You solved the '${puzzleName}' puzzle!`);
355+
addToast({ title:'Congratz...', message: `You solved the Nonogram: ${puzzleName}!`, type: 'success' });
272356
}
273357
}
274-
}, [playerGrid, solvedPuzzle, checkWin, addToast]);
358+
}, [playerGrid, solvedPuzzle, checkWin, addToast, puzzleName]);
275359

276360
const handleCellClick = (row, col, event) => {
277361
if (gameWon) return;

0 commit comments

Comments
 (0)