From 07f10955a505f8e3f11c9aeac7dd0ea752bd0500 Mon Sep 17 00:00:00 2001 From: Michel Wilhelm Date: Sun, 8 Nov 2020 00:13:59 -0300 Subject: [PATCH] when user wins, mark all unrevealed as falgged --- src/App.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/App.js b/src/App.js index b7374d7..7ddd8f5 100644 --- a/src/App.js +++ b/src/App.js @@ -64,6 +64,20 @@ function App() { if (activeGame && activeGame.win === true) { document.getElementsByClassName('reset')[0].innerHTML = '😎'; + + // Search for all unrevealed squares to put the flag + dummyBoard.map((row, rowId) => + row.map((col, colId) => { + const cell = document.getElementById(`cell_${rowId}_${colId}`); + if ( + !cell.classList.contains('revealed') && + !cell.classList.contains('empty') && + !cell.classList.contains('point') + ) { + cell.classList.add('flagged'); + } + }) + ); } });